blizzard_api 0.3.5 → 0.3.6
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/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +19 -0
- data/lib/blizzard_api.rb +1 -0
- data/lib/blizzard_api/diablo.rb +9 -9
- data/lib/blizzard_api/diablo/community/profile.rb +10 -4
- data/lib/blizzard_api/starcraft.rb +40 -0
- data/lib/blizzard_api/starcraft/community/account.rb +23 -0
- data/lib/blizzard_api/starcraft/community/ladder.rb +34 -0
- data/lib/blizzard_api/starcraft/community/profile.rb +76 -0
- data/lib/blizzard_api/starcraft/game_data/league.rb +27 -0
- data/lib/blizzard_api/starcraft/request.rb +36 -0
- data/lib/blizzard_api/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98dfa44fc3124d09b6f7d748b9177f4fa4db78b75824f9c5643b3b4ec9ebd6b9
|
4
|
+
data.tar.gz: 04fc32625fc155c3b2d187ea0db9d79427d902b67783b79684efc2023a29462c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d601c0591eb90072a937cc860e2fb5e8e42c0fc72d795207188156a7df40f17187e40604d4acc3f187c75d4ae82ce55bfd2cf1212f3311e2205500a8da01ff6
|
7
|
+
data.tar.gz: 768023a73f05b338e6c03c57ba918ede8b3aa16a7f2aefa5ec61e3c4f1025e4f42c2242fdddf08a4e0559f46e86cfe25dde955ccb3c3611b62712e031ad83e2f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
Please view this file on the master branch, otherwise it may be outdated
|
2
2
|
|
3
|
+
**Version 0.3.6**
|
4
|
+
|
5
|
+
Fix Diablo shortcuts.
|
6
|
+
Adding SC2 endpoints back.
|
7
|
+
|
8
|
+
https://us.forums.blizzard.com/en/blizzard/t/starcraft-ii-community-api-update/2652/5
|
9
|
+
|
3
10
|
**Version 0.3.5**
|
4
11
|
|
5
12
|
Fixed a bug for generating slugs for Korean
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,7 @@ This gem allow you to interface with the new blizzard api (2018) using the OAuth
|
|
16
16
|
- 4.1. [World of Warcraft endpoints](#41-world-of-warcraft-endpoints)
|
17
17
|
- 4.2. [Diablo III endpoints](#42-diablo-iii-endpoints)
|
18
18
|
- 4.3. [Hearthstone endpoints](#43-hearthstone-endpoints)
|
19
|
+
- 4.4. [Starcraft II endpoints](#43-starcraft-ii-endpoints)
|
19
20
|
|
20
21
|
## 1. Installation
|
21
22
|
|
@@ -284,6 +285,24 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
|
|
284
285
|
* BlizzardApi::Hearthstone::Metadata
|
285
286
|
- index
|
286
287
|
- get :type
|
288
|
+
|
289
|
+
### 4.4. Starcraft II endpoints
|
290
|
+
|
291
|
+
Every endpoint requiring a *region_id* parameter will accepts either the integer representation of the region described in the api docs or a symbol: `:US`, `:EU`, `:KO` or `:TW`
|
292
|
+
|
293
|
+
* BlizzardApi::Starcraft::League
|
294
|
+
- get :season_id, :queue_id, :team_type, :league_id
|
295
|
+
* BlizzardApi::Starcraft::Profile
|
296
|
+
- static :region_id
|
297
|
+
- metadata :region_id, :realm_id, :profile_id
|
298
|
+
- profile :region_id, :realm_id, :profile_id
|
299
|
+
- ladder_summary :region_id, :realm_id, :profile_id
|
300
|
+
- ladder :region_id, :realm_id, :profile_id, :ladder_id
|
301
|
+
* BlizzardApi::Starcraft::Ladder
|
302
|
+
- grandmaster :region_id, :options
|
303
|
+
- season :region_id
|
304
|
+
* BlizzardApi::Starcraft::Account
|
305
|
+
- player :account_id
|
287
306
|
|
288
307
|
## Contributing
|
289
308
|
|
data/lib/blizzard_api.rb
CHANGED
data/lib/blizzard_api/diablo.rb
CHANGED
@@ -12,13 +12,13 @@ module BlizzardApi
|
|
12
12
|
|
13
13
|
##
|
14
14
|
# @return {Season}
|
15
|
-
def season
|
15
|
+
def self.season
|
16
16
|
BlizzardApi::Diablo::Season.new
|
17
17
|
end
|
18
18
|
|
19
19
|
##
|
20
20
|
# @return {Era}
|
21
|
-
def era
|
21
|
+
def self.era
|
22
22
|
BlizzardApi::Diablo::Era.new
|
23
23
|
end
|
24
24
|
|
@@ -33,43 +33,43 @@ module BlizzardApi
|
|
33
33
|
|
34
34
|
##
|
35
35
|
# @return {Act}
|
36
|
-
def act
|
36
|
+
def self.act
|
37
37
|
BlizzardApi::Diablo::Act.new
|
38
38
|
end
|
39
39
|
|
40
40
|
##
|
41
41
|
# @return {Artisan}
|
42
|
-
def artisan
|
42
|
+
def self.artisan
|
43
43
|
BlizzardApi::Diablo::Artisan.new
|
44
44
|
end
|
45
45
|
|
46
46
|
##
|
47
47
|
# @return {Follower}
|
48
|
-
def follower
|
48
|
+
def self.follower
|
49
49
|
BlizzardApi::Diablo::Follower.new
|
50
50
|
end
|
51
51
|
|
52
52
|
##
|
53
53
|
# @return {Character}
|
54
|
-
def character
|
54
|
+
def self.character
|
55
55
|
BlizzardApi::Diablo::Character.new
|
56
56
|
end
|
57
57
|
|
58
58
|
##
|
59
59
|
# @return {ItemType}
|
60
|
-
def item_type
|
60
|
+
def self.item_type
|
61
61
|
BlizzardApi::Diablo::ItemType.new
|
62
62
|
end
|
63
63
|
|
64
64
|
##
|
65
65
|
# @return {Type}
|
66
|
-
def item
|
66
|
+
def self.item
|
67
67
|
BlizzardApi::Diablo::Item.new
|
68
68
|
end
|
69
69
|
|
70
70
|
##
|
71
71
|
# @return {Profile}
|
72
|
-
def profile
|
72
|
+
def self.profile
|
73
73
|
BlizzardApi::Diablo::Profile.new
|
74
74
|
end
|
75
75
|
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)}/data/profile/#{battletag}", opts
|
25
|
+
api_request "#{base_url(:community)}/data/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)}/data/profile/#{battletag}/hero/#{hero_id}", opts
|
41
|
+
api_request "#{base_url(:community)}/data/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)}/data/profile/#{battletag}/hero/#{hero_id}/items", opts
|
57
|
+
api_request "#{base_url(:community)}/data/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/items", opts
|
58
58
|
end
|
59
59
|
|
60
60
|
##
|
@@ -70,7 +70,13 @@ 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)}/data/profile/#{battletag}/hero/#{hero_id}/follower-items", opts
|
73
|
+
api_request "#{base_url(:community)}/data/profile/#{parse_battle_tag(battletag)}/hero/#{hero_id}/follower-items", opts
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def parse_battle_tag(battletag)
|
79
|
+
battletag.sub('#', '-')
|
74
80
|
end
|
75
81
|
end
|
76
82
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
# Starcraft II related classes
|
5
|
+
module Starcraft
|
6
|
+
require_relative 'starcraft/request'
|
7
|
+
|
8
|
+
# Starcraft II data api
|
9
|
+
require_relative 'starcraft/game_data/league'
|
10
|
+
|
11
|
+
##
|
12
|
+
# @return {League}
|
13
|
+
def self.league
|
14
|
+
BlizzardApi::Starcraft::League.new
|
15
|
+
end
|
16
|
+
|
17
|
+
# Starcraft community api
|
18
|
+
require_relative 'starcraft/community/profile'
|
19
|
+
require_relative 'starcraft/community/ladder'
|
20
|
+
require_relative 'starcraft/community/account'
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return {Profile}
|
24
|
+
def self.profile
|
25
|
+
BlizzardApi::Starcraft::Profile.new
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# @return {Ladder}
|
30
|
+
def self.ladder
|
31
|
+
BlizzardApi::Starcraft::Ladder.new
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# @return {Account}
|
36
|
+
def self.account
|
37
|
+
BlizzardApi::Starcraft::Account.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Starcraft
|
5
|
+
##
|
6
|
+
# This class allows access to Starcraft II league 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.account
|
12
|
+
class Account < Starcraft::Request
|
13
|
+
##
|
14
|
+
# Returns information about a player account
|
15
|
+
#
|
16
|
+
# @param [Integer] account_id Account ID
|
17
|
+
# @!macro request_options
|
18
|
+
def player(account_id, options = {})
|
19
|
+
api_request "#{base_url(:community)}/player/#{account_id}", { ttl: CACHE_DAY }.merge(options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Starcraft
|
5
|
+
##
|
6
|
+
# This class allows access to Starcraft II ladder 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.ladder
|
12
|
+
class Ladder < Starcraft::Request
|
13
|
+
##
|
14
|
+
# Grandmaster endpoint
|
15
|
+
#
|
16
|
+
# @!macro sc2_regions
|
17
|
+
# @!macro request_options
|
18
|
+
def grandmaster(region_id, options = {})
|
19
|
+
reg = resolve_region(region_id)
|
20
|
+
api_request "#{base_url(:community)}/ladder/grandmaster/#{reg}", { ttl: CACHE_DAY }.merge(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Season endpoint
|
25
|
+
#
|
26
|
+
# @!macro sc2_regions
|
27
|
+
# @!macro request_options
|
28
|
+
def season(region_id, options = {})
|
29
|
+
reg = resolve_region(region_id)
|
30
|
+
api_request "#{base_url(:community)}/ladder/season/#{reg}", { ttl: CACHE_DAY }.merge(options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Starcraft
|
5
|
+
##
|
6
|
+
# This class allows access to Starcraft II profile 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.profile
|
12
|
+
class Profile < Starcraft::Request
|
13
|
+
##
|
14
|
+
# Static profile data
|
15
|
+
#
|
16
|
+
# @!macro sc2_regions
|
17
|
+
# @!macro request_options
|
18
|
+
def static(region_id, options = {})
|
19
|
+
reg = resolve_region(region_id)
|
20
|
+
api_request "#{base_url(:community)}/static/profile/#{reg}", { ttl: CACHE_DAY }.merge(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Metadata
|
25
|
+
#
|
26
|
+
# @!macro sc2_regions
|
27
|
+
# @param [Integer] realm_id Realm ID
|
28
|
+
# @param [Integer] profile_id Profile ID
|
29
|
+
# @!macro request_options
|
30
|
+
def metadata(region_id, realm_id, profile_id, options = {})
|
31
|
+
reg = resolve_region(region_id)
|
32
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
33
|
+
api_request "#{base_url(:community)}/metadata/profile/#{reg}/#{realm_id}/#{profile_id}", opts
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Profile data
|
38
|
+
#
|
39
|
+
# @!macro sc2_regions
|
40
|
+
# @param [Integer] realm_id Realm ID
|
41
|
+
# @param [Integer] profile_id Profile ID
|
42
|
+
# @!macro request_options
|
43
|
+
def profile(region_id, realm_id, profile_id, options = {})
|
44
|
+
reg = resolve_region(region_id)
|
45
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
46
|
+
api_request "#{base_url(:community)}/profile/#{reg}/#{realm_id}/#{profile_id}", opts
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Ladder summary
|
51
|
+
#
|
52
|
+
# @!macro sc2_regions
|
53
|
+
# @param [Integer] realm_id Realm ID
|
54
|
+
# @param [Integer] profile_id Profile ID
|
55
|
+
# @!macro request_options
|
56
|
+
def ladder_summary(region_id, realm_id, profile_id, options = {})
|
57
|
+
reg = resolve_region(region_id)
|
58
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
59
|
+
api_request "#{base_url(:community)}profile/#{reg}/#{realm_id}/#{profile_id}/ladder/summary ", opts
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Ladder data
|
64
|
+
#
|
65
|
+
# @!macro sc2_regions
|
66
|
+
# @param [Integer] realm_id Realm ID
|
67
|
+
# @param [Integer] profile_id Profile ID
|
68
|
+
# @!macro request_options
|
69
|
+
def ladder(region_id, realm_id, profile_id, ladder_id, options = {})
|
70
|
+
reg = resolve_region(region_id)
|
71
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
72
|
+
api_request "#{base_url(:community)}/profile/#{reg}/#{realm_id}/#{profile_id}/ladder/#{ladder_id}", opts
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Starcraft
|
5
|
+
##
|
6
|
+
# This class allows access to Starcraft II league 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.league
|
12
|
+
class League < Starcraft::Request
|
13
|
+
##
|
14
|
+
# Return information about league
|
15
|
+
#
|
16
|
+
# @param [Integer] season_id Season id
|
17
|
+
# @param [Integer] queue_id Queue id
|
18
|
+
# @param [Integer] team_type Team type
|
19
|
+
# @param [Integer] league_id League id
|
20
|
+
# @!macro request_options
|
21
|
+
def get(season_id, queue_id, team_type, league_id, options = {})
|
22
|
+
opts = { ttl: CACHE_DAY }.merge(options)
|
23
|
+
api_request "#{base_url(:game_data)}/league/#{season_id}/#{queue_id}/#{team_type}/#{league_id}", opts
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# @!macro [new] sc2_regions
|
5
|
+
# @param {Symbol} region_id One of the valid Starcraft II regions *:US*, *:EU*, *:KO*, and *:TW*
|
6
|
+
# @note This gem do not support nor will support China endpoints
|
7
|
+
|
8
|
+
module BlizzardApi
|
9
|
+
module Starcraft
|
10
|
+
##
|
11
|
+
# Starcraft requests
|
12
|
+
class Request < BlizzardApi::Request
|
13
|
+
# Possible regions for the SC II API (Except China)
|
14
|
+
SC_REGION = { US: 1, EU: 2, KO: 3, TW: 3 }.freeze
|
15
|
+
|
16
|
+
##
|
17
|
+
# @!macro regions
|
18
|
+
def initialize(region = nil)
|
19
|
+
super region
|
20
|
+
@game = 'sc2'
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
##
|
26
|
+
# Helper method to find a region_id by its symbol
|
27
|
+
def resolve_region(region_arg)
|
28
|
+
return region_arg if region_arg.is_a? Integer
|
29
|
+
|
30
|
+
return SC_REGION[region_arg] if region_arg.is_a? Symbol
|
31
|
+
|
32
|
+
raise ArgumentError, 'Invalid region, please read the documentation'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/blizzard_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blizzard_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Schiavo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -115,6 +115,12 @@ files:
|
|
115
115
|
- lib/blizzard_api/hearthstone/game_data/metadata.rb
|
116
116
|
- lib/blizzard_api/hearthstone/request.rb
|
117
117
|
- lib/blizzard_api/request.rb
|
118
|
+
- lib/blizzard_api/starcraft.rb
|
119
|
+
- lib/blizzard_api/starcraft/community/account.rb
|
120
|
+
- lib/blizzard_api/starcraft/community/ladder.rb
|
121
|
+
- lib/blizzard_api/starcraft/community/profile.rb
|
122
|
+
- lib/blizzard_api/starcraft/game_data/league.rb
|
123
|
+
- lib/blizzard_api/starcraft/request.rb
|
118
124
|
- lib/blizzard_api/version.rb
|
119
125
|
- lib/blizzard_api/wow.rb
|
120
126
|
- lib/blizzard_api/wow/game_data/achievement.rb
|