blizzard_api 0.4.1 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 242a293ba7b8ca3247dc92e4d4499049f4e81fc5ee425035148ad45d45717076
4
- data.tar.gz: 0b4035e8c611f321a516182ec8f95ec88da575a408b43624ffa8ce4d7e1c7a37
3
+ metadata.gz: 79f0c2964787e385ec480a01f0286a455a5869b7d6d3e9d8f4f46b9ac0bd98b6
4
+ data.tar.gz: c79b59fb2862b32e325240159a8d7dc08199c4f6f9fb3c060df4d73016de414d
5
5
  SHA512:
6
- metadata.gz: f8ffab41d1106b9ae14cab5ca48bd369cd301ad7c833d878d841f96ab5c30fdb6944ed1e52b757e52cb519361e3c1317c798202d8e6333c215013d2b35304a57
7
- data.tar.gz: 3a06b3833836360e72578224e53cc1b1cccb8c70bc310958b0ffe3f02a0cbbbf6ad6e545ad6413a5f7b067edf0f70f783b252b97bcfbf71a19eaec1a66ebbaa9
6
+ metadata.gz: a425ba4f7b554a3381f7fb588650ff4525320da241c5f10c21e472bd8ef982659929bce064eb19c107b0b7ccabd1702d215fbbb256024e2be2a0cad7913110d0
7
+ data.tar.gz: b8d2b32b759989fd5f7d2a129b9cb2e6c5b23d06e1ea5bbaa9159a7c65bc1d771fbfd3fb782260950553d2c0feaaeca748567e0db4337357c9e9ac0135b7f8de
@@ -1,6 +1,6 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- Metrics/LineLength:
3
+ Layout/LineLength:
4
4
  Max: 140
5
5
 
6
6
  Metrics/ModuleLength:
@@ -12,6 +12,7 @@ Metrics/AbcSize:
12
12
 
13
13
  AllCops:
14
14
  TargetRubyVersion: 2.5
15
+ NewCops: enable
15
16
  Exclude:
16
17
  - 'vendor/**/*'
17
18
  - 'bin/**/*'
@@ -1,5 +1,52 @@
1
1
  Please view this file on the master branch, otherwise it may be outdated
2
2
 
3
+ **Version 0.5.0**
4
+
5
+ This version brings a lot of internal changes to the way the gem works. While
6
+ there no breaking change is expected use it carefully.
7
+
8
+ ## New features:
9
+
10
+ ### Extended mode
11
+
12
+ When creating a request you can now specify **mode** as the last argument. Available modes:
13
+ * **regular**: No changes, should work as it always did.
14
+ * **extended**: All requests now return an array with two objects, the actual HTTPResponse object and the usual Hash.
15
+
16
+ ```ruby
17
+ api_client = BlizzardApi::Wow::Item.new 'us', :extended
18
+ response, item_data = api_client.get 35_000
19
+
20
+ puts response.code # 200
21
+ puts item_data[:name][:en_US] # Brutal Gladiator's Dragonhide Legguards
22
+ ```
23
+
24
+ This is intended to expose the response code and headers.
25
+
26
+ **Important**: Extended mode completely disables the cache.
27
+
28
+ ### Custom headers
29
+
30
+ You an now pass custom headers in the **options** hash.
31
+
32
+ There is also a new shorthand for the `If-Modified-Since` header.
33
+
34
+ ```ruby
35
+ # If-Modified-Since shorhand
36
+ auction_data = BlizzardApi::Wow.auction.get 1146, since: DateTime.parse('2099-01-01Z')
37
+
38
+ # Using custom headers
39
+ auction_data = BlizzardApi::Wow.auction.get 1146, headers: { 'If-Modified-Since' => 'Sun, 27 Sep 2020 02:17:03 GMT' }
40
+ ```
41
+
42
+ **Important**
43
+ * Headers are not part of the cache key, use the option `ignore_cache: true` when needed.
44
+ * The `since` shorthand will always disable the cache.
45
+
46
+ **Version 0.4.2**
47
+
48
+ Added new retail and classic search endpoints described here: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200708/10310
49
+
3
50
  **Version 0.4.1**
4
51
 
5
52
  Added new retail and classic endpoints described here: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200609/8902
@@ -1,31 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blizzard_api (0.4.0)
4
+ blizzard_api (0.5.0)
5
5
  redis (~> 4.1, >= 4.1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.0)
11
- dotenv (2.7.5)
12
- jaro_winkler (1.5.3)
13
- minitest (5.11.3)
14
- parallel (1.17.0)
15
- parser (2.6.3.0)
16
- ast (~> 2.4.0)
10
+ ast (2.4.1)
11
+ dotenv (2.7.6)
12
+ minitest (5.14.2)
13
+ parallel (1.19.2)
14
+ parser (2.7.1.5)
15
+ ast (~> 2.4.1)
17
16
  rainbow (3.0.0)
18
17
  rake (13.0.1)
19
- redis (4.1.4)
20
- rubocop (0.74.0)
21
- jaro_winkler (~> 1.5.1)
18
+ redis (4.2.2)
19
+ regexp_parser (1.8.0)
20
+ rexml (3.2.4)
21
+ rubocop (0.92.0)
22
22
  parallel (~> 1.10)
23
- parser (>= 2.6)
23
+ parser (>= 2.7.1.5)
24
24
  rainbow (>= 2.2.2, < 4.0)
25
+ regexp_parser (>= 1.7)
26
+ rexml
27
+ rubocop-ast (>= 0.5.0)
25
28
  ruby-progressbar (~> 1.7)
26
- unicode-display_width (>= 1.4.0, < 1.7)
29
+ unicode-display_width (>= 1.4.0, < 2.0)
30
+ rubocop-ast (0.6.0)
31
+ parser (>= 2.7.1.5)
27
32
  ruby-progressbar (1.10.1)
28
- unicode-display_width (1.6.0)
33
+ unicode-display_width (1.7.0)
29
34
  yard (0.9.25)
30
35
 
31
36
  PLATFORMS
data/README.md CHANGED
@@ -145,6 +145,7 @@ end
145
145
  - types
146
146
  - type :id
147
147
  - display_media :id
148
+ - search
148
149
  * Blizzard::Wow::Guild
149
150
  - rewards
150
151
  - perks
@@ -211,6 +212,7 @@ end
211
212
  - get :id
212
213
  - complete
213
214
  - status :realms
215
+ - search
214
216
  * Blizzard::Wow::Region
215
217
  - index
216
218
  - get :id
@@ -231,10 +233,12 @@ end
231
233
  - class :id
232
234
  - subclass :class_id, :subclass_id
233
235
  - media :id
236
+ - search
234
237
  * Blizzard::Wow::AzeriteEssence
235
238
  - index
236
239
  - get :id
237
240
  - media :id
241
+ - search
238
242
  * Blizzard::Wow::ReputationTier
239
243
  - index
240
244
  - get :id
@@ -262,6 +266,7 @@ end
262
266
  - get :id
263
267
  * Blizzard::Wow::Spell
264
268
  - get :id
269
+ - search
265
270
  * Blizzard::Wow::Zone
266
271
  - index
267
272
  - get :id
@@ -4,8 +4,8 @@ module BlizzardApi
4
4
  module Diablo
5
5
  # Generic endpoint to support most data requests with minor configurations
6
6
  class GenericDataEndpoint < Diablo::Request
7
- def initialize(region = nil)
8
- super region
7
+ def initialize(region = nil, mode = :regular)
8
+ super region, mode
9
9
  endpoint_setup
10
10
  @ttl ||= CACHE_DAY
11
11
  end
@@ -6,8 +6,8 @@ module BlizzardApi
6
6
  class Request < BlizzardApi::Request
7
7
  ##
8
8
  # @!macro regions
9
- def initialize(region = nil)
10
- super region
9
+ def initialize(region = nil, mode = :regular)
10
+ super region, mode
11
11
  @game = 'd3'
12
12
  end
13
13
  end
@@ -4,8 +4,8 @@ module BlizzardApi
4
4
  module Hearthstone
5
5
  # Generic endpoint to support most data requests with minor configurations
6
6
  class GenericDataEndpoint < Hearthstone::Request
7
- def initialize(region = nil)
8
- super region
7
+ def initialize(region = nil, mode = :regular)
8
+ super region, mode
9
9
  endpoint_setup
10
10
  @ttl ||= CACHE_DAY
11
11
  end
@@ -6,8 +6,8 @@ module BlizzardApi
6
6
  class Request < BlizzardApi::Request
7
7
  ##
8
8
  # @!macro regions
9
- def initialize(region = nil)
10
- super region
9
+ def initialize(region = nil, mode = :regular)
10
+ super region, mode
11
11
  @game = 'hearthstone'
12
12
  end
13
13
  end
@@ -8,6 +8,7 @@
8
8
  # @option options [String] :access_token Overrides the access_token for a single call
9
9
  # @option options [Boolean] :ignore_cache If set to true the request will not use the cache
10
10
  # @option options [Integer] :ttl Override the default time (in seconds) a request should be cached
11
+ # @option options [DateTime] :since Adds the If-modified-since headers. Will always ignore cache when set.
11
12
 
12
13
  ##
13
14
  # @!macro [new] regions
@@ -31,18 +32,12 @@ module BlizzardApi
31
32
  ##
32
33
  # Simplifies the requests to Blizzard APIS
33
34
  class Request
34
- # One minute cache
35
- CACHE_MINUTE = 60
36
35
  # One hour cache
37
- CACHE_HOUR = 60 * CACHE_MINUTE
36
+ CACHE_HOUR = 3600
38
37
  # One day cache
39
38
  CACHE_DAY = 24 * CACHE_HOUR
40
- # One week cache
41
- CACHE_WEEK = CACHE_DAY * 7
42
- # One (commercial) month cache
43
- CACHE_MONTH = CACHE_DAY * 30
44
39
  # Three (commercial) months cache
45
- CACHE_TRIMESTER = CACHE_MONTH * 3
40
+ CACHE_TRIMESTER = CACHE_DAY * 90
46
41
 
47
42
  # Common endpoints
48
43
  BASE_URLS = {
@@ -59,13 +54,20 @@ module BlizzardApi
59
54
  # @return [String] Api region
60
55
  attr_accessor :region
61
56
 
57
+ ##
58
+ # @!attribute mode
59
+ # @return [:regular, :extended]
60
+ attr_accessor :mode
61
+
62
62
  ##
63
63
  # @!macro regions
64
- def initialize(region = nil)
64
+ def initialize(region = nil, mode = :regular)
65
65
  self.region = region || BlizzardApi.region
66
66
  @redis = Redis.new(host: BlizzardApi.redis_host, port: BlizzardApi.redis_port) if BlizzardApi.use_cache
67
67
  # Use the shared access_token, or create one if it doesn't exists. This avoids unnecessary calls to create tokens.
68
68
  @access_token = BlizzardApi.access_token || create_access_token
69
+ # Mode
70
+ @mode = mode
69
71
  end
70
72
 
71
73
  require 'net/http'
@@ -98,10 +100,6 @@ module BlizzardApi
98
100
  end
99
101
  end
100
102
 
101
- def string_to_slug(string)
102
- CGI.escape(string.downcase.tr(' ', '-'))
103
- end
104
-
105
103
  def create_access_token
106
104
  uri = URI.parse("https://#{BlizzardApi.region}.battle.net/oauth/token")
107
105
 
@@ -121,26 +119,24 @@ module BlizzardApi
121
119
  # Creates the whole url for request
122
120
  parsed_url = URI.parse(url)
123
121
 
124
- data = options[:ignore_cache] ? nil : find_in_cache(parsed_url.to_s)
122
+ data = using_cache?(options) ? find_in_cache(parsed_url.to_s) : nil
123
+
125
124
  # If data was found that means cache is enabled and valid
126
- return format_response data if data
125
+ return JSON.parse(data, symbolize_names: true) if data
127
126
 
128
- # Override access_token
129
- @access_token = options[:access_token] if options.include? :access_token
127
+ response = consume_api parsed_url, options
130
128
 
131
- response = consume_api parsed_url
129
+ save_in_cache parsed_url.to_s, response.body, options[:ttl] || CACHE_DAY if using_cache? options
132
130
 
133
- unless options[:ignore_cache]
134
- ttl = options[:ttl] || CACHE_DAY
135
- save_in_cache parsed_url.to_s, response.body, ttl
136
- end
131
+ response_data = response.code.to_i.eql?(304) ? nil : JSON.parse(response.body, symbolize_names: true)
132
+ return [response, response_data] if mode.eql? :extended
137
133
 
138
- format_response response.body
134
+ response_data
139
135
  end
140
136
 
141
137
  def api_request(uri, query_string = {})
142
138
  # List of request options
143
- options_key = %i[ignore_cache ttl format access_token namespace classic]
139
+ options_key = %i[ignore_cache ttl format access_token namespace classic headers since]
144
140
 
145
141
  # Separates request options from api fields and options. Any user-defined option will be treated as api field.
146
142
  options = query_string.select { |k, _v| query_string.delete(k) || true if options_key.include? k }
@@ -159,35 +155,46 @@ module BlizzardApi
159
155
 
160
156
  private
161
157
 
162
- def consume_api(url)
158
+ ##
159
+ # @param options [Hash] Request options
160
+ def using_cache?(options)
161
+ return false if mode.eql?(:extended) || options.key?(:since)
162
+
163
+ !options.fetch(:ignore_cache, false)
164
+ end
165
+
166
+ def consume_api(url, options = {})
163
167
  # Creates a HTTP connection and request to ensure thread safety
164
168
  http = Net::HTTP.new(url.host, url.port)
165
169
  http.use_ssl = true
166
170
  request = Net::HTTP::Get.new(url)
167
171
 
168
- # Blizzard API documentation states the preferred way to send the access_token is using Bearer token on header
169
- request['Authorization'] = "Bearer #{@access_token}"
172
+ add_headers request, options
170
173
 
171
174
  # Executes the request
172
175
  http.request(request).tap do |response|
173
- raise BlizzardApi::ApiException.new 'Request failed', response.code.to_i unless response.code.to_i == 200
176
+ if mode.eql?(:regular) && ![200, 304].include?(response.code.to_i)
177
+ raise BlizzardApi::ApiException.new 'Request failed', response.code.to_i
178
+ end
174
179
  end
175
180
  end
176
181
 
177
- def save_in_cache(resource_url, data, ttl)
178
- return nil unless BlizzardApi.use_cache
182
+ def add_headers(request, options)
183
+ # Blizzard API documentation states the preferred way to send the access_token is using Bearer token on header
184
+ request['Authorization'] = "Bearer #{options.fetch(:access_token, @access_token)}"
185
+ # Format If-modified-since option
186
+ request['If-Modified-Since'] = options[:since].httpdate if options.key? :since
187
+ options[:headers]&.each { |header, content| request[header] = content }
188
+ end
179
189
 
180
- @redis.setex resource_url, ttl, data
190
+ def save_in_cache(resource_url, data, ttl)
191
+ @redis.setex resource_url, ttl, data if BlizzardApi.use_cache
181
192
  end
182
193
 
183
194
  def find_in_cache(resource_url)
184
195
  return false unless BlizzardApi.use_cache
185
196
 
186
- @redis.get resource_url if @redis.exists resource_url
187
- end
188
-
189
- def format_response(data)
190
- JSON.parse(data, symbolize_names: true)
197
+ @redis.get resource_url if @redis.exists? resource_url
191
198
  end
192
199
  end
193
200
  end
@@ -15,8 +15,8 @@ module BlizzardApi
15
15
 
16
16
  ##
17
17
  # @!macro regions
18
- def initialize(region = nil)
19
- super region
18
+ def initialize(region = nil, mode = :regular)
19
+ super region, mode
20
20
  @game = 'sc2'
21
21
  end
22
22
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '0.4.1'
5
+ VERSION = '0.5.0'
6
6
  end
@@ -7,6 +7,7 @@ module BlizzardApi
7
7
  require_relative 'wow/game_data/generic_data_endpoint'
8
8
  require_relative 'wow/search/search_composer'
9
9
  require_relative 'wow/search/search_request'
10
+ require_relative 'wow/slug'
10
11
 
11
12
  # WoW data api
12
13
  require_relative 'wow/game_data/achievement'
@@ -17,6 +18,7 @@ module BlizzardApi
17
18
  require_relative 'wow/game_data/guild_crest'
18
19
  require_relative 'wow/game_data/item'
19
20
  require_relative 'wow/game_data/journal'
21
+ require_relative 'wow/game_data/media'
20
22
  require_relative 'wow/game_data/mount'
21
23
  require_relative 'wow/game_data/mythic_keystone_affix'
22
24
  require_relative 'wow/game_data/mythic_keystone'
@@ -95,6 +97,13 @@ module BlizzardApi
95
97
  BlizzardApi::Wow::Journal.new(region)
96
98
  end
97
99
 
100
+ ##
101
+ # @param region [String] API Region
102
+ # @return {Media}
103
+ def self.media(region = BlizzardApi.region)
104
+ BlizzardApi::Wow::Media.new(region)
105
+ end
106
+
98
107
  ##
99
108
  # @param region [String] API Region
100
109
  # @return {Mount}
@@ -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 AzeriteEssence < Wow::GenericDataEndpoint
13
+ include BlizzardApi::Wow::Searchable
14
+
13
15
  ##
14
16
  # Fetch media for one of the azerite essences listed by the {#index} using its *id*
15
17
  #
@@ -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.creature
12
12
  class Creature < Wow::GenericDataEndpoint
13
+ include BlizzardApi::Wow::Searchable
14
+
13
15
  def index
14
16
  raise BlizzardApi::ApiException, 'Creatures endpoint doesn\'t have a index method'
15
17
  end
@@ -7,8 +7,8 @@ module BlizzardApi
7
7
  class GenericDataEndpoint < Wow::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
  endpoint_setup
13
13
  @ttl ||= CACHE_DAY
14
14
  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.item
12
12
  class Item < 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
  #
@@ -97,6 +97,21 @@ module BlizzardApi
97
97
  api_request "#{endpoint_uri('encounter')}/#{id}", default_options.merge(options)
98
98
  end
99
99
 
100
+ ##
101
+ # Fetch data base on search criteria
102
+ #
103
+ # @param page [Integer] Page o return
104
+ # @param page_size [Integer] Amount of items per page
105
+ #
106
+ # @!macro request_options
107
+ # @!macro response
108
+ def encounter_search(page = 1, page_size = 100, options = {})
109
+ search_options = SearchComposer.new(page, page_size)
110
+ yield search_options if block_given?
111
+
112
+ api_request "#{endpoint_uri('encounter', :search)}?#{search_options.to_search_query}", default_options.merge(options)
113
+ end
114
+
100
115
  protected
101
116
 
102
117
  def endpoint_setup
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BlizzardApi
4
+ module Wow
5
+ ##
6
+ # This class allows access to World of Warcraft mounts
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.mount
12
+ class Media < Wow::GenericDataEndpoint
13
+ include BlizzardApi::Wow::Searchable
14
+
15
+ def index(_options = nil)
16
+ raise BlizzardApi::ApiException, 'This endpoint does not have a index method'
17
+ end
18
+
19
+ def get(_options = nil)
20
+ raise BlizzardApi::ApiException, 'This endpoint does not have a get method'
21
+ 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
+ end
36
+ end
37
+ 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.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,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
  #
@@ -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'
@@ -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.1
4
+ version: 0.5.0
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-09 00:00:00.000000000 Z
11
+ date: 2020-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -160,6 +160,7 @@ files:
160
160
  - lib/blizzard_api/wow/game_data/guild_crest.rb
161
161
  - lib/blizzard_api/wow/game_data/item.rb
162
162
  - lib/blizzard_api/wow/game_data/journal.rb
163
+ - lib/blizzard_api/wow/game_data/media.rb
163
164
  - lib/blizzard_api/wow/game_data/mount.rb
164
165
  - lib/blizzard_api/wow/game_data/mythic_keystone.rb
165
166
  - lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb
@@ -187,6 +188,7 @@ files:
187
188
  - lib/blizzard_api/wow/request.rb
188
189
  - lib/blizzard_api/wow/search/search_composer.rb
189
190
  - lib/blizzard_api/wow/search/search_request.rb
191
+ - lib/blizzard_api/wow/slug.rb
190
192
  homepage: https://gitlab.com/francisschiavo/blizzard_api
191
193
  licenses:
192
194
  - MIT