blizzard_api 0.5.6 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +6 -2
- data/blizzard_api.gemspec +2 -1
- data/lib/blizzard_api/configuration.rb +10 -34
- data/lib/blizzard_api/diablo/community/act.rb +2 -2
- data/lib/blizzard_api/diablo/community/artisan.rb +2 -2
- data/lib/blizzard_api/diablo/community/character.rb +2 -2
- data/lib/blizzard_api/diablo/community/follower.rb +1 -1
- data/lib/blizzard_api/diablo/community/item.rb +1 -1
- data/lib/blizzard_api/diablo/community/item_type.rb +2 -2
- data/lib/blizzard_api/diablo/community/profile.rb +4 -4
- data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +3 -3
- data/lib/blizzard_api/hearthstone/game_data/back.rb +1 -1
- data/lib/blizzard_api/hearthstone/game_data/card.rb +2 -2
- data/lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb +2 -2
- data/lib/blizzard_api/request.rb +24 -7
- data/lib/blizzard_api/starcraft.rb +1 -1
- data/lib/blizzard_api/starcraft/community/account.rb +1 -1
- data/lib/blizzard_api/starcraft/community/ladder.rb +2 -2
- data/lib/blizzard_api/starcraft/community/legacy.rb +3 -4
- data/lib/blizzard_api/starcraft/community/profile.rb +5 -5
- data/lib/blizzard_api/starcraft/game_data/league.rb +1 -1
- data/lib/blizzard_api/version.rb +1 -1
- data/lib/blizzard_api/wow/game_data/achievement.rb +3 -3
- data/lib/blizzard_api/wow/game_data/auction.rb +20 -2
- data/lib/blizzard_api/wow/game_data/azerite_essence.rb +1 -1
- data/lib/blizzard_api/wow/game_data/covenant.rb +5 -5
- data/lib/blizzard_api/wow/game_data/creature.rb +13 -7
- data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +20 -8
- data/lib/blizzard_api/wow/game_data/guild_crest.rb +4 -2
- data/lib/blizzard_api/wow/game_data/item.rb +10 -6
- data/lib/blizzard_api/wow/game_data/journal.rb +8 -8
- data/lib/blizzard_api/wow/game_data/modified_crafting.rb +4 -4
- data/lib/blizzard_api/wow/game_data/mythic_keystone.rb +6 -6
- data/lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb +1 -1
- data/lib/blizzard_api/wow/game_data/mythic_keystone_leaderboard.rb +2 -2
- data/lib/blizzard_api/wow/game_data/mythic_raid_leaderboard.rb +1 -1
- data/lib/blizzard_api/wow/game_data/pet.rb +4 -4
- data/lib/blizzard_api/wow/game_data/playable_class.rb +10 -8
- data/lib/blizzard_api/wow/game_data/playable_specialization.rb +8 -8
- data/lib/blizzard_api/wow/game_data/profession.rb +4 -4
- data/lib/blizzard_api/wow/game_data/pvp_season.rb +5 -3
- data/lib/blizzard_api/wow/game_data/pvp_tier.rb +1 -1
- data/lib/blizzard_api/wow/game_data/quest.rb +6 -6
- data/lib/blizzard_api/wow/game_data/reputation.rb +4 -4
- data/lib/blizzard_api/wow/game_data/spell.rb +1 -1
- data/lib/blizzard_api/wow/game_data/talent.rb +2 -2
- data/lib/blizzard_api/wow/game_data/tech_talent.rb +3 -3
- data/lib/blizzard_api/wow/game_data/wow_token.rb +1 -1
- data/lib/blizzard_api/wow/profile/character_profile.rb +27 -27
- data/lib/blizzard_api/wow/profile/guild.rb +5 -5
- data/lib/blizzard_api/wow/profile/profile.rb +6 -6
- data/lib/blizzard_api/wow/search/search_composer.rb +2 -2
- data/lib/blizzard_api/wow/search/search_request.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daa79d3a8860c6cfd5b600090627933b7b2710ade24d4c76099198741accff97
|
4
|
+
data.tar.gz: f98d1226d19bfb605aa65c5380f7d3891b0b3fa733b7f85f3e21ba0d92ba9ee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97da96397847d2d55c09a1bf7fa8aa81fe828780b58dd4830635c06fcb4070799df4e271ffa92c2dd64e40caa5fe0ab78609a0cb3940abee8d91a73a09e3f156
|
7
|
+
data.tar.gz: 95cd4500e97f933fdd29ac2005524a3b1cb8b5283b82a61dd737a9f04bfaf6206dbc32869c95ff9ca95c72efebb8e3fb6d702126fad41a6f058cd81d88b4f173
|
data/.github/workflows/ruby.yml
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
Please view this file on the master branch, otherwise it may be outdated
|
2
2
|
|
3
|
+
**Version 0.6.3**
|
4
|
+
|
5
|
+
Fixed argument propagation in some profile methods.
|
6
|
+
|
7
|
+
**Version 0.6.2**
|
8
|
+
|
9
|
+
Fixed an encoding problem on search endpoints.
|
10
|
+
|
11
|
+
**Version 0.6.1**
|
12
|
+
|
13
|
+
Added support for TBCC and Classice Era endpoints.
|
14
|
+
|
15
|
+
**Version 0.6.0**
|
16
|
+
|
17
|
+
Upgraded gem dependencies and refactored the code to support Ruby 3.0.0
|
18
|
+
Required ruby version upgraded to 2.7.2
|
19
|
+
Added concurrency to all WoW game data *complete* methods. Default of 4 threads. Should be close to # of threads available.
|
20
|
+
|
3
21
|
**Version 0.5.6**
|
4
22
|
|
5
23
|
Upgrade gem dependencies to fix a security vulnerability
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
blizzard_api (0.
|
4
|
+
blizzard_api (0.6.3)
|
5
5
|
redis (~> 4.1, >= 4.1.0)
|
6
|
+
thwait (~> 0.2.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
11
|
ast (2.4.2)
|
11
12
|
dotenv (2.7.6)
|
13
|
+
e2mmap (0.1.0)
|
12
14
|
minitest (5.14.4)
|
13
15
|
parallel (1.20.1)
|
14
16
|
parser (3.0.1.1)
|
@@ -30,6 +32,8 @@ GEM
|
|
30
32
|
rubocop-ast (1.5.0)
|
31
33
|
parser (>= 3.0.1.1)
|
32
34
|
ruby-progressbar (1.11.0)
|
35
|
+
thwait (0.2.0)
|
36
|
+
e2mmap
|
33
37
|
unicode-display_width (1.7.0)
|
34
38
|
yard (0.9.26)
|
35
39
|
|
@@ -45,4 +49,4 @@ DEPENDENCIES
|
|
45
49
|
yard
|
46
50
|
|
47
51
|
BUNDLED WITH
|
48
|
-
2.
|
52
|
+
2.2.17
|
data/blizzard_api.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'blizzard_api/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.required_ruby_version = '>= 2.
|
8
|
+
spec.required_ruby_version = '>= 2.7.2'
|
9
9
|
spec.name = 'blizzard_api'
|
10
10
|
spec.version = BlizzardApi::VERSION
|
11
11
|
spec.authors = ['Francis Schiavo']
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.require_paths = ['lib']
|
36
36
|
|
37
37
|
spec.add_runtime_dependency 'redis', '~> 4.1', '>= 4.1.0'
|
38
|
+
spec.add_runtime_dependency 'thwait', '~> 0.2.0'
|
38
39
|
|
39
40
|
spec.add_development_dependency 'dotenv'
|
40
41
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
@@ -45,13 +45,12 @@ module BlizzardApi
|
|
45
45
|
attr_accessor :redis_port
|
46
46
|
|
47
47
|
##
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
54
|
-
attr_accessor :format
|
48
|
+
#
|
49
|
+
# @!attribute concurrency
|
50
|
+
# How many threads to use for WoW game data `complete` payloads. Defaults to 4.
|
51
|
+
# Should be set to the amount of available cores on the system.
|
52
|
+
# @return [Integer] Concurrency
|
53
|
+
attr_writer :concurrency
|
55
54
|
|
56
55
|
##
|
57
56
|
# @!attribute access_token
|
@@ -59,33 +58,6 @@ module BlizzardApi
|
|
59
58
|
# @return [String] Access token.
|
60
59
|
attr_accessor :access_token
|
61
60
|
|
62
|
-
##
|
63
|
-
# @!attribute icons_directory
|
64
|
-
# Icons directory.
|
65
|
-
# This directory stores icons for many World of Warcraft endpoints.
|
66
|
-
# @return [String] icons_directory
|
67
|
-
attr_accessor :wow_icons_directory
|
68
|
-
|
69
|
-
##
|
70
|
-
# @!attribute guild_emblem_directory
|
71
|
-
# Guild crest images directory. Some sub directories will be created.
|
72
|
-
# @see https://develop.battle.net/access/clients
|
73
|
-
# @return [String] Guild crest directory
|
74
|
-
attr_accessor :wow_guild_crest_directory
|
75
|
-
|
76
|
-
##
|
77
|
-
# @!attribute wow_character_profile_directory
|
78
|
-
# This directory stores images for World of Warcraft character profiles. Sub directories will be created for
|
79
|
-
# each realm and character.
|
80
|
-
# @return [String] Character profile media directory
|
81
|
-
attr_accessor :wow_character_profile_directory
|
82
|
-
|
83
|
-
##
|
84
|
-
# @!attribute wow_npc_directory
|
85
|
-
# This directory stores images for World of Warcraft NPCs and creatures.
|
86
|
-
# @return [String] NPCs media directory
|
87
|
-
attr_accessor :wow_npc_directory
|
88
|
-
|
89
61
|
##
|
90
62
|
# This method return the singleton instance of the configuration module. Use this to initialize the default values
|
91
63
|
# and options.
|
@@ -110,5 +82,9 @@ module BlizzardApi
|
|
110
82
|
def configure
|
111
83
|
yield self
|
112
84
|
end
|
85
|
+
|
86
|
+
def concurrency
|
87
|
+
@concurrency ||= 4
|
88
|
+
end
|
113
89
|
end
|
114
90
|
end
|
@@ -17,7 +17,7 @@ module BlizzardApi
|
|
17
17
|
#
|
18
18
|
# @!macro response
|
19
19
|
def index(**options)
|
20
|
-
api_request "#{base_url(:community)}/data/act", { ttl: CACHE_TRIMESTER }.merge(options)
|
20
|
+
api_request "#{base_url(:community)}/data/act", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -28,7 +28,7 @@ module BlizzardApi
|
|
28
28
|
#
|
29
29
|
# @!macro response
|
30
30
|
def get(id, **options)
|
31
|
-
api_request "#{base_url(:community)}/data/act/#{id}", { ttl: CACHE_TRIMESTER }.merge(options)
|
31
|
+
api_request "#{base_url(:community)}/data/act/#{id}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -18,7 +18,7 @@ module BlizzardApi
|
|
18
18
|
#
|
19
19
|
# @!macro response
|
20
20
|
def get(artisan_slug, **options)
|
21
|
-
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
21
|
+
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
22
22
|
end
|
23
23
|
|
24
24
|
##
|
@@ -31,7 +31,7 @@ module BlizzardApi
|
|
31
31
|
# @!macro response
|
32
32
|
def recipe(artisan_slug, recipe_slug, **options)
|
33
33
|
opts = { ttl: CACHE_TRIMESTER }.merge(options)
|
34
|
-
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}/recipe/#{recipe_slug}", opts
|
34
|
+
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}/recipe/#{recipe_slug}", **opts
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -18,7 +18,7 @@ module BlizzardApi
|
|
18
18
|
#
|
19
19
|
# @!macro response
|
20
20
|
def get(class_slug, **options)
|
21
|
-
api_request "#{base_url(:community)}/data/hero/#{class_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
21
|
+
api_request "#{base_url(:community)}/data/hero/#{class_slug}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
22
22
|
end
|
23
23
|
|
24
24
|
##
|
@@ -31,7 +31,7 @@ module BlizzardApi
|
|
31
31
|
# @!macro response
|
32
32
|
def skill(class_slug, skill_slug, **options)
|
33
33
|
opts = { ttl: CACHE_TRIMESTER }.merge(options)
|
34
|
-
api_request "#{base_url(:community)}/data/hero/#{class_slug}/skill/#{skill_slug}", opts
|
34
|
+
api_request "#{base_url(:community)}/data/hero/#{class_slug}/skill/#{skill_slug}", **opts
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -18,7 +18,7 @@ module BlizzardApi
|
|
18
18
|
#
|
19
19
|
# @!macro response
|
20
20
|
def get(follower_slug, **options)
|
21
|
-
api_request "#{base_url(:community)}/data/follower/#{follower_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
21
|
+
api_request "#{base_url(:community)}/data/follower/#{follower_slug}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -18,7 +18,7 @@ module BlizzardApi
|
|
18
18
|
#
|
19
19
|
# @!macro response
|
20
20
|
def get(item_slug_and_id, **options)
|
21
|
-
api_request "#{base_url(:community)}/data/item/#{item_slug_and_id}", { ttl: CACHE_TRIMESTER }.merge(options)
|
21
|
+
api_request "#{base_url(:community)}/data/item/#{item_slug_and_id}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -17,7 +17,7 @@ module BlizzardApi
|
|
17
17
|
#
|
18
18
|
# @!macro response
|
19
19
|
def index(**options)
|
20
|
-
api_request "#{base_url(:community)}/data/item-type", { ttl: CACHE_TRIMESTER }.merge(options)
|
20
|
+
api_request "#{base_url(:community)}/data/item-type", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -28,7 +28,7 @@ module BlizzardApi
|
|
28
28
|
#
|
29
29
|
# @!macro response
|
30
30
|
def get(item_type_slug, **options)
|
31
|
-
api_request "#{base_url(:community)}/data/item-type/#{item_type_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
31
|
+
api_request "#{base_url(:community)}/data/item-type/#{item_type_slug}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -22,7 +22,7 @@ module BlizzardApi
|
|
22
22
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
23
23
|
def index(battletag, oauth_token, **options)
|
24
24
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
25
|
-
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/", opts
|
25
|
+
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/", **opts
|
26
26
|
end
|
27
27
|
|
28
28
|
##
|
@@ -38,7 +38,7 @@ module BlizzardApi
|
|
38
38
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
39
39
|
def hero(battletag, oauth_token, hero_id, **options)
|
40
40
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
41
|
-
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}", opts
|
41
|
+
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}", **opts
|
42
42
|
end
|
43
43
|
|
44
44
|
##
|
@@ -54,7 +54,7 @@ module BlizzardApi
|
|
54
54
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
55
55
|
def hero_items(battletag, oauth_token, hero_id, **options)
|
56
56
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
57
|
-
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/items", opts
|
57
|
+
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/items", **opts
|
58
58
|
end
|
59
59
|
|
60
60
|
##
|
@@ -70,7 +70,7 @@ module BlizzardApi
|
|
70
70
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
71
71
|
def hero_follower_items(battletag, oauth_token, hero_id, **options)
|
72
72
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
73
|
-
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/follower-items", opts
|
73
|
+
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/follower-items", **opts
|
74
74
|
end
|
75
75
|
|
76
76
|
private
|
@@ -17,7 +17,7 @@ module BlizzardApi
|
|
17
17
|
#
|
18
18
|
# @!macro response
|
19
19
|
def index(**options)
|
20
|
-
api_request "#{base_url(:game_data)}/#{@endpoint}/", default_options.merge(options)
|
20
|
+
api_request "#{base_url(:game_data)}/#{@endpoint}/", **default_options.merge(options)
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -28,7 +28,7 @@ module BlizzardApi
|
|
28
28
|
#
|
29
29
|
# @!macro response
|
30
30
|
def get(id, **options)
|
31
|
-
api_request "#{base_url(:game_data)}/#{@endpoint}/#{id}", default_options.merge(options)
|
31
|
+
api_request "#{base_url(:game_data)}/#{@endpoint}/#{id}", **default_options.merge(options)
|
32
32
|
end
|
33
33
|
|
34
34
|
##
|
@@ -41,7 +41,7 @@ module BlizzardApi
|
|
41
41
|
# @!macro response
|
42
42
|
def leaderboard(id, leaderboard_id, **options)
|
43
43
|
opts = default_options.merge(options)
|
44
|
-
api_request "#{base_url(:game_data)}/#{@endpoint}/#{id}/leaderboard/#{leaderboard_id}", opts
|
44
|
+
api_request "#{base_url(:game_data)}/#{@endpoint}/#{id}/leaderboard/#{leaderboard_id}", **opts
|
45
45
|
end
|
46
46
|
|
47
47
|
protected
|
@@ -39,7 +39,7 @@ module BlizzardApi
|
|
39
39
|
def search(search_options = {}, **options)
|
40
40
|
validate_search_options search_options if options.include? :validate_fields
|
41
41
|
|
42
|
-
api_request "#{base_url(:community)}/cardbacks", default_options.merge(options).merge(search_options)
|
42
|
+
api_request "#{base_url(:community)}/cardbacks", **default_options.merge(options).merge(search_options)
|
43
43
|
end
|
44
44
|
|
45
45
|
protected
|
@@ -75,7 +75,7 @@ module BlizzardApi
|
|
75
75
|
def search(search_options = {}, **options)
|
76
76
|
validate_search_options search_options if options.include? :validate_fields
|
77
77
|
|
78
|
-
api_request "#{base_url(:community)}/cards", default_options.merge(options).merge(search_options)
|
78
|
+
api_request "#{base_url(:community)}/cards", **default_options.merge(options).merge(search_options)
|
79
79
|
end
|
80
80
|
|
81
81
|
##
|
@@ -91,7 +91,7 @@ module BlizzardApi
|
|
91
91
|
#
|
92
92
|
# @!macro response
|
93
93
|
def get(id_or_slug, game_mode = 'constructed', **options)
|
94
|
-
super id_or_slug, { gameMode: game_mode }.merge(options)
|
94
|
+
super id_or_slug, **{ gameMode: game_mode }.merge(options)
|
95
95
|
end
|
96
96
|
|
97
97
|
protected
|
@@ -21,7 +21,7 @@ module BlizzardApi
|
|
21
21
|
#
|
22
22
|
# @!macro response
|
23
23
|
def index(**options)
|
24
|
-
api_request "#{base_url(:community)}/#{@endpoint}/", default_options.merge(options)
|
24
|
+
api_request "#{base_url(:community)}/#{@endpoint}/", **default_options.merge(options)
|
25
25
|
end
|
26
26
|
|
27
27
|
##
|
@@ -32,7 +32,7 @@ module BlizzardApi
|
|
32
32
|
#
|
33
33
|
# @!macro response
|
34
34
|
def get(id, **options)
|
35
|
-
api_request "#{base_url(:community)}/#{@endpoint}/#{id}", default_options.merge(options)
|
35
|
+
api_request "#{base_url(:community)}/#{@endpoint}/#{id}", **default_options.merge(options)
|
36
36
|
end
|
37
37
|
|
38
38
|
protected
|
data/lib/blizzard_api/request.rb
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
# @option options [Boolean] :ignore_cache If set to true the request will not use the cache
|
10
10
|
# @option options [Integer] :ttl Override the default time (in seconds) a request should be cached
|
11
11
|
# @option options [DateTime] :since Adds the If-modified-since headers. Will always ignore cache when set.
|
12
|
+
# @option options [Integer] :concurrency How many threads to use for complete sets of data.
|
13
|
+
# BEWARE: Might cause 429 responses, in this case lower the number.
|
12
14
|
|
13
15
|
##
|
14
16
|
# @!macro [new] regions
|
@@ -83,16 +85,31 @@ module BlizzardApi
|
|
83
85
|
format BASE_URLS[scope], region, @game
|
84
86
|
end
|
85
87
|
|
88
|
+
##
|
89
|
+
# Returns a valid version namespace
|
90
|
+
#
|
91
|
+
# @param [Hash] options A hash containing a valid namespace key
|
92
|
+
def endpoint_version(options)
|
93
|
+
if options.key? :classic
|
94
|
+
'classic-'
|
95
|
+
elsif options.key? :classic1x
|
96
|
+
'classic1x-'
|
97
|
+
else
|
98
|
+
''
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
86
102
|
##
|
87
103
|
# Returns a valid namespace string for consuming the api endpoints
|
88
104
|
#
|
89
105
|
# @param [Hash] options A hash containing the namespace key
|
90
106
|
def endpoint_namespace(options)
|
107
|
+
version = endpoint_version(options)
|
91
108
|
case options[:namespace]
|
92
109
|
when :dynamic
|
93
|
-
|
110
|
+
"dynamic-#{version}#{region}"
|
94
111
|
when :static
|
95
|
-
|
112
|
+
"static-#{version}#{region}"
|
96
113
|
when :profile
|
97
114
|
"profile-#{region}"
|
98
115
|
else
|
@@ -124,7 +141,7 @@ module BlizzardApi
|
|
124
141
|
# If data was found that means cache is enabled and valid
|
125
142
|
return JSON.parse(data, symbolize_names: true) if data
|
126
143
|
|
127
|
-
response = consume_api parsed_url, options
|
144
|
+
response = consume_api parsed_url, **options
|
128
145
|
|
129
146
|
save_in_cache parsed_url.to_s, response.body, options[:ttl] || CACHE_DAY if using_cache? options
|
130
147
|
|
@@ -134,9 +151,9 @@ module BlizzardApi
|
|
134
151
|
response_data
|
135
152
|
end
|
136
153
|
|
137
|
-
def api_request(uri, query_string
|
154
|
+
def api_request(uri, **query_string)
|
138
155
|
# List of request options
|
139
|
-
options_key = %i[ignore_cache ttl format access_token namespace classic headers since]
|
156
|
+
options_key = %i[ignore_cache ttl format access_token namespace classic classic1x headers since]
|
140
157
|
|
141
158
|
# Separates request options from api fields and options. Any user-defined option will be treated as api field.
|
142
159
|
options = query_string.select { |k, _v| query_string.delete(k) || true if options_key.include? k }
|
@@ -150,7 +167,7 @@ module BlizzardApi
|
|
150
167
|
uri = uri.include?('?') ? "#{uri}&#{query_string}" : "#{uri}?#{query_string}"
|
151
168
|
end
|
152
169
|
|
153
|
-
request uri, options
|
170
|
+
request uri, **options
|
154
171
|
end
|
155
172
|
|
156
173
|
private
|
@@ -174,7 +191,7 @@ module BlizzardApi
|
|
174
191
|
# Executes the request
|
175
192
|
http.request(request).tap do |response|
|
176
193
|
if mode.eql?(:regular) && ![200, 304].include?(response.code.to_i)
|
177
|
-
raise BlizzardApi::ApiException.new
|
194
|
+
raise BlizzardApi::ApiException.new "Request failed with code '#{response.code}' details: #{response.to_hash}", response.code.to_i
|
178
195
|
end
|
179
196
|
end
|
180
197
|
end
|