blizzard_api 0.2.4 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 770ab293148fe2410f404e46ffb5108121b47dcf9262dfc4e07c4b139dca3fab
4
- data.tar.gz: c807938359f746c9a0d0ada0761726e268588f2a359b1c362c3acb24444dfa98
3
+ metadata.gz: ef547d30cdbb5599ad187f0b222b94921c9597c89dba9c95ee96ab98f2083267
4
+ data.tar.gz: a5a62685e422fcd58735c894286f69781b5bdd546e0b8fedb9c3ca05c783de2f
5
5
  SHA512:
6
- metadata.gz: 429845f34610b72326cdca9b77b8408d49bb0852297d0282d8ee71ef0a2f0c4dfe4ea6dbf1c3d5ca31e562a343edde968178888d64e29ea7c8ec2d522eb1d6e7
7
- data.tar.gz: d06edb2063dd4edd42b7f5ae18018355854884eb482ac94d3589f6abc3a04fa24d93e37f474d690daa225aa392c12baa5a36dc1ea9751c0afb2b2277b96d29a5
6
+ metadata.gz: 89bd6b397a46d2ad4f48b09f20bda65ac1b44d666d2e619fbfc11aa1f1eb18d79d000a56e76358b25ef521543ee532063697c696df74c9efc604855c787f9d12
7
+ data.tar.gz: 5d6bda03485f62b00e074aedc0d924d0c416e57f65bbf9b72c1dfeade0d4a7dc785bbbc2feb40c38f23ea7a794918de68d625cfa09a83fc10e8e904065622c91
@@ -1,7 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  Metrics/LineLength:
4
- Max: 120
4
+ Max: 140
5
5
 
6
6
  Metrics/ModuleLength:
7
7
  Exclude:
@@ -1,5 +1,10 @@
1
1
  Please view this file on the master branch, otherwise it may be outdated
2
2
 
3
+ **Version 0.2.5**
4
+ * Added two unreleased endpoints for character profile(`raid_progression` and `collections`).
5
+ * Added new WoW profile endpoints
6
+ * Added missing profile automated tests
7
+
3
8
  **Version 0.2.4**
4
9
  * Added new WoW profile endpoints: #2 https://us.battle.net/forums/en/bnet/topic/20772457051
5
10
  * Added support for HearthStone: !1 (Thanks Bradyn Glines for implementing this)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blizzard_api (0.2.3)
4
+ blizzard_api (0.2.5)
5
5
  redis (~> 4.1, >= 4.1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -88,8 +88,6 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
88
88
  - index
89
89
  - categories
90
90
  - category :id
91
- - character_achievement_index
92
- - guild_achievement_index
93
91
  - media :id
94
92
  * Blizzard::Wow::ConnectedRealm
95
93
  - index
@@ -168,6 +166,7 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
168
166
  - index
169
167
  - get :id
170
168
  - complete
169
+ - status :realms
171
170
  * Blizzard::Wow::Region
172
171
  - index
173
172
  - get :id
@@ -187,9 +186,11 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
187
186
  - classes
188
187
  - class :id
189
188
  - subclass :class_id, :subclass_id
189
+ - media :id
190
190
  * Blizzard::Wow::AzeriteEssence
191
191
  - index
192
192
  - get :id
193
+ - media :id
193
194
 
194
195
  * Blizzard::Wow::Auction
195
196
  - get :realm
@@ -199,10 +200,6 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
199
200
  * Blizzard::Wow::Challenge
200
201
  - realm_index
201
202
  - region_index
202
- * Blizzard::Wow::Character
203
- - get :realm, :character, :fields
204
- - get_keystone_profile :realm, :character, :user_token, :season
205
- - get_user_characters :user_token
206
203
  * Blizzard::Wow::Guild
207
204
  - get :relam, :name, :fields
208
205
  - rewards
@@ -219,11 +216,24 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
219
216
  - index
220
217
  - get :id
221
218
 
222
-
223
219
  * BlizzardApi::Wow::CharacterProfile
224
- - get_keystone_profile :realm, :character, :user_token, :season
220
+ - get_user_characters :user_token
221
+ - get :realm, :character, :fields
225
222
  - pvp_summmary :realm, :character, :user_token
226
223
  - pvp_bracket :realm, :character, :bracket, :user_token
224
+ - achievements :realm, :character
225
+ - appearance :realm, :character
226
+ - equipment :realm, :character
227
+ - media :realm, :character
228
+ - pvp_bracket :realm, :character, :bracket
229
+ - pvp_summary :realm, :character
230
+ - specializations :realm, :character
231
+ - statistics :realm, :character
232
+ - titles :realm, :character
233
+ - mythic_keystone_profile :realm, :character
234
+ - mythic_keystone_seasons :realm, :character
235
+ - collections :realm, :character (Not active yet on Blizzard servers)
236
+ - raid_progression :realm, :character (Not active yet on Blizzard servers)
227
237
 
228
238
  ### 4.2. Diablo III endpoints
229
239
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '0.2.4'
5
+ VERSION = '0.2.5'
6
6
  end
@@ -173,7 +173,6 @@ module BlizzardApi
173
173
  require_relative 'wow/community/auction'
174
174
  require_relative 'wow/community/boss'
175
175
  require_relative 'wow/community/challenge'
176
- require_relative 'wow/community/character'
177
176
  require_relative 'wow/community/pvp'
178
177
  require_relative 'wow/community/quest'
179
178
  require_relative 'wow/community/recipe'
@@ -54,30 +54,6 @@ module BlizzardApi
54
54
  api_request "#{endpoint_uri('category')}/#{id}", default_options.merge(options)
55
55
  end
56
56
 
57
- ##
58
- # Return a list of possible character achievements.
59
- # This endpoint uses a community endpoint. It is recommended to use the new data endpoint using {#index}.
60
- # @see https://us.battle.net/forums/en/bnet/topic/20771546990
61
- #
62
- # @!macro request_options
63
- #
64
- # @!macro response
65
- def character_achievement_index(options = {})
66
- api_request "#{base_url(:community)}/data/character/achievements", { ttl: CACHE_TRIMESTER }.merge(options)
67
- end
68
-
69
- ##
70
- # Return a list of possible guild achievements
71
- # This endpoint uses a community endpoint. It is recommended to use the new data endpoint using {#index}.
72
- # @see https://us.battle.net/forums/en/bnet/topic/20771546990
73
- #
74
- # @!macro request_options
75
- #
76
- # @!macro response
77
- def guild_achievement_index(options = {})
78
- api_request "#{base_url(:community)}/data/guild/achievements", { ttl: CACHE_TRIMESTER }.merge(options)
79
- end
80
-
81
57
  ##
82
58
  # Fetch media assets for the specified achievement
83
59
  #
@@ -10,6 +10,18 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.azerite_essence
12
12
  class AzeriteEssence < Wow::GenericDataEndpoint
13
+ ##
14
+ # Fetch media for one of the azerite essences listed by the {#index} using its *id*
15
+ #
16
+ # @param id [Integer] Azerite essence id
17
+ #
18
+ # @!macro request_options
19
+ #
20
+ # @!macro response
21
+ def media(id, options = {})
22
+ api_request "#{base_url(:media)}/azerite-essence/#{id}", default_options.merge(options)
23
+ end
24
+
13
25
  protected
14
26
 
15
27
  def endpoint_setup
@@ -12,7 +12,8 @@ module BlizzardApi
12
12
  # api_instance = BlizzardApi::Wow.guild
13
13
  class Guild < Wow::Request
14
14
  # Valid fields for guild profile request
15
- VALID_FIELDS = %w[achievements challenge members news].freeze
15
+ VALID_FIELDS = %w[achievements achievementsCompleted achievementsCompletedTimestamp criteria criteriaCreated
16
+ criteriaQuantity criteriaTimestamp challenge members news].freeze
16
17
 
17
18
  ##
18
19
  # Helper method for checking valid fields. Use this to validate an array of fields if you are not sure about their
@@ -84,11 +85,16 @@ module BlizzardApi
84
85
  #
85
86
  # @param realm [String] The guild realm's slug
86
87
  # @param guild [String] The guild's name
87
- #
88
88
  # @!macro request_options
89
+ # @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
90
+ # instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
89
91
  #
90
92
  # @!macro response
91
93
  def achievements(realm, guild, options = {})
94
+ if options.include? :use_community_endpoint
95
+ return api_request "#{base_url(:community)}/data/guild/achievements", { ttl: CACHE_TRIMESTER }.merge(options)
96
+ end
97
+
92
98
  guild_request realm, guild, options, 'achievements'
93
99
  end
94
100
 
@@ -91,6 +91,18 @@ module BlizzardApi
91
91
  api_request "#{endpoint_uri('class')}/#{id}/item-subclass/#{subclass_id}", default_options.merge(options)
92
92
  end
93
93
 
94
+ ##
95
+ # Fetch media for an item using its *id*
96
+ #
97
+ # @param id [Integer] Item id
98
+ #
99
+ # @!macro request_options
100
+ #
101
+ # @!macro response
102
+ def media(id, options = {})
103
+ api_request "#{base_url(:media)}/item/#{id}", default_options.merge(options)
104
+ end
105
+
94
106
  protected
95
107
 
96
108
  def endpoint_setup
@@ -25,7 +25,7 @@ module BlizzardApi
25
25
  #
26
26
  # @!macro response
27
27
  def dungeons(options = {})
28
- api_request "#{endpoint_uri}/period/index", default_options.merge(options)
28
+ api_request "#{endpoint_uri}/dungeon/index", default_options.merge(options)
29
29
  end
30
30
 
31
31
  ##
@@ -14,10 +14,12 @@ module BlizzardApi
14
14
  # This method is actually located at the community scope, but included here because of its relevance
15
15
  # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
16
16
  #
17
+ # @param realms [Array<String>] An optional list of realm-slugs to filter results
17
18
  # @!macro request_options
18
19
  #
19
20
  # @!macro response
20
- def status(options = {})
21
+ def status(realms = [], options = {})
22
+ options[:realms] = realms.map(&:string_to_slug).join(',') if realms.count.positive?
21
23
  api_request "#{base_url(:community)}/realm/status", { ttl: CACHE_MINUTE }.merge(options)
22
24
  end
23
25
 
@@ -10,6 +10,79 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.achievement
12
12
  class CharacterProfile < Wow::Request
13
+ # Valid fields for character profile requests
14
+ VALID_FIELDS = %w[
15
+ achievements
16
+ appearance
17
+ feed
18
+ guild
19
+ hunterPets
20
+ items
21
+ mounts
22
+ pets
23
+ petSlots
24
+ professions
25
+ progression
26
+ pvp
27
+ quests
28
+ reputation
29
+ statistics
30
+ stats
31
+ talents
32
+ titles
33
+ audit
34
+ ].freeze
35
+
36
+ ##
37
+ # Helper method for checking valid fields. Use this to validate an array of fields if you are not sure about their
38
+ # names.
39
+ #
40
+ # @param fields [Array<String>] Array containing desired fields to include
41
+ #
42
+ # @raise ArgumentError
43
+ def validate_fields(fields)
44
+ fields.each do |field|
45
+ raise ArgumentError, "Unrecognized field #{field}" unless VALID_FIELDS.include? field
46
+ end
47
+ end
48
+
49
+ ##
50
+ # Return a list containing all WoW characters of a BNet account
51
+ #
52
+ # @note This endpoint requires a user token obtained through the user authorization flow
53
+ # @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
54
+ #
55
+ # @param user_token [String] A token obtained by the authorization flow. See link below.
56
+ # @!macro request_options
57
+ #
58
+ # @!macro response
59
+ def get_user_characters(user_token, options = {})
60
+ opts = { ttl: CACHE_HOUR, access_token: user_token }.merge(options)
61
+ api_request "#{base_url(:community)}/user/characters", opts
62
+ end
63
+
64
+ ##
65
+ # Return character achievements
66
+ #
67
+ # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-profile-api
68
+ #
69
+ # @param realm [String] The character realm's slug
70
+ # @param character [String] The character name
71
+ # @param fields [Array<String>] An array containing all the fields you want to be included in the response. Only
72
+ # used for community endpoint.
73
+ # @!macro request_options
74
+ # @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
75
+ # instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
76
+ #
77
+ # @!macro response
78
+ def get(realm, character, fields = [], options = {})
79
+ return character_request realm, character, options unless options.include? :use_community_endpoint
80
+
81
+ validate_fields fields if options.include? :validate_fields
82
+ opts = { ttl: CACHE_DAY, fields: fields.join(',') }.merge(options)
83
+ api_request "#{base_url(:community)}/character/#{CGI.escape(realm)}/#{CGI.escape(character)}", opts
84
+ end
85
+
13
86
  ##
14
87
  # Return character achievements
15
88
  #
@@ -18,10 +91,14 @@ module BlizzardApi
18
91
  # @param realm [String] The character realm's slug
19
92
  # @param character [String] The character name
20
93
  # @!macro request_options
94
+ # @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
95
+ # instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
21
96
  #
22
97
  # @!macro response
23
98
  def achievements(realm, character, options = {})
24
- api_request "#{endpoint_uri(realm, character)}/achievements", default_options.merge(options)
99
+ return character_request realm, character, options, 'achievements' unless options.include? :use_community_endpoint
100
+
101
+ api_request "#{base_url(:community)}/data/guild/achievements", { ttl: CACHE_TRIMESTER }.merge(options)
25
102
  end
26
103
 
27
104
  ##
@@ -35,7 +112,7 @@ module BlizzardApi
35
112
  #
36
113
  # @!macro response
37
114
  def appearance(realm, character, options = {})
38
- api_request "#{endpoint_uri(realm, character)}/appearance", default_options.merge(options)
115
+ character_request realm, character, options, 'appearance'
39
116
  end
40
117
 
41
118
  ##
@@ -49,7 +126,7 @@ module BlizzardApi
49
126
  #
50
127
  # @!macro response
51
128
  def equipment(realm, character, options = {})
52
- api_request "#{endpoint_uri(realm, character)}/equipment", default_options.merge(options)
129
+ character_request realm, character, options, 'equipment'
53
130
  end
54
131
 
55
132
  ##
@@ -63,7 +140,7 @@ module BlizzardApi
63
140
  #
64
141
  # @!macro response
65
142
  def media(realm, character, options = {})
66
- api_request "#{endpoint_uri(realm, character)}/character-media", default_options.merge(options)
143
+ character_request realm, character, options, 'character-media'
67
144
  end
68
145
 
69
146
  ##
@@ -78,7 +155,7 @@ module BlizzardApi
78
155
  #
79
156
  # @!macro response
80
157
  def pvp_bracket(realm, character, bracket, options = {})
81
- api_request "#{endpoint_uri(realm, character)}/pvp-bracket/#{bracket}", default_options.merge(options)
158
+ character_request realm, character, options, "pvp-bracket/#{bracket}"
82
159
  end
83
160
 
84
161
  ##
@@ -92,7 +169,7 @@ module BlizzardApi
92
169
  #
93
170
  # @!macro response
94
171
  def pvp_summary(realm, character, options = {})
95
- api_request "#{endpoint_uri(realm, character)}/pvp-summary", default_options.merge(options)
172
+ character_request realm, character, options, 'pvp-summary'
96
173
  end
97
174
 
98
175
  ##
@@ -106,7 +183,7 @@ module BlizzardApi
106
183
  #
107
184
  # @!macro response
108
185
  def specializations(realm, character, options = {})
109
- api_request "#{endpoint_uri(realm, character)}/specializations", default_options.merge(options)
186
+ character_request realm, character, options, 'specializations'
110
187
  end
111
188
 
112
189
  ##
@@ -120,7 +197,7 @@ module BlizzardApi
120
197
  #
121
198
  # @!macro response
122
199
  def statistics(realm, character, options = {})
123
- api_request "#{endpoint_uri(realm, character)}/statistics", default_options.merge(options)
200
+ character_request realm, character, options, 'statistics'
124
201
  end
125
202
 
126
203
  ##
@@ -134,7 +211,7 @@ module BlizzardApi
134
211
  #
135
212
  # @!macro response
136
213
  def titles(realm, character, options = {})
137
- api_request "#{endpoint_uri(realm, character)}/titles", default_options.merge(options)
214
+ character_request realm, character, options, 'titles'
138
215
  end
139
216
 
140
217
  ##
@@ -147,8 +224,8 @@ module BlizzardApi
147
224
  # @!macro request_options
148
225
  #
149
226
  # @!macro response
150
- def keystone_profile(realm, character, options = {})
151
- api_request "#{endpoint_uri(realm, character)}/mythic-keystone-profile", default_options.merge(options)
227
+ def mythic_keystone_profile(realm, character, options = {})
228
+ character_request realm, character, options, 'mythic-keystone-profile'
152
229
  end
153
230
 
154
231
  ##
@@ -162,9 +239,36 @@ module BlizzardApi
162
239
  # @!macro request_options
163
240
  #
164
241
  # @!macro response
165
- def keystone_season_details(realm, character, season = nil, options = {})
166
- api_request api_request "#{endpoint_uri(realm, character)}/mythic-keystone-profile/season/#{season}",
167
- default_options.merge(options)
242
+ def mythic_keystone_seasons(realm, character, season = nil, options = {})
243
+ character_request realm, character, options, "mythic-keystone-profile/season/#{season}"
244
+ end
245
+
246
+ ##
247
+ # Return a character's collections
248
+ #
249
+ # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-profile-api
250
+ #
251
+ # @param realm [String] The character realm's slug
252
+ # @param character [String] The character name
253
+ # @!macro request_options
254
+ #
255
+ # @!macro response
256
+ def collections(realm, character, options = {})
257
+ character_request realm, character, options, 'collections'
258
+ end
259
+
260
+ ##
261
+ # Return a character's raid progression
262
+ #
263
+ # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-profile-api
264
+ #
265
+ # @param realm [String] The character realm's slug
266
+ # @param character [String] The character name
267
+ # @!macro request_options
268
+ #
269
+ # @!macro response
270
+ def raid_progression(realm, character, options = {})
271
+ character_request realm, character, options, 'raid-progression'
168
272
  end
169
273
 
170
274
  private
@@ -175,8 +279,10 @@ module BlizzardApi
175
279
  opts
176
280
  end
177
281
 
178
- def endpoint_uri(realm, character)
179
- "#{base_url(:profile)}/character/#{CGI.escape(realm)}/#{CGI.escape(character)}"
282
+ def character_request(realm, character, options = {}, variant = nil)
283
+ uri = "#{base_url(:profile)}/character/#{CGI.escape(realm.downcase)}/#{CGI.escape(character.downcase)}"
284
+ uri += "/#{variant}" if variant
285
+ api_request uri, default_options.merge(options)
180
286
  end
181
287
  end
182
288
  end
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Schiavo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-04 00:00:00.000000000 Z
11
+ date: 2019-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -154,7 +154,6 @@ files:
154
154
  - lib/blizzard_api/wow/community/auction.rb
155
155
  - lib/blizzard_api/wow/community/boss.rb
156
156
  - lib/blizzard_api/wow/community/challenge.rb
157
- - lib/blizzard_api/wow/community/character.rb
158
157
  - lib/blizzard_api/wow/community/pvp.rb
159
158
  - lib/blizzard_api/wow/community/quest.rb
160
159
  - lib/blizzard_api/wow/community/recipe.rb
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BlizzardApi
4
- module Wow
5
- ##
6
- # This class allows access to World of Warcraft character data
7
- #
8
- # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
9
- #
10
- # You can get an instance of this class using the default region as follows:
11
- # api_instance = BlizzardApi::Wow.character
12
- class Character < Wow::Request
13
- # Valid fields for character profile requests
14
- VALID_FIELDS = %w[
15
- achievements
16
- appearance
17
- feed
18
- guild
19
- hunterPets
20
- items
21
- mounts
22
- pets
23
- petSlots
24
- professions
25
- progression
26
- pvp
27
- quests
28
- reputation
29
- statistics
30
- stats
31
- talents
32
- titles
33
- audit
34
- ].freeze
35
-
36
- ##
37
- # Helper method for checking valid fields. Use this to validate an array of fields if you are not sure about their
38
- # names.
39
- #
40
- # @param fields [Array<String>] Array containing desired fields to include
41
- #
42
- # @raise ArgumentError
43
- def validate_fields(fields)
44
- fields.each do |field|
45
- raise ArgumentError, "Unrecognized field #{field}" unless VALID_FIELDS.include? field
46
- end
47
- end
48
-
49
- ##
50
- # Return data about the specified char
51
- #
52
- # @param realm [String] The character realm's slug
53
- # @param character [String] The character name
54
- # @param fields [Array<String>] An array containing all the fields you want to be included in the response.
55
- # @!macro request_options
56
- #
57
- # @!macro response
58
- def get(realm, character, fields = [], options = {})
59
- validate_fields fields if options.include? :validate_fields
60
-
61
- opts = { ttl: CACHE_DAY, fields: fields.join(',') }.merge(options)
62
-
63
- api_request "#{base_url(:community)}/character/#{CGI.escape(realm)}/#{CGI.escape(character)}", opts
64
- end
65
-
66
- ##
67
- # Return a list containing all WoW characters of a BNet account
68
- #
69
- # @note This endpoint requires a user token obtained through the user authorization flow
70
- # @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
71
- #
72
- # @param user_token [String] A token obtained by the authorization flow. See link below.
73
- # @!macro request_options
74
- #
75
- # @!macro response
76
- def get_user_characters(user_token, options = {})
77
- opts = { ttl: CACHE_HOUR, access_token: user_token }.merge(options)
78
- api_request "#{base_url(:community)}/user/characters", opts
79
- end
80
- end
81
- end
82
- end