blizzard_api 0.6.0 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7671ab9869534ec9c4c8031eac8e73ac9f389b9199cd9ca61a0e80127de66c53
4
- data.tar.gz: 915f7c1ff4b867b4b403dcb55128ab134b5012f380e90a8c589097ba57bf28a8
3
+ metadata.gz: f331c75e7b30062614bb12c18bfe208742debf32143048dfb51e322baa53fe83
4
+ data.tar.gz: 8653702786c36a232c7698feb4b8559681dd5418fe9ad5e390578977c2b3525c
5
5
  SHA512:
6
- metadata.gz: 50ce63d400f8997131913f6b677b3676bf68c5134d0acf5328276a37d861073f57004eb3c922821c261608a17610e25c956a1401633d99d25af68cb05c8729f8
7
- data.tar.gz: f57a645a37541c1ab06113439529822b84fe71808447303d04b25ba947e368754169e7cb6532482d584061c5a0708b1c7ecf0fe9392c896e236bc132f8c4885b
6
+ metadata.gz: ac6789833e98e6f0b1a940999ea59ac96bf1c9676bf58fff869c1a78fb98a5ffffb3e52254f4e261b73407606e6659bff3c904f31c436694d65d1e2bf873d45d
7
+ data.tar.gz: '088809759e0d6afe7ad9824098f54c1c4d4d66457ef187c3e24b0288bf3f6dfdfbb34e39cb0d5396db8f8360f69fdea55c64e988597115dc6920e98259fd414b'
data/.rubocop.yml CHANGED
@@ -11,7 +11,7 @@ Metrics/AbcSize:
11
11
  Max: 20
12
12
 
13
13
  AllCops:
14
- TargetRubyVersion: 2.5
14
+ TargetRubyVersion: 2.7
15
15
  NewCops: enable
16
16
  Exclude:
17
17
  - 'vendor/**/*'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  Please view this file on the master branch, otherwise it may be outdated
2
2
 
3
+ **Version 0.6.4**
4
+
5
+ Fixed argument propagation in SC2 legacy profile methods.
6
+
7
+ **Version 0.6.3**
8
+
9
+ Fixed argument propagation in some profile methods.
10
+
11
+ **Version 0.6.2**
12
+
13
+ Fixed an encoding problem on search endpoints.
14
+
15
+ **Version 0.6.1**
16
+
17
+ Added support for TBCC and Classice Era endpoints.
18
+
3
19
  **Version 0.6.0**
4
20
 
5
21
  Upgraded gem dependencies and refactored the code to support Ruby 3.0.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blizzard_api (0.6.0)
4
+ blizzard_api (0.6.3)
5
5
  redis (~> 4.1, >= 4.1.0)
6
6
  thwait (~> 0.2.0)
7
7
 
@@ -13,11 +13,11 @@ GEM
13
13
  e2mmap (0.1.0)
14
14
  minitest (5.14.4)
15
15
  parallel (1.20.1)
16
- parser (3.0.1.1)
16
+ parser (3.0.2.0)
17
17
  ast (~> 2.4.1)
18
18
  rainbow (3.0.0)
19
- rake (13.0.3)
20
- redis (4.2.5)
19
+ rake (13.0.6)
20
+ redis (4.3.1)
21
21
  regexp_parser (2.1.1)
22
22
  rexml (3.2.5)
23
23
  rubocop (0.93.1)
@@ -29,7 +29,7 @@ GEM
29
29
  rubocop-ast (>= 0.6.0)
30
30
  ruby-progressbar (~> 1.7)
31
31
  unicode-display_width (>= 1.4.0, < 2.0)
32
- rubocop-ast (1.5.0)
32
+ rubocop-ast (1.8.0)
33
33
  parser (>= 3.0.1.1)
34
34
  ruby-progressbar (1.11.0)
35
35
  thwait (0.2.0)
@@ -50,7 +50,7 @@ module BlizzardApi
50
50
  # How many threads to use for WoW game data `complete` payloads. Defaults to 4.
51
51
  # Should be set to the amount of available cores on the system.
52
52
  # @return [Integer] Concurrency
53
- attr_accessor :concurrency
53
+ attr_writer :concurrency
54
54
 
55
55
  ##
56
56
  # @!attribute access_token
@@ -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
@@ -9,7 +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. BEWARE: Might cause 429 responses, in this case lower the number.
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.
13
14
 
14
15
  ##
15
16
  # @!macro [new] regions
@@ -84,16 +85,31 @@ module BlizzardApi
84
85
  format BASE_URLS[scope], region, @game
85
86
  end
86
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
+
87
102
  ##
88
103
  # Returns a valid namespace string for consuming the api endpoints
89
104
  #
90
105
  # @param [Hash] options A hash containing the namespace key
91
106
  def endpoint_namespace(options)
107
+ version = endpoint_version(options)
92
108
  case options[:namespace]
93
109
  when :dynamic
94
- options.include?(:classic) ? "dynamic-classic-#{region}" : "dynamic-#{region}"
110
+ "dynamic-#{version}#{region}"
95
111
  when :static
96
- options.include?(:classic) ? "static-classic-#{region}" : "static-#{region}"
112
+ "static-#{version}#{region}"
97
113
  when :profile
98
114
  "profile-#{region}"
99
115
  else
@@ -137,7 +153,7 @@ module BlizzardApi
137
153
 
138
154
  def api_request(uri, **query_string)
139
155
  # List of request options
140
- 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]
141
157
 
142
158
  # Separates request options from api fields and options. Any user-defined option will be treated as api field.
143
159
  options = query_string.select { |k, _v| query_string.delete(k) || true if options_key.include? k }
@@ -41,7 +41,7 @@ module BlizzardApi
41
41
  def self.account(region = BlizzardApi.region)
42
42
  BlizzardApi::Starcraft::Account.new(region)
43
43
  end
44
-
44
+
45
45
  ##
46
46
  # @return {Legacy}
47
47
  def self.legacy(region = BlizzardApi.region)
@@ -16,7 +16,7 @@ module BlizzardApi
16
16
  # @param [Integer] account_id Account ID
17
17
  # @!macro request_options
18
18
  def player(account_id, **options)
19
- api_request "#{base_url(:community)}/player/#{account_id}", { ttl: CACHE_DAY }.merge(options)
19
+ api_request "#{base_url(:community)}/player/#{account_id}", **{ ttl: CACHE_DAY }.merge(options)
20
20
  end
21
21
  end
22
22
  end
@@ -10,7 +10,6 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Starcraft.legacy
12
12
  class Legacy < Starcraft::Request
13
-
14
13
  ##
15
14
  # Profile data
16
15
  #
@@ -21,7 +20,7 @@ module BlizzardApi
21
20
  def profile(region_id, realm_id, profile_id, **options)
22
21
  reg = resolve_region(region_id)
23
22
  opts = { ttl: CACHE_DAY }.merge(options)
24
- api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}", opts
23
+ api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}", **opts
25
24
  end
26
25
 
27
26
  ##
@@ -34,7 +33,7 @@ module BlizzardApi
34
33
  def ladders(region_id, realm_id, profile_id, **options)
35
34
  reg = resolve_region(region_id)
36
35
  opts = { ttl: CACHE_DAY }.merge(options)
37
- api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}/ladder ", opts
36
+ api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}/ladder ", **opts
38
37
  end
39
38
 
40
39
  ##
@@ -47,9 +46,9 @@ module BlizzardApi
47
46
  def match(region_id, realm_id, profile_id, **options)
48
47
  reg = resolve_region(region_id)
49
48
  opts = { ttl: CACHE_DAY }.merge(options)
50
- api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}/matches", opts
49
+ api_request "#{base_url(:community)}/legacy/profile/#{reg}/#{realm_id}/#{profile_id}/matches", **opts
51
50
  end
52
-
51
+
53
52
  ##
54
53
  # Ladder
55
54
  #
@@ -59,9 +58,9 @@ module BlizzardApi
59
58
  def ladder(region_id, ladder_id, **options)
60
59
  reg = resolve_region(region_id)
61
60
  opts = { ttl: CACHE_DAY }.merge(options)
62
- api_request "#{base_url(:community)}/legacy/ladder/#{reg}/#{ladder_id}", opts
61
+ api_request "#{base_url(:community)}/legacy/ladder/#{reg}/#{ladder_id}", **opts
63
62
  end
64
-
63
+
65
64
  ##
66
65
  # Achievement data
67
66
  #
@@ -70,9 +69,9 @@ module BlizzardApi
70
69
  def achievements(region_id, **options)
71
70
  reg = resolve_region(region_id)
72
71
  opts = { ttl: CACHE_DAY }.merge(options)
73
- api_request "#{base_url(:community)}/legacy/data/achievements/#{reg}", opts
72
+ api_request "#{base_url(:community)}/legacy/data/achievements/#{reg}", **opts
74
73
  end
75
-
74
+
76
75
  ##
77
76
  # Rewards data
78
77
  #
@@ -81,7 +80,7 @@ module BlizzardApi
81
80
  def rewards(region_id, **options)
82
81
  reg = resolve_region(region_id)
83
82
  opts = { ttl: CACHE_DAY }.merge(options)
84
- api_request "#{base_url(:community)}/legacy/data/rewards/#{reg}", opts
83
+ api_request "#{base_url(:community)}/legacy/data/rewards/#{reg}", **opts
85
84
  end
86
85
  end
87
86
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '0.6.0'
5
+ VERSION = '0.6.4'
6
6
  end
@@ -10,15 +10,33 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.auction
12
12
  class Auction < Wow::Request
13
+ ##
14
+ # Return all auction houses for the specified connected realm. Classic only.
15
+ #
16
+ # @param connected_realm_id [Integer] A valid connected realm id
17
+ # @!macro request_options
18
+ #
19
+ # @!macro response
20
+ def index(connected_realm_id, **options)
21
+ opts = { ttl: CACHE_HOUR, namespace: :dynamic }.merge(options)
22
+ api_request "#{base_url(:game_data)}/connected-realm/#{connected_realm_id}/auctions/index", **opts
23
+ end
24
+
13
25
  ##
14
26
  # Return all active auctions for the specified connected realm
15
27
  #
16
28
  # @param connected_realm_id [Integer] A valid connected realm id
17
29
  # @!macro request_options
30
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
18
31
  #
19
32
  # @!macro response
20
- def get(connected_realm_id, **options)
33
+ def get(connected_realm_id, auction_house_id = nil, **options)
21
34
  opts = { ttl: CACHE_HOUR, namespace: :dynamic }.merge(options)
35
+
36
+ unless auction_house_id.nil?
37
+ return api_request "#{base_url(:game_data)}/connected-realm/#{connected_realm_id}/auctions/#{auction_house_id}", **opts
38
+ end
39
+
22
40
  api_request "#{base_url(:game_data)}/connected-realm/#{connected_realm_id}/auctions", **opts
23
41
  end
24
42
  end
@@ -13,7 +13,7 @@ module BlizzardApi
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
15
  def index
16
- raise BlizzardApi::ApiException, 'Creatures endpoint doesn\'t have a index method'
16
+ raise BlizzardApi::ApiException, 'Creatures endpoint doesn\'t have an index method'
17
17
  end
18
18
 
19
19
  def complete
@@ -25,6 +25,7 @@ module BlizzardApi
25
25
  #
26
26
  # @!macro request_options
27
27
  # @option options [Boolean] :classic If set to true, this method will call the classic version
28
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
28
29
  #
29
30
  # @!macro response
30
31
  def families(**options)
@@ -38,6 +39,7 @@ module BlizzardApi
38
39
  #
39
40
  # @!macro request_options
40
41
  # @option options [Boolean] :classic If set to true, this method will call the classic version
42
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
41
43
  #
42
44
  # @!macro response
43
45
  def family(id, **options)
@@ -51,6 +53,7 @@ module BlizzardApi
51
53
  #
52
54
  # @!macro request_options
53
55
  # @option options [Boolean] :classic If set to true, this method will call the classic version
56
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
54
57
  #
55
58
  # @!macro response
56
59
  def family_media(id, **options)
@@ -62,6 +65,7 @@ module BlizzardApi
62
65
  #
63
66
  # @!macro request_options
64
67
  # @option options [Boolean] :classic If set to true, this method will call the classic version
68
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
65
69
  #
66
70
  # @!macro response
67
71
  def types(**options)
@@ -75,6 +79,7 @@ module BlizzardApi
75
79
  #
76
80
  # @!macro request_options
77
81
  # @option options [Boolean] :classic If set to true, this method will call the classic version
82
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
78
83
  #
79
84
  # @!macro response
80
85
  def type(id, **options)
@@ -88,6 +93,7 @@ module BlizzardApi
88
93
  #
89
94
  # @!macro request_options
90
95
  # @option options [Boolean] :classic If set to true, this method will call the classic version
96
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
91
97
  #
92
98
  # @!macro response
93
99
  def display_media(id, **options)
@@ -21,6 +21,7 @@ module BlizzardApi
21
21
  #
22
22
  # @!macro request_options
23
23
  # @option options [Boolean] :classic If set to true, this method will call the classic version
24
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
24
25
  #
25
26
  # @!macro response
26
27
  def border_media(id, **options)
@@ -32,6 +33,7 @@ module BlizzardApi
32
33
  #
33
34
  # @param id [Integer] Emblem id
34
35
  # @option options [Boolean] :classic If set to true, this method will call the classic version
36
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
35
37
  #
36
38
  # @!macro request_options
37
39
  #
@@ -33,6 +33,7 @@ module BlizzardApi
33
33
  #
34
34
  # @!macro request_options
35
35
  # @option options [Boolean] :classic If set to true, this method will call the classic version
36
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
36
37
  #
37
38
  # @!macro response
38
39
  def classes(**options)
@@ -45,6 +46,7 @@ module BlizzardApi
45
46
  # @param id [Integer] Item class id
46
47
  # @!macro request_options
47
48
  # @option options [Boolean] :classic If set to true, this method will call the classic version
49
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
48
50
  #
49
51
  # @!macro response
50
52
  def class(id, **options)
@@ -58,6 +60,7 @@ module BlizzardApi
58
60
  # @param subclass_id [Integer] Item subclass id
59
61
  # @!macro request_options
60
62
  # @option options [Boolean] :classic If set to true, this method will call the classic version
63
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
61
64
  #
62
65
  # @!macro response
63
66
  def subclass(id, subclass_id, **options)
@@ -71,6 +74,7 @@ module BlizzardApi
71
74
  #
72
75
  # @!macro request_options
73
76
  # @option options [Boolean] :classic If set to true, this method will call the classic version
77
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
74
78
  #
75
79
  # @!macro response
76
80
  def media(id, **options)
@@ -30,7 +30,7 @@ module BlizzardApi
30
30
  # This method overrides the inherited default behavior to prevent high server load and fetch time
31
31
  #
32
32
  # @!macro response
33
- def get(_id, **options)
33
+ def get(_id)
34
34
  raise BlizzardApi::ApiException, 'This endpoint does not have a get method'
35
35
  end
36
36
 
@@ -25,6 +25,7 @@ module BlizzardApi
25
25
  # @!macro complete
26
26
  #
27
27
  # @option options [Boolean] :classic If set to true, this method will call the classic version
28
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
28
29
  def complete(**options)
29
30
  index_data = index(**options)
30
31
  [].tap do |classes|
@@ -43,6 +44,7 @@ module BlizzardApi
43
44
  #
44
45
  # @!macro request_options
45
46
  # @option options [Boolean] :classic If set to true, this method will call the classic version
47
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
46
48
  #
47
49
  # @!macro response
48
50
  def get(id, **options)
@@ -14,6 +14,7 @@ module BlizzardApi
14
14
  # Returns a index of pvp leaderboard for a season
15
15
  #
16
16
  # @!macro request_options
17
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
17
18
  #
18
19
  # @!macro response
19
20
  def leaderboards(season_id, **options)
@@ -24,6 +25,7 @@ module BlizzardApi
24
25
  # Returns the leaderboard for a given season and bracket
25
26
  #
26
27
  # @!macro request_options
28
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
27
29
  #
28
30
  # @!macro response
29
31
  def leaderboard(season_id, brackets, **options)
@@ -68,7 +68,7 @@ module BlizzardApi
68
68
  { ttl: CACHE_HOUR, namespace: :profile }
69
69
  end
70
70
 
71
- def api_request(_uri, query_string = {})
71
+ def api_request(_uri, **query_string)
72
72
  query_string.merge! access_token: @token
73
73
  super
74
74
  end
@@ -27,7 +27,7 @@ module BlizzardApi
27
27
  #
28
28
  # @return {SearchComposer}
29
29
  def where(field, value)
30
- fields.push "#{field}=#{resolve_value(value)}"
30
+ fields.push "#{field}=#{URI.encode_www_form_component(resolve_value(value))}"
31
31
  self
32
32
  end
33
33
 
@@ -44,7 +44,7 @@ module BlizzardApi
44
44
  #
45
45
  # @return {SearchComposer}
46
46
  def where_not(field, value)
47
- fields.push "#{field}!=#{resolve_value(value)}"
47
+ fields.push "#{field}!=#{URI.encode_www_form_component(resolve_value(value))}"
48
48
  self
49
49
  end
50
50
 
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.6.0
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Schiavo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-11 00:00:00.000000000 Z
11
+ date: 2021-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis