blizzard_api 0.2.5 → 0.2.6

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 (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/blizzard_api/request.rb +8 -5
  5. data/lib/blizzard_api/version.rb +1 -1
  6. data/lib/blizzard_api/wow/game_data/achievement.rb +1 -1
  7. data/lib/blizzard_api/wow/game_data/azerite_essence.rb +1 -1
  8. data/lib/blizzard_api/wow/game_data/connected_realm.rb +1 -1
  9. data/lib/blizzard_api/wow/game_data/creature.rb +7 -1
  10. data/lib/blizzard_api/wow/game_data/guild.rb +1 -1
  11. data/lib/blizzard_api/wow/game_data/guild_crest.rb +3 -1
  12. data/lib/blizzard_api/wow/game_data/item.rb +6 -1
  13. data/lib/blizzard_api/wow/game_data/mount.rb +1 -1
  14. data/lib/blizzard_api/wow/game_data/mythic_keystone.rb +1 -1
  15. data/lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb +1 -1
  16. data/lib/blizzard_api/wow/game_data/mythic_keystone_leaderboard.rb +1 -1
  17. data/lib/blizzard_api/wow/game_data/mythic_raid_leaderboard.rb +1 -1
  18. data/lib/blizzard_api/wow/game_data/pet.rb +1 -1
  19. data/lib/blizzard_api/wow/game_data/playable_class.rb +7 -1
  20. data/lib/blizzard_api/wow/game_data/playable_specialization.rb +1 -1
  21. data/lib/blizzard_api/wow/game_data/power_type.rb +1 -1
  22. data/lib/blizzard_api/wow/game_data/pvp_season.rb +1 -1
  23. data/lib/blizzard_api/wow/game_data/pvp_tier.rb +1 -1
  24. data/lib/blizzard_api/wow/game_data/race.rb +2 -1
  25. data/lib/blizzard_api/wow/game_data/realm.rb +1 -1
  26. data/lib/blizzard_api/wow/game_data/region.rb +1 -1
  27. data/lib/blizzard_api/wow/game_data/title.rb +1 -1
  28. data/lib/blizzard_api/wow/game_data/wow_token.rb +1 -1
  29. data/lib/blizzard_api/wow/profile/character_profile.rb +1 -1
  30. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef547d30cdbb5599ad187f0b222b94921c9597c89dba9c95ee96ab98f2083267
4
- data.tar.gz: a5a62685e422fcd58735c894286f69781b5bdd546e0b8fedb9c3ca05c783de2f
3
+ metadata.gz: 25c1bd74a1092556badd39caaef17c28d9147e6bfbc5f5503885b908909bc80e
4
+ data.tar.gz: 9635f636213f46d088727e94c927848606570472ba50604b19c00aaf8b795776
5
5
  SHA512:
6
- metadata.gz: 89bd6b397a46d2ad4f48b09f20bda65ac1b44d666d2e619fbfc11aa1f1eb18d79d000a56e76358b25ef521543ee532063697c696df74c9efc604855c787f9d12
7
- data.tar.gz: 5d6bda03485f62b00e074aedc0d924d0c416e57f65bbf9b72c1dfeade0d4a7dc785bbbc2feb40c38f23ea7a794918de68d625cfa09a83fc10e8e904065622c91
6
+ metadata.gz: d1c93eaeb0897efd8ff31944139d2e9d46fdab0f26983123fd5f2722b57d85a7feed2bf6fb1803965f9fd7120a4c9a490e79cf2b1e15051a33fe50c5bafabbc3
7
+ data.tar.gz: a675dd8aec9fea8676e8e938e8b201a2b2279118ac22f54f28503e09308962cfe5b1df092b3370e3c5969b55ae030851f163b58e1804a2b6f5a491a23b500268
@@ -1,5 +1,9 @@
1
1
  Please view this file on the master branch, otherwise it may be outdated
2
2
 
3
+ **Version 0.2.6**
4
+ * Added namespace `static-classic` for wow classic support.
5
+ * Some WoW endpoints now support the `classic: true` option.
6
+
3
7
  **Version 0.2.5**
4
8
  * Added two unreleased endpoints for character profile(`raid_progression` and `collections`).
5
9
  * Added new WoW profile endpoints
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blizzard_api (0.2.5)
4
+ blizzard_api (0.2.6)
5
5
  redis (~> 4.1, >= 4.1.0)
6
6
 
7
7
  GEM
@@ -83,13 +83,13 @@ module BlizzardApi
83
83
  ##
84
84
  # Returns a valid namespace string for consuming the api endpoints
85
85
  #
86
- # @param [Symbol] scope Scope of the namespace to be used. *:dynamic* or *:static*
87
- def endpoint_namespace(scope)
88
- case scope
86
+ # @param [Hash] options A hash containing the namespace key
87
+ def endpoint_namespace(options)
88
+ case options[:namespace]
89
89
  when :dynamic
90
90
  "dynamic-#{region}"
91
91
  when :static
92
- "static-#{region}"
92
+ options.include?(:classic) ? "static-classic-#{region}" : "static-#{region}"
93
93
  when :profile
94
94
  "profile-#{region}"
95
95
  else
@@ -139,11 +139,14 @@ module BlizzardApi
139
139
 
140
140
  def api_request(uri, query_string = {})
141
141
  # List of request options
142
- options_key = %i[ignore_cache ttl format access_token]
142
+ options_key = %i[ignore_cache ttl format access_token namespace classic]
143
143
 
144
144
  # Separates request options from api fields and options. Any user-defined option will be treated as api field.
145
145
  options = query_string.select { |k, _v| query_string.delete(k) || true if options_key.include? k }
146
146
 
147
+ # Namespace
148
+ query_string[:namespace] = endpoint_namespace(options) if options.include? :namespace
149
+
147
150
  # In case uri already have query string parameters joins them with &
148
151
  if query_string.size.positive?
149
152
  query_string = URI.encode_www_form(query_string, false)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '0.2.5'
5
+ VERSION = '0.2.6'
6
6
  end
@@ -68,7 +68,7 @@ module BlizzardApi
68
68
 
69
69
  def endpoint_setup
70
70
  @endpoint = 'achievement'
71
- @namespace = endpoint_namespace :static
71
+ @namespace = :static
72
72
  @collection = 'achievements'
73
73
  @ttl = CACHE_TRIMESTER
74
74
  end
@@ -26,7 +26,7 @@ module BlizzardApi
26
26
 
27
27
  def endpoint_setup
28
28
  @endpoint = 'azerite-essence'
29
- @namespace = endpoint_namespace :static
29
+ @namespace = :static
30
30
  @collection = 'azerite_essences'
31
31
  @ttl = CACHE_TRIMESTER
32
32
  end
@@ -14,7 +14,7 @@ module BlizzardApi
14
14
 
15
15
  def endpoint_setup
16
16
  @endpoint = 'connected-realm'
17
- @namespace = endpoint_namespace :dynamic
17
+ @namespace = :dynamic
18
18
  @collection = 'connected_realms'
19
19
  @ttl = CACHE_TRIMESTER
20
20
  end
@@ -22,6 +22,7 @@ module BlizzardApi
22
22
  # Fetch all creature families
23
23
  #
24
24
  # @!macro request_options
25
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
25
26
  #
26
27
  # @!macro response
27
28
  def families(options = {})
@@ -34,6 +35,7 @@ module BlizzardApi
34
35
  # @param id [Integer] Creature family id
35
36
  #
36
37
  # @!macro request_options
38
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
37
39
  #
38
40
  # @!macro response
39
41
  def family(id, options = {})
@@ -46,6 +48,7 @@ module BlizzardApi
46
48
  # @param id [Integer] Creature family id
47
49
  #
48
50
  # @!macro request_options
51
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
49
52
  #
50
53
  # @!macro response
51
54
  def family_media(id, options = {})
@@ -56,6 +59,7 @@ module BlizzardApi
56
59
  # Fetch all creature types
57
60
  #
58
61
  # @!macro request_options
62
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
59
63
  #
60
64
  # @!macro response
61
65
  def types(options = {})
@@ -68,6 +72,7 @@ module BlizzardApi
68
72
  # @param id [Integer] Creature type id
69
73
  #
70
74
  # @!macro request_options
75
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
71
76
  #
72
77
  # @!macro response
73
78
  def type(id, options = {})
@@ -80,6 +85,7 @@ module BlizzardApi
80
85
  # @param id [Integer] Creature type id
81
86
  #
82
87
  # @!macro request_options
88
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
83
89
  #
84
90
  # @!macro response
85
91
  def display_media(id, options = {})
@@ -90,7 +96,7 @@ module BlizzardApi
90
96
 
91
97
  def endpoint_setup
92
98
  @endpoint = 'creature'
93
- @namespace = endpoint_namespace :static
99
+ @namespace = :static
94
100
  @collection = 'achievements'
95
101
  @ttl = CACHE_TRIMESTER
96
102
  end
@@ -105,7 +105,7 @@ module BlizzardApi
105
105
  guild = CGI.escape string_to_slug(guild)
106
106
  url = "#{base_url(:game_data)}/guild/#{realm}/#{guild}"
107
107
  url += "/#{variant}" if variant
108
- api_request url, { ttl: CACHE_DAY, namespace: endpoint_namespace(:profile) }.merge(options)
108
+ api_request url, { ttl: CACHE_DAY, namespace: :profile }.merge(options)
109
109
  end
110
110
  end
111
111
  end
@@ -20,6 +20,7 @@ module BlizzardApi
20
20
  # @param id [Integer] Border id
21
21
  #
22
22
  # @!macro request_options
23
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
23
24
  #
24
25
  # @!macro response
25
26
  def border_media(id, options = {})
@@ -30,6 +31,7 @@ module BlizzardApi
30
31
  # Return guild embelm assets by its id
31
32
  #
32
33
  # @param id [Integer] Emblem id
34
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
33
35
  #
34
36
  # @!macro request_options
35
37
  #
@@ -42,7 +44,7 @@ module BlizzardApi
42
44
 
43
45
  def endpoint_setup
44
46
  @endpoint = 'guild-crest'
45
- @namespace = endpoint_namespace(:static)
47
+ @namespace = :static
46
48
  @ttl = CACHE_TRIMESTER
47
49
  end
48
50
  end
@@ -33,6 +33,7 @@ module BlizzardApi
33
33
  # @!macro request_options
34
34
  # @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
35
35
  # instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
36
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
36
37
  #
37
38
  # @!macro response
38
39
  def get(id, options = {})
@@ -58,6 +59,7 @@ module BlizzardApi
58
59
  # @!macro request_options
59
60
  # @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
60
61
  # instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
62
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
61
63
  #
62
64
  # @!macro response
63
65
  def classes(options = {})
@@ -73,6 +75,7 @@ module BlizzardApi
73
75
  #
74
76
  # @param id [Integer] Item class id
75
77
  # @!macro request_options
78
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
76
79
  #
77
80
  # @!macro response
78
81
  def class(id, options = {})
@@ -85,6 +88,7 @@ module BlizzardApi
85
88
  # @param id [Integer] Item class id
86
89
  # @param subclass_id [Integer] Item subclass id
87
90
  # @!macro request_options
91
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
88
92
  #
89
93
  # @!macro response
90
94
  def subclass(id, subclass_id, options = {})
@@ -97,6 +101,7 @@ module BlizzardApi
97
101
  # @param id [Integer] Item id
98
102
  #
99
103
  # @!macro request_options
104
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
100
105
  #
101
106
  # @!macro response
102
107
  def media(id, options = {})
@@ -107,7 +112,7 @@ module BlizzardApi
107
112
 
108
113
  def endpoint_setup
109
114
  @endpoint = 'item'
110
- @namespace = endpoint_namespace :static
115
+ @namespace = :static
111
116
  @collection = 'items'
112
117
  @ttl = CACHE_TRIMESTER
113
118
  end
@@ -28,7 +28,7 @@ module BlizzardApi
28
28
 
29
29
  def endpoint_setup
30
30
  @endpoint = 'mount'
31
- @namespace = endpoint_namespace :static
31
+ @namespace = :static
32
32
  @collection = 'mounts'
33
33
  @ttl = CACHE_TRIMESTER
34
34
  end
@@ -88,7 +88,7 @@ module BlizzardApi
88
88
 
89
89
  def endpoint_setup
90
90
  @endpoint = 'mythic-keystone'
91
- @namespace = endpoint_namespace :dynamic
91
+ @namespace = :dynamic
92
92
  @collection = 'mythic-keystones'
93
93
  @ttl = CACHE_TRIMESTER
94
94
  end
@@ -14,7 +14,7 @@ module BlizzardApi
14
14
 
15
15
  def endpoint_setup
16
16
  @endpoint = 'keystone-affix'
17
- @namespace = endpoint_namespace :static
17
+ @namespace = :static
18
18
  @collection = 'affixes'
19
19
  @ttl = CACHE_TRIMESTER
20
20
  end
@@ -37,7 +37,7 @@ module BlizzardApi
37
37
  private
38
38
 
39
39
  def default_options(options)
40
- { ttl: CACHE_DAY, namespace: endpoint_namespace(:dynamic) }.merge options
40
+ { ttl: CACHE_DAY, namespace: :dynamic }.merge options
41
41
  end
42
42
 
43
43
  def endpoint_uri(connected_realm_id)
@@ -20,7 +20,7 @@ module BlizzardApi
20
20
  #
21
21
  # @!macro response
22
22
  def get(raid, faction, options = {})
23
- opts = options.merge(namespace: endpoint_namespace(:dynamic), ttl: CACHE_DAY)
23
+ opts = options.merge(namespace: :dynamic, ttl: CACHE_DAY)
24
24
  api_request "#{base_url(:game_data)}/leaderboard/hall-of-fame/#{raid}/#{faction}", opts
25
25
  end
26
26
  end
@@ -89,7 +89,7 @@ module BlizzardApi
89
89
 
90
90
  def endpoint_setup
91
91
  @endpoint = 'pet'
92
- @namespace = endpoint_namespace :static
92
+ @namespace = :static
93
93
  @collection = 'pets'
94
94
  @ttl = CACHE_TRIMESTER
95
95
  end
@@ -16,6 +16,7 @@ module BlizzardApi
16
16
  # @!macro request_options
17
17
  # @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
18
18
  # instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
19
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
19
20
  #
20
21
  # @!macro response
21
22
  def index(options = {})
@@ -37,6 +38,8 @@ module BlizzardApi
37
38
 
38
39
  ##
39
40
  # @!macro complete
41
+ #
42
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
40
43
  def complete(options = {})
41
44
  index_data = index options
42
45
  [].tap do |classes|
@@ -54,6 +57,7 @@ module BlizzardApi
54
57
  # @param id [Integer] Playable class id
55
58
  #
56
59
  # @!macro request_options
60
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
57
61
  #
58
62
  # @!macro response
59
63
  def get(id, options = {})
@@ -66,12 +70,14 @@ module BlizzardApi
66
70
 
67
71
  def endpoint_setup
68
72
  @endpoint = 'playable-class'
69
- @namespace = endpoint_namespace :static
73
+ @namespace = :static
70
74
  @collection = 'classes'
71
75
  @ttl = CACHE_TRIMESTER
72
76
  end
73
77
 
74
78
  def get_class_icon(media_url, options)
79
+ return if options.include? :classic
80
+
75
81
  media_data = request media_url[:key][:href], options
76
82
  %r{56/([a-z_]+).jpg}.match(media_data[:assets][0][:value].to_s)[1]
77
83
  end
@@ -24,7 +24,7 @@ module BlizzardApi
24
24
 
25
25
  def endpoint_setup
26
26
  @endpoint = 'playable-specialization'
27
- @namespace = endpoint_namespace :static
27
+ @namespace = :static
28
28
  @collection = 'playable_specialization'
29
29
  @ttl = CACHE_TRIMESTER
30
30
  end
@@ -14,7 +14,7 @@ module BlizzardApi
14
14
 
15
15
  def endpoint_setup
16
16
  @endpoint = 'power-type'
17
- @namespace = endpoint_namespace :static
17
+ @namespace = :static
18
18
  @collection = 'power_types'
19
19
  @ttl = CACHE_TRIMESTER
20
20
  end
@@ -44,7 +44,7 @@ module BlizzardApi
44
44
 
45
45
  def endpoint_setup
46
46
  @endpoint = 'pvp-season'
47
- @namespace = endpoint_namespace :dynamic
47
+ @namespace = :dynamic
48
48
  @collection = 'power_types'
49
49
  @ttl = CACHE_TRIMESTER
50
50
  end
@@ -24,7 +24,7 @@ module BlizzardApi
24
24
 
25
25
  def endpoint_setup
26
26
  @endpoint = 'pvp-tier'
27
- @namespace = endpoint_namespace :static
27
+ @namespace = :static
28
28
  @collection = 'tiers'
29
29
  @ttl = CACHE_TRIMESTER
30
30
  end
@@ -16,6 +16,7 @@ module BlizzardApi
16
16
  # @!macro request_options
17
17
  # @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
18
18
  # instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
19
+ # @option options [Boolean] :classic If set to true, this method will call the classic version
19
20
  #
20
21
  # @!macro response
21
22
  def index(options = {})
@@ -28,7 +29,7 @@ module BlizzardApi
28
29
 
29
30
  def endpoint_setup
30
31
  @endpoint = 'playable-race'
31
- @namespace = endpoint_namespace :static
32
+ @namespace = :static
32
33
  @collection = 'races'
33
34
  @ttl = CACHE_TRIMESTER
34
35
  end
@@ -27,7 +27,7 @@ module BlizzardApi
27
27
 
28
28
  def endpoint_setup
29
29
  @endpoint = 'realm'
30
- @namespace = endpoint_namespace :dynamic
30
+ @namespace = :dynamic
31
31
  @collection = 'realms'
32
32
  @ttl = CACHE_TRIMESTER
33
33
  end
@@ -27,7 +27,7 @@ module BlizzardApi
27
27
 
28
28
  def endpoint_setup
29
29
  @endpoint = 'region'
30
- @namespace = endpoint_namespace :dynamic
30
+ @namespace = :dynamic
31
31
  @collection = 'regions'
32
32
  @ttl = CACHE_TRIMESTER
33
33
  end
@@ -22,7 +22,7 @@ module BlizzardApi
22
22
 
23
23
  def endpoint_setup
24
24
  @endpoint = 'title'
25
- @namespace = endpoint_namespace :static
25
+ @namespace = :static
26
26
  @collection = 'titles'
27
27
  @ttl = CACHE_TRIMESTER
28
28
  end
@@ -17,7 +17,7 @@ module BlizzardApi
17
17
  #
18
18
  # @!macro response
19
19
  def get(options = {})
20
- opts = { namespace: endpoint_namespace(:dynamic), ttl: CACHE_HOUR }.merge(options)
20
+ opts = { namespace: :dynamic, ttl: CACHE_HOUR }.merge(options)
21
21
  api_request "#{base_url(:game_data)}/token/index", opts
22
22
  end
23
23
  end
@@ -274,7 +274,7 @@ module BlizzardApi
274
274
  private
275
275
 
276
276
  def default_options(user_token = nil)
277
- opts = { ttl: CACHE_HOUR, namespace: endpoint_namespace(:profile) }
277
+ opts = { ttl: CACHE_HOUR, namespace: :profile }
278
278
  opts.merge access_token: user_token if user_token
279
279
  opts
280
280
  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.5
4
+ version: 0.2.6
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-15 00:00:00.000000000 Z
11
+ date: 2019-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis