blizzard_api 0.6.4 → 1.0.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile.lock +11 -13
  4. data/blizzard_api.gemspec +0 -1
  5. data/lib/blizzard_api/api_standards.rb +55 -0
  6. data/lib/blizzard_api/configuration.rb +20 -17
  7. data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +2 -2
  8. data/lib/blizzard_api/diablo/request.rb +3 -3
  9. data/lib/blizzard_api/diablo.rb +33 -27
  10. data/lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb +2 -2
  11. data/lib/blizzard_api/hearthstone/request.rb +3 -3
  12. data/lib/blizzard_api/hearthstone.rb +18 -12
  13. data/lib/blizzard_api/request.rb +27 -76
  14. data/lib/blizzard_api/starcraft/request.rb +3 -3
  15. data/lib/blizzard_api/starcraft.rb +20 -14
  16. data/lib/blizzard_api/token_manager.rb +49 -0
  17. data/lib/blizzard_api/version.rb +1 -1
  18. data/lib/blizzard_api/wow/game_data/achievement.rb +1 -16
  19. data/lib/blizzard_api/wow/game_data/azerite_essence.rb +2 -9
  20. data/lib/blizzard_api/wow/game_data/connected_realm.rb +1 -8
  21. data/lib/blizzard_api/wow/game_data/covenant.rb +2 -9
  22. data/lib/blizzard_api/wow/game_data/creature.rb +2 -13
  23. data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +10 -37
  24. data/lib/blizzard_api/wow/game_data/guild_crest.rb +4 -10
  25. data/lib/blizzard_api/wow/game_data/item.rb +3 -18
  26. data/lib/blizzard_api/wow/game_data/journal.rb +2 -17
  27. data/lib/blizzard_api/wow/game_data/media.rb +2 -13
  28. data/lib/blizzard_api/wow/game_data/modified_crafting.rb +1 -12
  29. data/lib/blizzard_api/wow/game_data/mount.rb +1 -8
  30. data/lib/blizzard_api/wow/game_data/mythic_keystone.rb +2 -13
  31. data/lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb +2 -9
  32. data/lib/blizzard_api/wow/game_data/pet.rb +2 -9
  33. data/lib/blizzard_api/wow/game_data/playable_class.rb +2 -23
  34. data/lib/blizzard_api/wow/game_data/playable_race.rb +1 -8
  35. data/lib/blizzard_api/wow/game_data/playable_specialization.rb +1 -18
  36. data/lib/blizzard_api/wow/game_data/power_type.rb +1 -8
  37. data/lib/blizzard_api/wow/game_data/profession.rb +2 -9
  38. data/lib/blizzard_api/wow/game_data/pvp_region.rb +82 -0
  39. data/lib/blizzard_api/wow/game_data/pvp_season.rb +7 -9
  40. data/lib/blizzard_api/wow/game_data/pvp_tier.rb +3 -10
  41. data/lib/blizzard_api/wow/game_data/quest.rb +2 -9
  42. data/lib/blizzard_api/wow/game_data/realm.rb +1 -8
  43. data/lib/blizzard_api/wow/game_data/region.rb +1 -8
  44. data/lib/blizzard_api/wow/game_data/reputation.rb +2 -9
  45. data/lib/blizzard_api/wow/game_data/spell.rb +2 -17
  46. data/lib/blizzard_api/wow/game_data/talent.rb +2 -9
  47. data/lib/blizzard_api/wow/game_data/tech_talent.rb +2 -9
  48. data/lib/blizzard_api/wow/game_data/title.rb +1 -16
  49. data/lib/blizzard_api/wow/profile/profile.rb +2 -2
  50. data/lib/blizzard_api/wow/request.rb +3 -3
  51. data/lib/blizzard_api/wow.rb +122 -108
  52. data/lib/blizzard_api.rb +9 -0
  53. metadata +5 -16
@@ -10,15 +10,7 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # spec = BlizzardApi::Wow.playable_specialization
12
12
  class PlayableSpecialization < Wow::GenericDataEndpoint
13
- ##
14
- # @!macro complete
15
- def complete(**options)
16
- index_data = index(**options)
17
- {}.tap do |response_data|
18
- response_data[:character_specializations] = character_data(index_data, options)
19
- response_data[:pet_specializations] = pet_data(index_data, options)
20
- end
21
- end
13
+ setup 'playable-specialization', :static, CACHE_TRIMESTER
22
14
 
23
15
  ##
24
16
  # Fetch media for one of the playable specializations listed by the {#index} using its *id*
@@ -32,15 +24,6 @@ module BlizzardApi
32
24
  api_request "#{base_url(:media)}/playable-specialization/#{id}", **default_options.merge(options)
33
25
  end
34
26
 
35
- protected
36
-
37
- def endpoint_setup
38
- @endpoint = 'playable-specialization'
39
- @namespace = :static
40
- @collection = 'playable_specialization'
41
- @ttl = CACHE_TRIMESTER
42
- end
43
-
44
27
  private
45
28
 
46
29
  def character_data(index_data, options)
@@ -10,14 +10,7 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.power_type
12
12
  class PowerType < Wow::GenericDataEndpoint
13
- protected
14
-
15
- def endpoint_setup
16
- @endpoint = 'power-type'
17
- @namespace = :static
18
- @collection = 'power_types'
19
- @ttl = CACHE_TRIMESTER
20
- end
13
+ setup 'power-type', :static, CACHE_TRIMESTER
21
14
  end
22
15
  end
23
16
  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.profession
12
12
  class Profession < Wow::GenericDataEndpoint
13
+ setup 'profession', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Fetch media for a profession using its *id*
15
17
  #
@@ -58,15 +60,6 @@ module BlizzardApi
58
60
  def recipe_media(id, **options)
59
61
  api_request "#{base_url(:media)}/recipe/#{id}", **default_options.merge(options)
60
62
  end
61
-
62
- protected
63
-
64
- def endpoint_setup
65
- @endpoint = 'profession'
66
- @namespace = :static
67
- @collection = 'professions'
68
- @ttl = CACHE_TRIMESTER
69
- end
70
63
  end
71
64
  end
72
65
  end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BlizzardApi
4
+ module Wow
5
+ ##
6
+ # This class allows access to World of Warcraft PvP seasons
7
+ #
8
+ # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-game-data-api
9
+ #
10
+ # You can get an instance of this class using the default region as follows:
11
+ # api_instance = BlizzardApi::Wow.pvp_season
12
+ class PvpRegion < Wow::GenericDataEndpoint
13
+ setup 'pvp-region', :dynamic, CACHE_TRIMESTER
14
+
15
+ ##
16
+ # Returns a index of pvp seasons within the region
17
+ #
18
+ # @param [Integer] region_id Region ID
19
+ #
20
+ # @!macro request_options
21
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
22
+ #
23
+ # @!macro response
24
+ def seasons(region_id, **options)
25
+ api_request "#{endpoint_uri}/#{region_id}/pvp-season/index", **default_options.merge(options)
26
+ end
27
+
28
+ ##
29
+ # Returns a index of pvp seasons within the region
30
+ #
31
+ # @param [Integer] region_id Region ID
32
+ # @param [Integer] season_id Season ID
33
+ #
34
+ # @!macro request_options
35
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
36
+ #
37
+ # @!macro response
38
+ def season(region_id, season_id, **options)
39
+ api_request "#{endpoint_uri}/#{region_id}/pvp-season/#{season_id}", **default_options.merge(options)
40
+ end
41
+
42
+ ##
43
+ # Returns a index of pvp leaderboard for a season
44
+ #
45
+ # @param [Integer] region_id Region ID
46
+ # @param [Integer] season_id Season ID
47
+ #
48
+ # @!macro request_options
49
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
50
+ #
51
+ # @!macro response
52
+ def leaderboards(region_id, season_id, **options)
53
+ api_request "#{endpoint_uri}/#{region_id}/pvp-season/#{season_id}/pvp-leaderboard/index", **default_options.merge(options)
54
+ end
55
+
56
+ ##
57
+ # Returns the leaderboard for a given season and bracket
58
+ #
59
+ # @param [Integer] region_id Region ID
60
+ # @param [Integer] season_id Season ID
61
+ # @param [String] brackets Brackets
62
+ #
63
+ # @!macro request_options
64
+ # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
65
+ #
66
+ # @!macro response
67
+ def leaderboard(region_id, season_id, brackets, **options)
68
+ api_request "#{endpoint_uri}/#{region_id}/pvp-season/#{season_id}/pvp-leaderboard/#{brackets}", **default_options.merge(options)
69
+ end
70
+
71
+ ##
72
+ # Returns a list of pvp rewards for a season
73
+ #
74
+ # @!macro request_options
75
+ #
76
+ # @!macro response
77
+ def rewards(region_id, season_id, **options)
78
+ api_request "#{endpoint_uri}/#{region_id}/pvp-season/#{season_id}/pvp-reward/index", **default_options.merge(options)
79
+ end
80
+ end
81
+ end
82
+ end
@@ -10,9 +10,13 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.pvp_season
12
12
  class PvpSeason < Wow::GenericDataEndpoint
13
+ setup 'pvp-season', :dynamic, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Returns a index of pvp leaderboard for a season
15
17
  #
18
+ # @param [Integer] season_id Season ID
19
+ #
16
20
  # @!macro request_options
17
21
  # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
18
22
  #
@@ -24,6 +28,9 @@ module BlizzardApi
24
28
  ##
25
29
  # Returns the leaderboard for a given season and bracket
26
30
  #
31
+ # @param [Integer] season_id Season ID
32
+ # @param [String] brackets Brackets
33
+ #
27
34
  # @!macro request_options
28
35
  # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
29
36
  #
@@ -41,15 +48,6 @@ module BlizzardApi
41
48
  def rewards(season_id, **options)
42
49
  api_request "#{endpoint_uri}/#{season_id}/pvp-reward/index", **default_options.merge(options)
43
50
  end
44
-
45
- protected
46
-
47
- def endpoint_setup
48
- @endpoint = 'pvp-season'
49
- @namespace = :dynamic
50
- @collection = 'power_types'
51
- @ttl = CACHE_TRIMESTER
52
- end
53
51
  end
54
52
  end
55
53
  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.pvp_tier
12
12
  class PvpTier < Wow::GenericDataEndpoint
13
+ setup 'pvp-tier', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Returns media assets for a pvp tier
15
17
  #
@@ -17,16 +19,7 @@ module BlizzardApi
17
19
  #
18
20
  # @!macro response
19
21
  def tier_media(id, **options)
20
- api_request "#{base_url(:media)}/#{@endpoint}/#{id}", **default_options.merge(options)
21
- end
22
-
23
- protected
24
-
25
- def endpoint_setup
26
- @endpoint = 'pvp-tier'
27
- @namespace = :static
28
- @collection = 'tiers'
29
- @ttl = CACHE_TRIMESTER
22
+ api_request "#{base_url(:media)}/#{self.class.endpoint}/#{id}", **default_options.merge(options)
30
23
  end
31
24
  end
32
25
  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.quest
12
12
  class Quest < Wow::GenericDataEndpoint
13
+ setup 'quest', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Return a list of quest categories
15
17
  #
@@ -72,15 +74,6 @@ module BlizzardApi
72
74
  def type(id, **options)
73
75
  api_request "#{endpoint_uri}/type/#{id}", **default_options.merge(options)
74
76
  end
75
-
76
- protected
77
-
78
- def endpoint_setup
79
- @endpoint = 'quest'
80
- @namespace = :static
81
- @collection = 'quests'
82
- @ttl = CACHE_TRIMESTER
83
- end
84
77
  end
85
78
  end
86
79
  end
@@ -12,14 +12,7 @@ module BlizzardApi
12
12
  class Realm < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
- protected
16
-
17
- def endpoint_setup
18
- @endpoint = 'realm'
19
- @namespace = :dynamic
20
- @collection = 'realms'
21
- @ttl = CACHE_TRIMESTER
22
- end
15
+ setup 'realm', :dynamic, CACHE_TRIMESTER
23
16
  end
24
17
  end
25
18
  end
@@ -10,14 +10,7 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.region
12
12
  class Region < Wow::GenericDataEndpoint
13
- protected
14
-
15
- def endpoint_setup
16
- @endpoint = 'region'
17
- @namespace = :dynamic
18
- @collection = 'regions'
19
- @ttl = CACHE_TRIMESTER
20
- end
13
+ setup 'region', :dynamic, CACHE_TRIMESTER
21
14
  end
22
15
  end
23
16
  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.reputation
12
12
  class Reputation < Wow::GenericDataEndpoint
13
+ setup 'reputation', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # This method overrides the inherited default behavior to prevent high server load and fetch time
15
17
  #
@@ -67,15 +69,6 @@ module BlizzardApi
67
69
  def tier(id, **options)
68
70
  api_request "#{endpoint_uri('tiers')}/#{id}", **default_options.merge(options)
69
71
  end
70
-
71
- protected
72
-
73
- def endpoint_setup
74
- @endpoint = 'reputation'
75
- @namespace = :static
76
- @collection = 'reputations'
77
- @ttl = CACHE_TRIMESTER
78
- end
79
72
  end
80
73
  end
81
74
  end
@@ -12,6 +12,8 @@ module BlizzardApi
12
12
  class Spell < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
+ setup 'spell', :static, CACHE_TRIMESTER
16
+
15
17
  ##
16
18
  # This method overrides the inherited default behavior to prevent high server load and fetch time
17
19
  #
@@ -20,14 +22,6 @@ module BlizzardApi
20
22
  raise BlizzardApi::ApiException, 'This endpoint does not have a index method'
21
23
  end
22
24
 
23
- ##
24
- # This method overrides the inherited default behavior to prevent high server load and fetch time
25
- #
26
- # @!macro response
27
- def complete
28
- raise BlizzardApi::ApiException, 'This endpoint does not have a complete method'
29
- end
30
-
31
25
  ##
32
26
  # Fetch media for a spell
33
27
  #
@@ -39,15 +33,6 @@ module BlizzardApi
39
33
  def display_media(id, **options)
40
34
  api_request "#{base_url(:media)}/spell/#{id}", **default_options.merge(options)
41
35
  end
42
-
43
- protected
44
-
45
- def endpoint_setup
46
- @endpoint = 'spell'
47
- @namespace = :static
48
- @collection = 'spells'
49
- @ttl = CACHE_TRIMESTER
50
- end
51
36
  end
52
37
  end
53
38
  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.talent
12
12
  class Talent < Wow::GenericDataEndpoint
13
+ setup 'talent', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Fetch pvp talents
15
17
  #
@@ -31,15 +33,6 @@ module BlizzardApi
31
33
  def pvp_talent(id, **options)
32
34
  api_request "#{base_url(:game_data)}/pvp-talent/#{id}", **default_options.merge(options)
33
35
  end
34
-
35
- protected
36
-
37
- def endpoint_setup
38
- @endpoint = 'talent'
39
- @namespace = :static
40
- @collection = 'talents'
41
- @ttl = CACHE_TRIMESTER
42
- end
43
36
  end
44
37
  end
45
38
  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.talent
12
12
  class TechTalent < Wow::GenericDataEndpoint
13
+ setup 'tech-talent', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Fetch tech talent trees
15
17
  #
@@ -43,15 +45,6 @@ module BlizzardApi
43
45
  def media(id, **options)
44
46
  api_request "#{base_url(:media)}/tech-talent/#{id}", **default_options.merge(options)
45
47
  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
48
  end
56
49
  end
57
50
  end
@@ -10,22 +10,7 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.title
12
12
  class Title < Wow::GenericDataEndpoint
13
- ##
14
- # This method overrides the inherited default behavior to prevent high server load and fetch time
15
- #
16
- # @!macro response
17
- def complete
18
- raise BlizzardApi::ApiException, 'There are too many achievements to fetch complete data'
19
- end
20
-
21
- protected
22
-
23
- def endpoint_setup
24
- @endpoint = 'title'
25
- @namespace = :static
26
- @collection = 'titles'
27
- @ttl = CACHE_TRIMESTER
28
- end
13
+ setup 'title', :static, CACHE_TRIMESTER
29
14
  end
30
15
  end
31
16
  end
@@ -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, mode = :regular)
11
- super region, mode
10
+ def initialize(token, **options)
11
+ super(**options)
12
12
  @token = token
13
13
  end
14
14
 
@@ -6,9 +6,9 @@ module BlizzardApi
6
6
  # World of Warcraft requests
7
7
  class Request < BlizzardApi::Request
8
8
  ##
9
- # @!macro regions
10
- def initialize(region = nil, mode = :regular)
11
- super region, mode
9
+ # @!macro init_options
10
+ def initialize(**options)
11
+ super(**options)
12
12
  @game = 'wow'
13
13
  end
14
14
  end