blizzard_api 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +21 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +21 -17
- data/README.md +58 -218
- data/blizzard_api.gemspec +8 -5
- data/lib/blizzard_api/configuration.rb +10 -34
- data/lib/blizzard_api/diablo/community/act.rb +4 -4
- data/lib/blizzard_api/diablo/community/artisan.rb +4 -4
- data/lib/blizzard_api/diablo/community/character.rb +4 -4
- data/lib/blizzard_api/diablo/community/follower.rb +2 -2
- data/lib/blizzard_api/diablo/community/item.rb +2 -2
- data/lib/blizzard_api/diablo/community/item_type.rb +4 -4
- data/lib/blizzard_api/diablo/community/profile.rb +4 -4
- data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +6 -6
- data/lib/blizzard_api/hearthstone/game_data/back.rb +2 -2
- data/lib/blizzard_api/hearthstone/game_data/card.rb +4 -4
- data/lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb +4 -4
- data/lib/blizzard_api/request.rb +8 -7
- data/lib/blizzard_api/starcraft.rb +7 -0
- data/lib/blizzard_api/starcraft/community/account.rb +1 -1
- data/lib/blizzard_api/starcraft/community/ladder.rb +4 -4
- data/lib/blizzard_api/starcraft/community/legacy.rb +88 -0
- data/lib/blizzard_api/starcraft/community/profile.rb +10 -10
- data/lib/blizzard_api/starcraft/game_data/league.rb +2 -2
- data/lib/blizzard_api/version.rb +1 -1
- data/lib/blizzard_api/wow.rb +0 -7
- data/lib/blizzard_api/wow/game_data/achievement.rb +6 -6
- data/lib/blizzard_api/wow/game_data/auction.rb +2 -2
- data/lib/blizzard_api/wow/game_data/azerite_essence.rb +2 -2
- data/lib/blizzard_api/wow/game_data/covenant.rb +10 -10
- data/lib/blizzard_api/wow/game_data/creature.rb +12 -12
- data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +23 -11
- data/lib/blizzard_api/wow/game_data/guild_crest.rb +4 -4
- data/lib/blizzard_api/wow/game_data/item.rb +12 -12
- data/lib/blizzard_api/wow/game_data/journal.rb +15 -15
- data/lib/blizzard_api/wow/game_data/modified_crafting.rb +8 -8
- data/lib/blizzard_api/wow/game_data/mythic_keystone.rb +12 -12
- data/lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb +2 -2
- data/lib/blizzard_api/wow/game_data/mythic_keystone_leaderboard.rb +4 -4
- data/lib/blizzard_api/wow/game_data/mythic_raid_leaderboard.rb +2 -2
- data/lib/blizzard_api/wow/game_data/pet.rb +8 -8
- data/lib/blizzard_api/wow/game_data/playable_class.rb +12 -12
- data/lib/blizzard_api/wow/game_data/playable_specialization.rb +10 -10
- data/lib/blizzard_api/wow/game_data/profession.rb +8 -8
- data/lib/blizzard_api/wow/game_data/pvp_season.rb +6 -6
- data/lib/blizzard_api/wow/game_data/pvp_tier.rb +2 -2
- data/lib/blizzard_api/wow/game_data/quest.rb +12 -12
- data/lib/blizzard_api/wow/game_data/reputation.rb +8 -8
- data/lib/blizzard_api/wow/game_data/spell.rb +2 -2
- data/lib/blizzard_api/wow/game_data/talent.rb +4 -4
- data/lib/blizzard_api/wow/game_data/tech_talent.rb +6 -6
- data/lib/blizzard_api/wow/game_data/wow_token.rb +2 -2
- data/lib/blizzard_api/wow/profile/character_profile.rb +53 -53
- data/lib/blizzard_api/wow/profile/guild.rb +10 -10
- data/lib/blizzard_api/wow/profile/profile.rb +10 -10
- data/lib/blizzard_api/wow/search/search_request.rb +2 -2
- metadata +27 -10
- data/.gitlab-ci.yml +0 -12
@@ -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_accessor :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
|
@@ -16,8 +16,8 @@ module BlizzardApi
|
|
16
16
|
# @!macro request_options
|
17
17
|
#
|
18
18
|
# @!macro response
|
19
|
-
def index(options
|
20
|
-
api_request "#{base_url(:community)}/data/act", { ttl: CACHE_TRIMESTER }.merge(options)
|
19
|
+
def index(**options)
|
20
|
+
api_request "#{base_url(:community)}/data/act", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -27,8 +27,8 @@ module BlizzardApi
|
|
27
27
|
# @!macro request_options
|
28
28
|
#
|
29
29
|
# @!macro response
|
30
|
-
def get(id, options
|
31
|
-
api_request "#{base_url(:community)}/data/act/#{id}", { ttl: CACHE_TRIMESTER }.merge(options)
|
30
|
+
def get(id, **options)
|
31
|
+
api_request "#{base_url(:community)}/data/act/#{id}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -17,8 +17,8 @@ module BlizzardApi
|
|
17
17
|
# @!macro request_options
|
18
18
|
#
|
19
19
|
# @!macro response
|
20
|
-
def get(artisan_slug, options
|
21
|
-
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
20
|
+
def get(artisan_slug, **options)
|
21
|
+
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
22
22
|
end
|
23
23
|
|
24
24
|
##
|
@@ -29,9 +29,9 @@ module BlizzardApi
|
|
29
29
|
# @!macro request_options
|
30
30
|
#
|
31
31
|
# @!macro response
|
32
|
-
def recipe(artisan_slug, recipe_slug, options
|
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
|
@@ -17,8 +17,8 @@ module BlizzardApi
|
|
17
17
|
# @!macro request_options
|
18
18
|
#
|
19
19
|
# @!macro response
|
20
|
-
def get(class_slug, options
|
21
|
-
api_request "#{base_url(:community)}/data/hero/#{class_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
20
|
+
def get(class_slug, **options)
|
21
|
+
api_request "#{base_url(:community)}/data/hero/#{class_slug}", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
22
22
|
end
|
23
23
|
|
24
24
|
##
|
@@ -29,9 +29,9 @@ module BlizzardApi
|
|
29
29
|
# @!macro request_options
|
30
30
|
#
|
31
31
|
# @!macro response
|
32
|
-
def skill(class_slug, skill_slug, options
|
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
|
@@ -17,8 +17,8 @@ module BlizzardApi
|
|
17
17
|
# @!macro request_options
|
18
18
|
#
|
19
19
|
# @!macro response
|
20
|
-
def get(follower_slug, options
|
21
|
-
api_request "#{base_url(:community)}/data/follower/#{follower_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
20
|
+
def get(follower_slug, **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
|
@@ -17,8 +17,8 @@ module BlizzardApi
|
|
17
17
|
# @!macro request_options
|
18
18
|
#
|
19
19
|
# @!macro response
|
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)
|
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)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -16,8 +16,8 @@ module BlizzardApi
|
|
16
16
|
# @!macro request_options
|
17
17
|
#
|
18
18
|
# @!macro response
|
19
|
-
def index(options
|
20
|
-
api_request "#{base_url(:community)}/data/item-type", { ttl: CACHE_TRIMESTER }.merge(options)
|
19
|
+
def index(**options)
|
20
|
+
api_request "#{base_url(:community)}/data/item-type", **{ ttl: CACHE_TRIMESTER }.merge(options)
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -27,8 +27,8 @@ module BlizzardApi
|
|
27
27
|
# @!macro request_options
|
28
28
|
#
|
29
29
|
# @!macro response
|
30
|
-
def get(item_type_slug, options
|
31
|
-
api_request "#{base_url(:community)}/data/item-type/#{item_type_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
30
|
+
def get(item_type_slug, **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
|
@@ -20,7 +20,7 @@ module BlizzardApi
|
|
20
20
|
# @!macro response
|
21
21
|
#
|
22
22
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
23
|
-
def index(battletag, oauth_token, options
|
23
|
+
def index(battletag, oauth_token, **options)
|
24
24
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
25
25
|
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/", opts
|
26
26
|
end
|
@@ -36,7 +36,7 @@ module BlizzardApi
|
|
36
36
|
# @!macro response
|
37
37
|
#
|
38
38
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
39
|
-
def hero(battletag, oauth_token, hero_id, options
|
39
|
+
def hero(battletag, oauth_token, hero_id, **options)
|
40
40
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
41
41
|
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}", opts
|
42
42
|
end
|
@@ -52,7 +52,7 @@ module BlizzardApi
|
|
52
52
|
# @!macro response
|
53
53
|
#
|
54
54
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
55
|
-
def hero_items(battletag, oauth_token, hero_id, options
|
55
|
+
def hero_items(battletag, oauth_token, hero_id, **options)
|
56
56
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
57
57
|
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/items", opts
|
58
58
|
end
|
@@ -68,7 +68,7 @@ module BlizzardApi
|
|
68
68
|
# @!macro response
|
69
69
|
#
|
70
70
|
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
71
|
-
def hero_follower_items(battletag, oauth_token, hero_id, options
|
71
|
+
def hero_follower_items(battletag, oauth_token, hero_id, **options)
|
72
72
|
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
73
73
|
api_request "#{base_url(:community)}/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/follower-items", opts
|
74
74
|
end
|
@@ -16,8 +16,8 @@ module BlizzardApi
|
|
16
16
|
# @!macro request_options
|
17
17
|
#
|
18
18
|
# @!macro response
|
19
|
-
def index(options
|
20
|
-
api_request "#{base_url(:game_data)}/#{@endpoint}/", default_options.merge(options)
|
19
|
+
def index(**options)
|
20
|
+
api_request "#{base_url(:game_data)}/#{@endpoint}/", **default_options.merge(options)
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -27,8 +27,8 @@ module BlizzardApi
|
|
27
27
|
# @!macro request_options
|
28
28
|
#
|
29
29
|
# @!macro response
|
30
|
-
def get(id, options
|
31
|
-
api_request "#{base_url(:game_data)}/#{@endpoint}/#{id}", default_options.merge(options)
|
30
|
+
def get(id, **options)
|
31
|
+
api_request "#{base_url(:game_data)}/#{@endpoint}/#{id}", **default_options.merge(options)
|
32
32
|
end
|
33
33
|
|
34
34
|
##
|
@@ -39,9 +39,9 @@ module BlizzardApi
|
|
39
39
|
# @!macro request_options
|
40
40
|
#
|
41
41
|
# @!macro response
|
42
|
-
def leaderboard(id, leaderboard_id, options
|
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
|
@@ -36,10 +36,10 @@ module BlizzardApi
|
|
36
36
|
# option is invalid
|
37
37
|
#
|
38
38
|
# @!macro response
|
39
|
-
def search(search_options = {}, options
|
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
|
@@ -72,10 +72,10 @@ module BlizzardApi
|
|
72
72
|
# option is invalid
|
73
73
|
#
|
74
74
|
# @!macro response
|
75
|
-
def search(search_options = {}, options
|
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
|
##
|
@@ -90,8 +90,8 @@ module BlizzardApi
|
|
90
90
|
# @!macro request_options
|
91
91
|
#
|
92
92
|
# @!macro response
|
93
|
-
def get(id_or_slug, game_mode = 'constructed', options
|
94
|
-
super id_or_slug, { gameMode: game_mode }.merge(options)
|
93
|
+
def get(id_or_slug, game_mode = 'constructed', **options)
|
94
|
+
super id_or_slug, **{ gameMode: game_mode }.merge(options)
|
95
95
|
end
|
96
96
|
|
97
97
|
protected
|
@@ -20,8 +20,8 @@ module BlizzardApi
|
|
20
20
|
# @!macro request_options
|
21
21
|
#
|
22
22
|
# @!macro response
|
23
|
-
def index(options
|
24
|
-
api_request "#{base_url(:community)}/#{@endpoint}/", default_options.merge(options)
|
23
|
+
def index(**options)
|
24
|
+
api_request "#{base_url(:community)}/#{@endpoint}/", **default_options.merge(options)
|
25
25
|
end
|
26
26
|
|
27
27
|
##
|
@@ -31,8 +31,8 @@ module BlizzardApi
|
|
31
31
|
# @!macro request_options
|
32
32
|
#
|
33
33
|
# @!macro response
|
34
|
-
def get(id, options
|
35
|
-
api_request "#{base_url(:community)}/#{@endpoint}/#{id}", default_options.merge(options)
|
34
|
+
def get(id, **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,7 @@
|
|
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. BEWARE: Might cause 429 responses, in this case lower the number.
|
12
13
|
|
13
14
|
##
|
14
15
|
# @!macro [new] regions
|
@@ -17,7 +18,7 @@
|
|
17
18
|
|
18
19
|
##
|
19
20
|
# @!macro [new] response
|
20
|
-
# @return [
|
21
|
+
# @return [Hash] API Response. The actual type of the returned object depends on the *format* option
|
21
22
|
# in the configuration module
|
22
23
|
|
23
24
|
##
|
@@ -115,7 +116,7 @@ module BlizzardApi
|
|
115
116
|
BlizzardApi.access_token = JSON.parse(response.body)['access_token']
|
116
117
|
end
|
117
118
|
|
118
|
-
def request(url, options
|
119
|
+
def request(url, **options)
|
119
120
|
# Creates the whole url for request
|
120
121
|
parsed_url = URI.parse(url)
|
121
122
|
|
@@ -124,7 +125,7 @@ module BlizzardApi
|
|
124
125
|
# If data was found that means cache is enabled and valid
|
125
126
|
return JSON.parse(data, symbolize_names: true) if data
|
126
127
|
|
127
|
-
response = consume_api parsed_url, options
|
128
|
+
response = consume_api parsed_url, **options
|
128
129
|
|
129
130
|
save_in_cache parsed_url.to_s, response.body, options[:ttl] || CACHE_DAY if using_cache? options
|
130
131
|
|
@@ -134,7 +135,7 @@ module BlizzardApi
|
|
134
135
|
response_data
|
135
136
|
end
|
136
137
|
|
137
|
-
def api_request(uri, query_string
|
138
|
+
def api_request(uri, **query_string)
|
138
139
|
# List of request options
|
139
140
|
options_key = %i[ignore_cache ttl format access_token namespace classic headers since]
|
140
141
|
|
@@ -150,7 +151,7 @@ module BlizzardApi
|
|
150
151
|
uri = uri.include?('?') ? "#{uri}&#{query_string}" : "#{uri}?#{query_string}"
|
151
152
|
end
|
152
153
|
|
153
|
-
request uri, options
|
154
|
+
request uri, **options
|
154
155
|
end
|
155
156
|
|
156
157
|
private
|
@@ -163,7 +164,7 @@ module BlizzardApi
|
|
163
164
|
!options.fetch(:ignore_cache, false)
|
164
165
|
end
|
165
166
|
|
166
|
-
def consume_api(url, options
|
167
|
+
def consume_api(url, **options)
|
167
168
|
# Creates a HTTP connection and request to ensure thread safety
|
168
169
|
http = Net::HTTP.new(url.host, url.port)
|
169
170
|
http.use_ssl = true
|
@@ -174,7 +175,7 @@ module BlizzardApi
|
|
174
175
|
# Executes the request
|
175
176
|
http.request(request).tap do |response|
|
176
177
|
if mode.eql?(:regular) && ![200, 304].include?(response.code.to_i)
|
177
|
-
raise BlizzardApi::ApiException.new
|
178
|
+
raise BlizzardApi::ApiException.new "Request failed with code '#{response.code}' details: #{response.to_hash}", response.code.to_i
|
178
179
|
end
|
179
180
|
end
|
180
181
|
end
|
@@ -19,6 +19,7 @@ module BlizzardApi
|
|
19
19
|
require_relative 'starcraft/community/profile'
|
20
20
|
require_relative 'starcraft/community/ladder'
|
21
21
|
require_relative 'starcraft/community/account'
|
22
|
+
require_relative 'starcraft/community/legacy'
|
22
23
|
|
23
24
|
##
|
24
25
|
# @param region [String] API Region
|
@@ -40,5 +41,11 @@ module BlizzardApi
|
|
40
41
|
def self.account(region = BlizzardApi.region)
|
41
42
|
BlizzardApi::Starcraft::Account.new(region)
|
42
43
|
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# @return {Legacy}
|
47
|
+
def self.legacy(region = BlizzardApi.region)
|
48
|
+
BlizzardApi::Starcraft::Legacy.new(region)
|
49
|
+
end
|
43
50
|
end
|
44
51
|
end
|
@@ -15,7 +15,7 @@ module BlizzardApi
|
|
15
15
|
#
|
16
16
|
# @param [Integer] account_id Account ID
|
17
17
|
# @!macro request_options
|
18
|
-
def player(account_id, options
|
18
|
+
def player(account_id, **options)
|
19
19
|
api_request "#{base_url(:community)}/player/#{account_id}", { ttl: CACHE_DAY }.merge(options)
|
20
20
|
end
|
21
21
|
end
|
@@ -15,9 +15,9 @@ module BlizzardApi
|
|
15
15
|
#
|
16
16
|
# @!macro sc2_regions
|
17
17
|
# @!macro request_options
|
18
|
-
def grandmaster(region_id, options
|
18
|
+
def grandmaster(region_id, **options)
|
19
19
|
reg = resolve_region(region_id)
|
20
|
-
api_request "#{base_url(:community)}/ladder/grandmaster/#{reg}", { ttl: CACHE_DAY }.merge(options)
|
20
|
+
api_request "#{base_url(:community)}/ladder/grandmaster/#{reg}", **{ ttl: CACHE_DAY }.merge(options)
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -25,9 +25,9 @@ module BlizzardApi
|
|
25
25
|
#
|
26
26
|
# @!macro sc2_regions
|
27
27
|
# @!macro request_options
|
28
|
-
def season(region_id, options
|
28
|
+
def season(region_id, **options)
|
29
29
|
reg = resolve_region(region_id)
|
30
|
-
api_request "#{base_url(:community)}/ladder/season/#{reg}", { ttl: CACHE_DAY }.merge(options)
|
30
|
+
api_request "#{base_url(:community)}/ladder/season/#{reg}", **{ ttl: CACHE_DAY }.merge(options)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Starcraft
|
5
|
+
##
|
6
|
+
# This class allows access to Starcraft II legacy data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/starcraft-2-game-data-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Starcraft.legacy
|
12
|
+
class Legacy < Starcraft::Request
|
13
|
+
|
14
|
+
##
|
15
|
+
# Profile data
|
16
|
+
#
|
17
|
+
# @!macro sc2_regions
|
18
|
+
# @param [Integer] realm_id Realm ID
|
19
|
+
# @param [Integer] profile_id Profile ID
|
20
|
+
# @!macro request_options
|
21
|
+
def profile(region_id, realm_id, profile_id, **options)
|
22
|
+
reg = resolve_region(region_id)
|
23
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
24
|
+
api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}", opts
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Ladders
|
29
|
+
#
|
30
|
+
# @!macro sc2_regions
|
31
|
+
# @param [Integer] realm_id Realm ID
|
32
|
+
# @param [Integer] profile_id Profile ID
|
33
|
+
# @!macro request_options
|
34
|
+
def ladders(region_id, realm_id, profile_id, **options)
|
35
|
+
reg = resolve_region(region_id)
|
36
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
37
|
+
api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}/ladder ", opts
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Match History
|
42
|
+
#
|
43
|
+
# @!macro sc2_regions
|
44
|
+
# @param [Integer] realm_id Realm ID
|
45
|
+
# @param [Integer] profile_id Profile ID
|
46
|
+
# @!macro request_options
|
47
|
+
def match(region_id, realm_id, profile_id, **options)
|
48
|
+
reg = resolve_region(region_id)
|
49
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
50
|
+
api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}/matches", opts
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Ladder
|
55
|
+
#
|
56
|
+
# @!macro sc2_regions
|
57
|
+
# @param [Integer] ladder_id Ladder ID
|
58
|
+
# @!macro request_options
|
59
|
+
def ladder(region_id, ladder_id, **options)
|
60
|
+
reg = resolve_region(region_id)
|
61
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
62
|
+
api_request "#{base_url(:community)}/legacy/ladder/#{reg}/#{ladder_id}", opts
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Achievement data
|
67
|
+
#
|
68
|
+
# @!macro sc2_regions
|
69
|
+
# @!macro request_options
|
70
|
+
def achievements(region_id, **options)
|
71
|
+
reg = resolve_region(region_id)
|
72
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
73
|
+
api_request "#{base_url(:community)}/legacy/data/achievements/#{reg}", opts
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Rewards data
|
78
|
+
#
|
79
|
+
# @!macro sc2_regions
|
80
|
+
# @!macro request_options
|
81
|
+
def rewards(region_id, **options)
|
82
|
+
reg = resolve_region(region_id)
|
83
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
84
|
+
api_request "#{base_url(:community)}/legacy/data/rewards/#{reg}", opts
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|