blizzard_api 0.6.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ##
4
+ # @!macro [new] init_options
5
+ # @param options [Hash] Initialization options
6
+ # @option options [String] :region API region
7
+ # @option options [Symbol] :model API mode (:regular, :extended)
8
+
3
9
  module BlizzardApi
4
10
  # Starcraft II related classes
5
11
  module Starcraft
@@ -9,10 +15,10 @@ module BlizzardApi
9
15
  require_relative 'starcraft/game_data/league'
10
16
 
11
17
  ##
12
- # @param region [String] API Region
18
+ # @!macro init_options
13
19
  # @return {League}
14
- def self.league(region = BlizzardApi.region)
15
- BlizzardApi::Starcraft::League.new(region)
20
+ def self.league(**options)
21
+ BlizzardApi::Starcraft::League.new(**options)
16
22
  end
17
23
 
18
24
  # Starcraft community api
@@ -22,30 +28,30 @@ module BlizzardApi
22
28
  require_relative 'starcraft/community/legacy'
23
29
 
24
30
  ##
25
- # @param region [String] API Region
31
+ # @!macro init_options
26
32
  # @return {Profile}
27
- def self.profile(region = BlizzardApi.region)
28
- BlizzardApi::Starcraft::Profile.new(region)
33
+ def self.profile(**options)
34
+ BlizzardApi::Starcraft::Profile.new(**options)
29
35
  end
30
36
 
31
37
  ##
32
- # @param region [String] API Region
38
+ # @!macro init_options
33
39
  # @return {Ladder}
34
- def self.ladder(region = BlizzardApi.region)
35
- BlizzardApi::Starcraft::Ladder.new(region)
40
+ def self.ladder(**options)
41
+ BlizzardApi::Starcraft::Ladder.new(**options)
36
42
  end
37
43
 
38
44
  ##
39
- # @param region [String] API Region
45
+ # @!macro init_options
40
46
  # @return {Account}
41
- def self.account(region = BlizzardApi.region)
42
- BlizzardApi::Starcraft::Account.new(region)
47
+ def self.account(**options)
48
+ BlizzardApi::Starcraft::Account.new(**options)
43
49
  end
44
50
 
45
51
  ##
46
52
  # @return {Legacy}
47
- def self.legacy(region = BlizzardApi.region)
48
- BlizzardApi::Starcraft::Legacy.new(region)
53
+ def self.legacy(**options)
54
+ BlizzardApi::Starcraft::Legacy.new(**options)
49
55
  end
50
56
  end
51
57
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BlizzardApi
4
+ ##
5
+ # Manages the current token and expiration date
6
+ module TokenManager
7
+ REDIS_TOKEN_KEY = 'access_token'
8
+
9
+ ##
10
+ # @!attribute access_token
11
+ # Current access token.
12
+ # @return [String] access_token
13
+ attr_accessor :access_token
14
+
15
+ ##
16
+ # @!attribute expires_at
17
+ # Current access token expiration date.
18
+ # @return [String] expires_at
19
+ attr_accessor :expires_at
20
+
21
+ ##
22
+ # Returns if the current token has expired
23
+ #
24
+ # @return [Boolean]
25
+ def access_token_expired?
26
+ return true if access_token.nil?
27
+
28
+ expires_at < Time.now
29
+ end
30
+
31
+ def restore_access_token
32
+ return false unless use_cache && cache_access_token
33
+
34
+ return false unless redis_connection.exists? REDIS_TOKEN_KEY
35
+
36
+ self.access_token = redis_connection.get REDIS_TOKEN_KEY
37
+ self.expires_at = Time.now + redis_connection.ttl(REDIS_TOKEN_KEY)
38
+ true
39
+ end
40
+
41
+ def save_access_token(token_data)
42
+ ttl = token_data['expires_in'].to_i
43
+ self.expires_at = Time.now + ttl
44
+ self.access_token = token_data['access_token']
45
+
46
+ redis_connection.setex REDIS_TOKEN_KEY, ttl, access_token if use_cache && cache_access_token
47
+ end
48
+ end
49
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '0.6.4'
5
+ VERSION = '1.0.0'
6
6
  end
@@ -10,13 +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.achievement
12
12
  class Achievement < 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
13
+ setup 'achievement', :static, CACHE_TRIMESTER
20
14
 
21
15
  ##
22
16
  # Return a list of possible achievement categories.
@@ -47,15 +41,6 @@ module BlizzardApi
47
41
  def media(id, **options)
48
42
  api_request "#{base_url(:media)}/achievement/#{id}", **default_options.merge(options)
49
43
  end
50
-
51
- protected
52
-
53
- def endpoint_setup
54
- @endpoint = 'achievement'
55
- @namespace = :static
56
- @collection = 'achievements'
57
- @ttl = CACHE_TRIMESTER
58
- end
59
44
  end
60
45
  end
61
46
  end
@@ -12,6 +12,8 @@ module BlizzardApi
12
12
  class AzeriteEssence < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
+ setup 'azerite-essence', :static, CACHE_TRIMESTER
16
+
15
17
  ##
16
18
  # Fetch media for one of the azerite essences listed by the {#index} using its *id*
17
19
  #
@@ -23,15 +25,6 @@ module BlizzardApi
23
25
  def media(id, **options)
24
26
  api_request "#{base_url(:media)}/azerite-essence/#{id}", **default_options.merge(options)
25
27
  end
26
-
27
- protected
28
-
29
- def endpoint_setup
30
- @endpoint = 'azerite-essence'
31
- @namespace = :static
32
- @collection = 'azerite_essences'
33
- @ttl = CACHE_TRIMESTER
34
- end
35
28
  end
36
29
  end
37
30
  end
@@ -12,14 +12,7 @@ module BlizzardApi
12
12
  class ConnectedRealm < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
- protected
16
-
17
- def endpoint_setup
18
- @endpoint = 'connected-realm'
19
- @namespace = :dynamic
20
- @collection = 'connected_realms'
21
- @ttl = CACHE_TRIMESTER
22
- end
15
+ setup 'connected-realm', :dynamic, CACHE_TRIMESTER
23
16
  end
24
17
  end
25
18
  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.azerite_essence
12
12
  class Covenant < Wow::GenericDataEndpoint
13
+ setup 'covenant', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Fetch media for one of the covenants listed by the {#index} using its *id*
15
17
  #
@@ -65,15 +67,6 @@ module BlizzardApi
65
67
  def conduit(id, **options)
66
68
  api_request "#{base_url(:game_data)}/covenant/conduit/#{id}", **default_options.merge(options)
67
69
  end
68
-
69
- protected
70
-
71
- def endpoint_setup
72
- @endpoint = 'covenant'
73
- @namespace = :static
74
- @collection = 'covenants'
75
- @ttl = CACHE_TRIMESTER
76
- end
77
70
  end
78
71
  end
79
72
  end
@@ -12,14 +12,12 @@ module BlizzardApi
12
12
  class Creature < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
+ setup 'creature', :static, CACHE_TRIMESTER
16
+
15
17
  def index
16
18
  raise BlizzardApi::ApiException, 'Creatures endpoint doesn\'t have an index method'
17
19
  end
18
20
 
19
- def complete
20
- raise BlizzardApi::ApiException, 'There are too many creatures to fetch complete data'
21
- end
22
-
23
21
  ##
24
22
  # Fetch all creature families
25
23
  #
@@ -99,15 +97,6 @@ module BlizzardApi
99
97
  def display_media(id, **options)
100
98
  api_request "#{base_url(:media)}/creature-display/#{id}", **default_options.merge(options)
101
99
  end
102
-
103
- protected
104
-
105
- def endpoint_setup
106
- @endpoint = 'creature'
107
- @namespace = :static
108
- @collection = 'achievements'
109
- @ttl = CACHE_TRIMESTER
110
- end
111
100
  end
112
101
  end
113
102
  end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thwait'
4
-
5
3
  module BlizzardApi
6
4
  module Wow
7
5
  ##
8
6
  # Generic endpoint to support most data requests with minor configurations
9
7
  class GenericDataEndpoint < Wow::Request
10
- ##
11
- # @!macro regions
12
- def initialize(region = nil, mode = :regular)
13
- super region, mode
14
- endpoint_setup
15
- @ttl ||= CACHE_DAY
8
+ class << self
9
+ attr_accessor :endpoint, :namespace, :ttl
10
+
11
+ def setup(endpoint, namespace, ttl)
12
+ self.endpoint = endpoint
13
+ self.namespace = namespace
14
+ self.ttl = ttl
15
+ end
16
16
  end
17
17
 
18
18
  ##
@@ -35,42 +35,15 @@ module BlizzardApi
35
35
  api_request "#{endpoint_uri}/#{id}", **default_options.merge(options)
36
36
  end
37
37
 
38
- ##
39
- # @!macro complete
40
- def complete(**options)
41
- payload = [].tap do |complete_data|
42
- index_data = index(**options)
43
- threads = []
44
-
45
- concurrency = options.key?(:concurrency) ? options[:concurrency].to_i : BlizzardApi.concurrency
46
- concurrency.times do
47
- threads << Thread.new do
48
- while index_data[@collection.to_sym].size.positive?
49
- item = index_data[@collection.to_sym].pop
50
- link = item.key?(:key) ? item[:key][:href] : item[:href]
51
- item_data = request link
52
- complete_data.push item_data
53
- end
54
- end
55
- end
56
- ThreadsWait.all_waits threads
57
- end
58
- payload.sort { |a, b| a[:id] <=> b[:id] }
59
- end
60
-
61
38
  protected
62
39
 
63
40
  def endpoint_uri(variant = nil, scope = :game_data)
64
- endpoint = variant ? "#{@endpoint}-#{variant}" : @endpoint
41
+ endpoint = variant ? "#{self.class.endpoint}-#{variant}" : self.class.endpoint
65
42
  "#{base_url(scope)}/#{endpoint}"
66
43
  end
67
44
 
68
- def endpoint_setup
69
- raise NotImplementedError, 'You must override this method to properly set up the endpoint'
70
- end
71
-
72
45
  def default_options
73
- { namespace: @namespace, ttl: @ttl }
46
+ { namespace: self.class.namespace, ttl: self.class.ttl }
74
47
  end
75
48
  end
76
49
  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.guild_crest
12
12
  class GuildCrest < Wow::GenericDataEndpoint
13
+ setup 'guild-crest', :static, CACHE_TRIMESTER
14
+
13
15
  def get
14
16
  raise BlizzardApi::ApiException, 'This endpoint doens\'t have a get method'
15
17
  end
@@ -25,7 +27,7 @@ module BlizzardApi
25
27
  #
26
28
  # @!macro response
27
29
  def border_media(id, **options)
28
- api_request "#{base_url(:media)}/#{@endpoint}/border/#{id}", **default_options.merge(options)
30
+ api_request "#{base_url(:media)}/#{self.class.endpoint}/border/#{id}", **default_options.merge(options)
29
31
  end
30
32
 
31
33
  ##
@@ -39,15 +41,7 @@ module BlizzardApi
39
41
  #
40
42
  # @!macro response
41
43
  def emblem_media(id, **options)
42
- api_request "#{base_url(:media)}/#{@endpoint}/emblem/#{id}", **default_options.merge(options)
43
- end
44
-
45
- protected
46
-
47
- def endpoint_setup
48
- @endpoint = 'guild-crest'
49
- @namespace = :static
50
- @ttl = CACHE_TRIMESTER
44
+ api_request "#{base_url(:media)}/#{self.class.endpoint}/emblem/#{id}", **default_options.merge(options)
51
45
  end
52
46
  end
53
47
  end
@@ -12,6 +12,8 @@ module BlizzardApi
12
12
  class Item < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
+ setup 'item', :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
  # Return a list of item classes
33
27
  #
@@ -49,7 +43,7 @@ module BlizzardApi
49
43
  # @option options [Boolean] :classic1x If set to true, this method will call the classic era version
50
44
  #
51
45
  # @!macro response
52
- def class(id, **options)
46
+ def item_class(id, **options)
53
47
  api_request "#{endpoint_uri('class')}/#{id}", **default_options.merge(options)
54
48
  end
55
49
 
@@ -101,15 +95,6 @@ module BlizzardApi
101
95
  def set(id, **options)
102
96
  api_request "#{endpoint_uri('set')}/#{id}", **default_options.merge(options)
103
97
  end
104
-
105
- protected
106
-
107
- def endpoint_setup
108
- @endpoint = 'item'
109
- @namespace = :static
110
- @collection = 'items'
111
- @ttl = CACHE_TRIMESTER
112
- end
113
98
  end
114
99
  end
115
100
  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.journal
12
12
  class Journal < Wow::GenericDataEndpoint
13
+ setup 'journal', :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
  #
@@ -18,14 +20,6 @@ module BlizzardApi
18
20
  raise BlizzardApi::ApiException, 'This endpoint does not have a index method'
19
21
  end
20
22
 
21
- ##
22
- # This method overrides the inherited default behavior to prevent high server load and fetch time
23
- #
24
- # @!macro response
25
- def complete
26
- raise BlizzardApi::ApiException, 'This endpoint does not have a complete method'
27
- end
28
-
29
23
  ##
30
24
  # This method overrides the inherited default behavior to prevent high server load and fetch time
31
25
  #
@@ -111,15 +105,6 @@ module BlizzardApi
111
105
 
112
106
  api_request "#{endpoint_uri('encounter', :search)}?#{search_options.to_search_query}", **default_options.merge(options)
113
107
  end
114
-
115
- protected
116
-
117
- def endpoint_setup
118
- @endpoint = 'journal'
119
- @namespace = :static
120
- @collection = 'journals'
121
- @ttl = CACHE_TRIMESTER
122
- end
123
108
  end
124
109
  end
125
110
  end
@@ -12,6 +12,8 @@ module BlizzardApi
12
12
  class Media < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
+ setup 'media', :static, CACHE_TRIMESTER
16
+
15
17
  def index(_options = nil)
16
18
  raise BlizzardApi::ApiException, 'This endpoint does not have a index method'
17
19
  end
@@ -19,19 +21,6 @@ module BlizzardApi
19
21
  def get(_options = nil)
20
22
  raise BlizzardApi::ApiException, 'This endpoint does not have a get method'
21
23
  end
22
-
23
- def complete(_options = nil)
24
- raise BlizzardApi::ApiException, 'This endpoint does not have a complete method'
25
- end
26
-
27
- protected
28
-
29
- def endpoint_setup
30
- @endpoint = 'media'
31
- @namespace = :static
32
- @collection = 'medias'
33
- @ttl = CACHE_TRIMESTER
34
- end
35
24
  end
36
25
  end
37
26
  end
@@ -10,9 +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.modified_crafting
12
12
  class ModifiedCrafting < Wow::GenericDataEndpoint
13
- def complete
14
- raise BlizzardApi::ApiException, 'This endpoint does not have a complete method.'
15
- end
13
+ setup 'modified-crafting', :static, CACHE_TRIMESTER
16
14
 
17
15
  ##
18
16
  # Fetch modified crafting category index
@@ -53,15 +51,6 @@ module BlizzardApi
53
51
  def slot_type(id, **options)
54
52
  api_request "#{base_url(:game_data)}/modified-crafting/reagent-slot-type/#{id}", **default_options.merge(options)
55
53
  end
56
-
57
- protected
58
-
59
- def endpoint_setup
60
- @endpoint = 'modified-crafting'
61
- @namespace = :static
62
- @collection = 'professions'
63
- @ttl = CACHE_TRIMESTER
64
- end
65
54
  end
66
55
  end
67
56
  end
@@ -12,14 +12,7 @@ module BlizzardApi
12
12
  class Mount < Wow::GenericDataEndpoint
13
13
  include BlizzardApi::Wow::Searchable
14
14
 
15
- protected
16
-
17
- def endpoint_setup
18
- @endpoint = 'mount'
19
- @namespace = :static
20
- @collection = 'mounts'
21
- @ttl = CACHE_TRIMESTER
22
- end
15
+ setup 'mount', :static, CACHE_TRIMESTER
23
16
  end
24
17
  end
25
18
  end
@@ -10,14 +10,12 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # api_instance = BlizzardApi::Wow.mythic_keystone
12
12
  class MythicKeystone < Wow::GenericDataEndpoint
13
+ setup 'mythic-keystone', :dynamic, CACHE_TRIMESTER
14
+
13
15
  def get
14
16
  raise BlizzardApi::ApiException, 'Mythic keystone endpoint does not have a get method'
15
17
  end
16
18
 
17
- def complete
18
- raise BlizzardApi::ApiException, 'There are too many creatures to fetch complete data'
19
- end
20
-
21
19
  ##
22
20
  # Fetch all mythic keystone dungeons
23
21
  #
@@ -83,15 +81,6 @@ module BlizzardApi
83
81
  def season(id, **options)
84
82
  api_request "#{endpoint_uri}/season/#{id}", **default_options.merge(options)
85
83
  end
86
-
87
- protected
88
-
89
- def endpoint_setup
90
- @endpoint = 'mythic-keystone'
91
- @namespace = :dynamic
92
- @collection = 'mythic-keystones'
93
- @ttl = CACHE_TRIMESTER
94
- end
95
84
  end
96
85
  end
97
86
  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.mythic_keystone_affix
12
12
  class MythicKeystoneAffix < Wow::GenericDataEndpoint
13
+ setup 'keystone-affix', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Fetch media for one of the affixes listed by the {#index} using its *id*
15
17
  #
@@ -21,15 +23,6 @@ module BlizzardApi
21
23
  def media(id, **options)
22
24
  api_request "#{base_url(:media)}/keystone-affix/#{id}", **default_options.merge(options)
23
25
  end
24
-
25
- protected
26
-
27
- def endpoint_setup
28
- @endpoint = 'keystone-affix'
29
- @namespace = :static
30
- @collection = 'affixes'
31
- @ttl = CACHE_TRIMESTER
32
- end
33
26
  end
34
27
  end
35
28
  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.pet
12
12
  class Pet < Wow::GenericDataEndpoint
13
+ setup 'pet', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Fetch media for one of the pets listed by the {#index} using its *id*
15
17
  #
@@ -55,15 +57,6 @@ module BlizzardApi
55
57
  def ability_media(id, **options)
56
58
  api_request "#{base_url(:media)}/pet-ability/#{id}", **default_options.merge(options)
57
59
  end
58
-
59
- protected
60
-
61
- def endpoint_setup
62
- @endpoint = 'pet'
63
- @namespace = :static
64
- @collection = 'pets'
65
- @ttl = CACHE_TRIMESTER
66
- end
67
60
  end
68
61
  end
69
62
  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.playable_class
12
12
  class PlayableClass < Wow::GenericDataEndpoint
13
+ setup 'playable-class', :static, CACHE_TRIMESTER
14
+
13
15
  ##
14
16
  # Returns the PvP talent slots data of a specific class
15
17
  #
@@ -21,22 +23,6 @@ module BlizzardApi
21
23
  api_request "#{endpoint_uri}/#{id}/pvp-talent-slots", **default_options.merge(options)
22
24
  end
23
25
 
24
- ##
25
- # @!macro complete
26
- #
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
29
- def complete(**options)
30
- index_data = index(**options)
31
- [].tap do |classes|
32
- index_data[:classes].each do |pclass|
33
- class_id = %r{playable-class/([0-9]+)}.match(pclass[:key].to_s)[1]
34
- class_data = get class_id, **options
35
- classes.push class_data
36
- end
37
- end
38
- end
39
-
40
26
  ##
41
27
  # Return playable class data by its id
42
28
  #
@@ -67,13 +53,6 @@ module BlizzardApi
67
53
 
68
54
  protected
69
55
 
70
- def endpoint_setup
71
- @endpoint = 'playable-class'
72
- @namespace = :static
73
- @collection = 'classes'
74
- @ttl = CACHE_TRIMESTER
75
- end
76
-
77
56
  def get_class_icon(media_url, **options)
78
57
  return if options.include? :classic
79
58
 
@@ -10,14 +10,7 @@ module BlizzardApi
10
10
  # You can get an instance of this class using the default region as follows:
11
11
  # race = BlizzardApi::Wow.playable_race
12
12
  class PlayableRace < Wow::GenericDataEndpoint
13
- protected
14
-
15
- def endpoint_setup
16
- @endpoint = 'playable-race'
17
- @namespace = :static
18
- @collection = 'races'
19
- @ttl = CACHE_TRIMESTER
20
- end
13
+ setup 'playable-race', :static, CACHE_TRIMESTER
21
14
  end
22
15
  end
23
16
  end