blizzard_api 0.4.0 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +21 -0
  3. data/.rubocop.yml +2 -1
  4. data/CHANGELOG.md +65 -0
  5. data/Gemfile.lock +19 -14
  6. data/README.md +6 -3
  7. data/blizzard_api.gemspec +6 -4
  8. data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +2 -2
  9. data/lib/blizzard_api/diablo/request.rb +2 -2
  10. data/lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb +2 -2
  11. data/lib/blizzard_api/hearthstone/request.rb +2 -2
  12. data/lib/blizzard_api/request.rb +45 -38
  13. data/lib/blizzard_api/starcraft.rb +7 -0
  14. data/lib/blizzard_api/starcraft/community/legacy.rb +88 -0
  15. data/lib/blizzard_api/starcraft/request.rb +2 -2
  16. data/lib/blizzard_api/version.rb +1 -1
  17. data/lib/blizzard_api/wow.rb +33 -0
  18. data/lib/blizzard_api/wow/game_data/azerite_essence.rb +2 -0
  19. data/lib/blizzard_api/wow/game_data/covenant.rb +79 -0
  20. data/lib/blizzard_api/wow/game_data/creature.rb +2 -0
  21. data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +2 -2
  22. data/lib/blizzard_api/wow/game_data/item.rb +2 -0
  23. data/lib/blizzard_api/wow/game_data/journal.rb +15 -0
  24. data/lib/blizzard_api/wow/game_data/media.rb +37 -0
  25. data/lib/blizzard_api/wow/game_data/modified_crafting.rb +67 -0
  26. data/lib/blizzard_api/wow/game_data/mount.rb +2 -0
  27. data/lib/blizzard_api/wow/game_data/pet.rb +46 -0
  28. data/lib/blizzard_api/wow/game_data/spell.rb +2 -0
  29. data/lib/blizzard_api/wow/game_data/tech_talent.rb +57 -0
  30. data/lib/blizzard_api/wow/profile/character_profile.rb +19 -1
  31. data/lib/blizzard_api/wow/profile/guild.rb +2 -0
  32. data/lib/blizzard_api/wow/profile/profile.rb +2 -2
  33. data/lib/blizzard_api/wow/request.rb +2 -2
  34. data/lib/blizzard_api/wow/search/search_composer.rb +3 -3
  35. data/lib/blizzard_api/wow/search/search_request.rb +1 -1
  36. data/lib/blizzard_api/wow/slug.rb +12 -0
  37. metadata +16 -8
  38. data/.gitlab-ci.yml +0 -12
@@ -10,6 +10,8 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.mount
12
12
  class Mount < Wow::GenericDataEndpoint
13
+ include BlizzardApi::Wow::Searchable
14
+
13
15
  protected
14
16
 
15
17
  def endpoint_setup
@@ -10,6 +10,52 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.pet
12
12
  class Pet < Wow::GenericDataEndpoint
13
+ ##
14
+ # Fetch media for one of the pets listed by the {#index} using its *id*
15
+ #
16
+ # @param id [Integer] Pet id
17
+ #
18
+ # @!macro request_options
19
+ #
20
+ # @!macro response
21
+ def media(id, options = {})
22
+ api_request "#{base_url(:media)}/pet/#{id}", default_options.merge(options)
23
+ end
24
+
25
+ ##
26
+ # Fetch all pet abilities
27
+ #
28
+ # @!macro request_options
29
+ #
30
+ # @!macro response
31
+ def abilities(options = {})
32
+ api_request "#{endpoint_uri('ability')}/index", default_options.merge(options)
33
+ end
34
+
35
+ ##
36
+ # Fetch a pet ability
37
+ #
38
+ # @param id [Integer] Pet id
39
+ #
40
+ # @!macro request_options
41
+ #
42
+ # @!macro response
43
+ def ability(id, options = {})
44
+ api_request "#{endpoint_uri('ability')}/#{id}", default_options.merge(options)
45
+ end
46
+
47
+ ##
48
+ # Fetch media for one of the pet abilities listed by the {#abilities} using its *id*
49
+ #
50
+ # @param id [Integer] Pet ability id
51
+ #
52
+ # @!macro request_options
53
+ #
54
+ # @!macro response
55
+ def ability_media(id, options = {})
56
+ api_request "#{base_url(:media)}/pet-ability/#{id}", default_options.merge(options)
57
+ end
58
+
13
59
  protected
14
60
 
15
61
  def endpoint_setup
@@ -10,6 +10,8 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.spell
12
12
  class Spell < Wow::GenericDataEndpoint
13
+ include BlizzardApi::Wow::Searchable
14
+
13
15
  ##
14
16
  # This method overrides the inherited default behavior to prevent high server load and fetch time
15
17
  #
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BlizzardApi
4
+ module Wow
5
+ ##
6
+ # This class allows access to World of Warcraft talent data
7
+ #
8
+ # @see https://develop.battle.net/documentation/world-of-warcraft/game-data-apis
9
+ #
10
+ # You can get an instance of this class using the default region as follows:
11
+ # api_instance = BlizzardApi::Wow.talent
12
+ class TechTalent < Wow::GenericDataEndpoint
13
+ ##
14
+ # Fetch tech talent trees
15
+ #
16
+ # @!macro request_options
17
+ #
18
+ # @!macro response
19
+ def tech_talent_trees(options = {})
20
+ api_request "#{base_url(:game_data)}/tech-talent-tree/index", default_options.merge(options)
21
+ end
22
+
23
+ ##
24
+ # Fetch a tech talent tree
25
+ #
26
+ # @param id [Integer] Tech talent id
27
+ #
28
+ # @!macro request_options
29
+ #
30
+ # @!macro response
31
+ def tech_talent_tree(id, options = {})
32
+ api_request "#{base_url(:game_data)}/tech-talent-tree/#{id}", default_options.merge(options)
33
+ end
34
+
35
+ ##
36
+ # Fetch a tech talent media
37
+ #
38
+ # @param id [Integer] Tech talent id
39
+ #
40
+ # @!macro request_options
41
+ #
42
+ # @!macro response
43
+ def media(id, options = {})
44
+ api_request "#{base_url(:media)}/tech-talent/#{id}", default_options.merge(options)
45
+ end
46
+
47
+ protected
48
+
49
+ def endpoint_setup
50
+ @endpoint = 'tech-talent'
51
+ @namespace = :static
52
+ @collection = 'tech-talents'
53
+ @ttl = CACHE_TRIMESTER
54
+ end
55
+ end
56
+ end
57
+ end
@@ -10,6 +10,8 @@ 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
+ include BlizzardApi::Wow::Slug
14
+
13
15
  ##
14
16
  # Return character achievements
15
17
  #
@@ -287,9 +289,11 @@ module BlizzardApi
287
289
  # @param realm [String] The character realm's slug
288
290
  # @param character [String] The character name
289
291
  # @!macro request_options
292
+ # @option options [Boolean] :completed Should return completed quests
290
293
  #
291
294
  # @!macro response
292
- def quests(realm, character, completed = false, options = {})
295
+ def quests(realm, character, options = {})
296
+ completed = options.delete(:completed) || false
293
297
  return character_request realm, character, options, 'quests/completed' if completed
294
298
 
295
299
  character_request realm, character, options, 'quests'
@@ -309,6 +313,20 @@ module BlizzardApi
309
313
  character_request realm, character, options, 'reputations'
310
314
  end
311
315
 
316
+ ##
317
+ # Return a character's soulbinds
318
+ #
319
+ # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-profile-api
320
+ #
321
+ # @param realm [String] The character realm's slug
322
+ # @param character [String] The character name
323
+ # @!macro request_options
324
+ #
325
+ # @!macro response
326
+ def soulbinds(realm, character, options = {})
327
+ character_request realm, character, options, 'soulbinds'
328
+ end
329
+
312
330
  ##
313
331
  # Return a character's specialization
314
332
  #
@@ -10,6 +10,8 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.guild
12
12
  class Guild < Wow::Request
13
+ include BlizzardApi::Wow::Slug
14
+
13
15
  ##
14
16
  # Return data about the specified guild
15
17
  #
@@ -7,8 +7,8 @@ module BlizzardApi
7
7
  class AccountProfile < Request
8
8
  ##
9
9
  # @param token [String] A token obtained using the authorization_code flow
10
- def initialize(token, region = nil)
11
- super region
10
+ def initialize(token, region = nil, mode = :regular)
11
+ super region, mode
12
12
  @token = token
13
13
  end
14
14
 
@@ -7,8 +7,8 @@ module BlizzardApi
7
7
  class Request < BlizzardApi::Request
8
8
  ##
9
9
  # @!macro regions
10
- def initialize(region = nil)
11
- super region
10
+ def initialize(region = nil, mode = :regular)
11
+ super region, mode
12
12
  @game = 'wow'
13
13
  end
14
14
  end
@@ -20,7 +20,7 @@ module BlizzardApi
20
20
  # The second argument takes a simple value, an array of values or a hash for range searches.
21
21
  #
22
22
  # @param field [String] Field name
23
- # @param value [String|Integer|Hash|Array<Integer|String>]
23
+ # @param value [String|Integer|Hash|Array<Integer>|Array<String>]
24
24
  # @option value [Integer] :min Range start
25
25
  # @option value [Integer] :max Range end
26
26
  # @option value [Integer] :mode Range mode (:inclusive|:exclusive)
@@ -37,7 +37,7 @@ module BlizzardApi
37
37
  # The second argument takes a simple value, an array of values or a hash for range searches.
38
38
  #
39
39
  # @param field [String] Field name
40
- # @param value [String|Integer|Hash|Array<Integer|String>]
40
+ # @param value [String|Integer|Hash|Array<Integer>|Array<String>]
41
41
  # @option value [Integer] :min Range start
42
42
  # @option value [Integer] :max Range end
43
43
  # @option value [Integer] :mode Range mode (:inclusive|:exclusive)
@@ -68,7 +68,7 @@ module BlizzardApi
68
68
  # @return {String}
69
69
  def to_search_query
70
70
  query_string = "_page=#{page}&_pageSize=#{page_size}"
71
- query_string += '&' + fields.join('&') unless fields.size.zero?
71
+ query_string += "&#{fields.join('&')}" unless fields.size.zero?
72
72
  query_string += "&orderby=#{order.join(',')}" unless order.size.zero?
73
73
  query_string
74
74
  end
@@ -6,7 +6,7 @@ module BlizzardApi
6
6
  # Added search support to an endpoint
7
7
  module Searchable
8
8
  ##
9
- # Fetch data base on search criteria
9
+ # Fetch data based on search criteria
10
10
  #
11
11
  # @param page [Integer] Page o return
12
12
  # @param page_size [Integer] Amount of items per page
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BlizzardApi
4
+ module Wow
5
+ # Support for slugs
6
+ module Slug
7
+ def string_to_slug(string)
8
+ CGI.escape(string.downcase.tr(' ', '-'))
9
+ end
10
+ end
11
+ end
12
+ 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.4.0
4
+ version: 0.5.3
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-06-08 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -102,13 +102,13 @@ dependencies:
102
102
  version: '0'
103
103
  description: This is a simple interface to obtain data from Blizzard API
104
104
  email:
105
- - francis.schiavo@francisschiavo.com
105
+ - francis@schiavo.dev
106
106
  executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - ".github/workflows/ruby.yml"
110
111
  - ".gitignore"
111
- - ".gitlab-ci.yml"
112
112
  - ".rubocop.yml"
113
113
  - ".rubocop_todo.yml"
114
114
  - CHANGELOG.md
@@ -146,6 +146,7 @@ files:
146
146
  - lib/blizzard_api/starcraft.rb
147
147
  - lib/blizzard_api/starcraft/community/account.rb
148
148
  - lib/blizzard_api/starcraft/community/ladder.rb
149
+ - lib/blizzard_api/starcraft/community/legacy.rb
149
150
  - lib/blizzard_api/starcraft/community/profile.rb
150
151
  - lib/blizzard_api/starcraft/game_data/league.rb
151
152
  - lib/blizzard_api/starcraft/request.rb
@@ -155,11 +156,14 @@ files:
155
156
  - lib/blizzard_api/wow/game_data/auction.rb
156
157
  - lib/blizzard_api/wow/game_data/azerite_essence.rb
157
158
  - lib/blizzard_api/wow/game_data/connected_realm.rb
159
+ - lib/blizzard_api/wow/game_data/covenant.rb
158
160
  - lib/blizzard_api/wow/game_data/creature.rb
159
161
  - lib/blizzard_api/wow/game_data/generic_data_endpoint.rb
160
162
  - lib/blizzard_api/wow/game_data/guild_crest.rb
161
163
  - lib/blizzard_api/wow/game_data/item.rb
162
164
  - lib/blizzard_api/wow/game_data/journal.rb
165
+ - lib/blizzard_api/wow/game_data/media.rb
166
+ - lib/blizzard_api/wow/game_data/modified_crafting.rb
163
167
  - lib/blizzard_api/wow/game_data/mount.rb
164
168
  - lib/blizzard_api/wow/game_data/mythic_keystone.rb
165
169
  - lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb
@@ -179,6 +183,7 @@ files:
179
183
  - lib/blizzard_api/wow/game_data/reputation.rb
180
184
  - lib/blizzard_api/wow/game_data/spell.rb
181
185
  - lib/blizzard_api/wow/game_data/talent.rb
186
+ - lib/blizzard_api/wow/game_data/tech_talent.rb
182
187
  - lib/blizzard_api/wow/game_data/title.rb
183
188
  - lib/blizzard_api/wow/game_data/wow_token.rb
184
189
  - lib/blizzard_api/wow/profile/character_profile.rb
@@ -187,13 +192,16 @@ files:
187
192
  - lib/blizzard_api/wow/request.rb
188
193
  - lib/blizzard_api/wow/search/search_composer.rb
189
194
  - lib/blizzard_api/wow/search/search_request.rb
190
- homepage: https://gitlab.com/francisschiavo/blizzard_api
195
+ - lib/blizzard_api/wow/slug.rb
196
+ homepage: https://github.com/francis-schiavo/blizzard_api
191
197
  licenses:
192
198
  - MIT
193
199
  metadata:
194
- homepage_uri: https://gitlab.com/francisschiavo/blizzard_api
195
- source_code_uri: https://gitlab.com/francisschiavo/blizzard_api
196
- changelog_uri: https://gitlab.com/francisschiavo/blizzard_api/blob/master/CHANGELOG.md
200
+ homepage_uri: https://github.com/francis-schiavo/blizzard_api
201
+ source_code_uri: https://github.com/francis-schiavo/blizzard_api
202
+ bug_tracker_uri: https://github.com/francis-schiavo/blizzard_api/issues
203
+ changelog_uri: https://github.com/francis-schiavo/blizzard_api/blob/master/CHANGELOG.md
204
+ documentation_uri: https://rubydoc.info/gems/blizzard_api
197
205
  post_install_message:
198
206
  rdoc_options: []
199
207
  require_paths:
@@ -1,12 +0,0 @@
1
- image: ruby:2.6
2
-
3
- stages:
4
- - test
5
-
6
- test:
7
- stage: test
8
- script:
9
- - gem install bundler -v 2.1.2
10
- - bundle install
11
- - rubocop
12
- - rake