blizzard_api 2.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +1 -1
- data/lib/blizzard_api/api_response.rb +27 -0
- data/lib/blizzard_api/diablo/community/{character.rb → character_class.rb} +1 -1
- data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +1 -1
- data/lib/blizzard_api/diablo.rb +2 -2
- data/lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb +1 -1
- data/lib/blizzard_api/request.rb +29 -8
- data/lib/blizzard_api/version.rb +1 -1
- data/lib/blizzard_api/wow/game_data/auction.rb +6 -0
- data/lib/blizzard_api/wow/game_data/guild_crest.rb +1 -1
- data/lib/blizzard_api/wow/game_data/reputation.rb +1 -1
- data/lib/blizzard_api/wow/game_data/spell.rb +1 -1
- data/lib/blizzard_api/wow/game_data/wow_token.rb +5 -10
- data/lib/blizzard_api/wow/profile/character_profile.rb +1 -1
- data/lib/blizzard_api.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba8374332ff5b57727b9b5528294f71c723b617fc863672f2cc1673c8a1f1537
|
4
|
+
data.tar.gz: 29b16eee7787cfc7a5e53d3274a829b49db727ca106e9e1f53a0867a1a81b188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2f2dfff1fed002b4ee9ac408a59a675d175c0effbc04fd39d3aac55b29802cc5db9d9d563528b2349724111191f7d0eddd15f696c2c67399a3df05875ffa6d5
|
7
|
+
data.tar.gz: 335ccfcdebdcfc92c345c11a0da1330092fdc55a5cc0a7927a4099ae37f838673a1b2ad6fbd29b9aa0b05f9274049d8e38a653379054cecb29259af2b395290c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
Please view this file on the master branch, otherwise it may be outdated
|
2
2
|
|
3
|
+
**Version 3.2.0**
|
4
|
+
|
5
|
+
Added new AH commodities endpoint.
|
6
|
+
|
7
|
+
**Version 3.1.0**
|
8
|
+
|
9
|
+
Fixed the latest build to exclude non 200 responses from caching.
|
10
|
+
|
11
|
+
**Version 3.0.0**
|
12
|
+
|
13
|
+
Changed the way `:extended` mode is handled regarding caching. Now the extended mode will use cache and return a fake
|
14
|
+
response object if the content is cached (Cache is still ignored when using the `:since` option).
|
15
|
+
A cached response can be identified by the presence of a `cached?` method on the response object.
|
16
|
+
|
17
|
+
Some automated tests for SC2 endpoints are now ignoring `503` errors. The state of the API is somehow unknown since it
|
18
|
+
is down most of the time.
|
19
|
+
|
3
20
|
**Version 2.0.0**
|
4
21
|
|
5
22
|
Removed the `icon` field from PlayableClass, it was meant to mimic the old communit API behavior during the transition
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
##
|
5
|
+
# Simple replacement for the http response object for cached data
|
6
|
+
class ApiResponse
|
7
|
+
attr_reader :code, :body
|
8
|
+
|
9
|
+
def initialize(body)
|
10
|
+
@code = 200
|
11
|
+
@body = body
|
12
|
+
end
|
13
|
+
|
14
|
+
def cached?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Net
|
21
|
+
# Workaround for fake response payloads
|
22
|
+
class HTTPResponse
|
23
|
+
def cached?
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -9,7 +9,7 @@ module BlizzardApi
|
|
9
9
|
#
|
10
10
|
# You can get an instance of this class using the default region as follows:
|
11
11
|
# api_instance = BlizzardApi::Diablo.character
|
12
|
-
class
|
12
|
+
class CharacterClass < BlizzardApi::Diablo::Request
|
13
13
|
##
|
14
14
|
# Return information about a class
|
15
15
|
#
|
@@ -35,7 +35,7 @@ module BlizzardApi
|
|
35
35
|
# Fetch leaderboard data for the current endpoint
|
36
36
|
#
|
37
37
|
# @param [Integer] id One of the IDs returned by the {index}
|
38
|
-
# @param [
|
38
|
+
# @param [String] leaderboard_id Leaderboard id
|
39
39
|
# @!macro request_options
|
40
40
|
#
|
41
41
|
# @!macro response
|
data/lib/blizzard_api/diablo.rb
CHANGED
@@ -34,7 +34,7 @@ module BlizzardApi
|
|
34
34
|
require_relative 'diablo/community/act'
|
35
35
|
require_relative 'diablo/community/artisan'
|
36
36
|
require_relative 'diablo/community/follower'
|
37
|
-
require_relative 'diablo/community/
|
37
|
+
require_relative 'diablo/community/character_class'
|
38
38
|
require_relative 'diablo/community/item_type'
|
39
39
|
require_relative 'diablo/community/item'
|
40
40
|
require_relative 'diablo/community/profile'
|
@@ -64,7 +64,7 @@ module BlizzardApi
|
|
64
64
|
# @!macro init_options
|
65
65
|
# @return {Character}
|
66
66
|
def self.character(**options)
|
67
|
-
BlizzardApi::Diablo::
|
67
|
+
BlizzardApi::Diablo::CharacterClass.new(**options)
|
68
68
|
end
|
69
69
|
|
70
70
|
##
|
data/lib/blizzard_api/request.rb
CHANGED
@@ -82,20 +82,28 @@ module BlizzardApi
|
|
82
82
|
def request(url, **options)
|
83
83
|
# Creates the whole url for request
|
84
84
|
parsed_url = URI.parse(url)
|
85
|
-
|
86
85
|
data = using_cache?(options) ? find_in_cache(parsed_url.to_s) : nil
|
87
86
|
|
88
87
|
# If data was found that means cache is enabled and valid
|
89
|
-
return
|
88
|
+
return prepare_response data if data
|
90
89
|
|
91
90
|
response = consume_api parsed_url, **options
|
92
91
|
|
93
|
-
|
92
|
+
handle_cache_on_response parsed_url, response, **options
|
93
|
+
end
|
94
94
|
|
95
|
-
|
96
|
-
|
95
|
+
def handle_cache_on_response(parsed_url, response, **options)
|
96
|
+
case response.code.to_i
|
97
|
+
when 304
|
98
|
+
response_data = nil
|
99
|
+
when 200
|
100
|
+
response_data = response.body
|
101
|
+
else
|
102
|
+
return nil, response
|
103
|
+
end
|
97
104
|
|
98
|
-
|
105
|
+
save_in_cache parsed_url.to_s, response.body, options[:ttl] || CACHE_DAY if using_cache? options
|
106
|
+
prepare_response response_data, response
|
99
107
|
end
|
100
108
|
|
101
109
|
def api_request(uri, **query_string)
|
@@ -110,7 +118,7 @@ module BlizzardApi
|
|
110
118
|
|
111
119
|
# In case uri already have query string parameters joins them with &
|
112
120
|
if query_string.size.positive?
|
113
|
-
query_string = URI.encode_www_form(query_string
|
121
|
+
query_string = URI.encode_www_form(query_string)
|
114
122
|
uri = uri.include?('?') ? "#{uri}&#{query_string}" : "#{uri}?#{query_string}"
|
115
123
|
end
|
116
124
|
|
@@ -119,10 +127,22 @@ module BlizzardApi
|
|
119
127
|
|
120
128
|
private
|
121
129
|
|
130
|
+
##
|
131
|
+
# Resolves the response based on the mode
|
132
|
+
def prepare_response(data, response = nil)
|
133
|
+
parsed_data = data.nil? ? data : JSON.parse(data, symbolize_names: true)
|
134
|
+
|
135
|
+
return parsed_data unless mode.eql? :extended
|
136
|
+
|
137
|
+
response ||= ApiResponse.new(data)
|
138
|
+
|
139
|
+
[response, parsed_data]
|
140
|
+
end
|
141
|
+
|
122
142
|
##
|
123
143
|
# @param options [Hash] Request options
|
124
144
|
def using_cache?(options)
|
125
|
-
return false if
|
145
|
+
return false if options.key?(:since)
|
126
146
|
|
127
147
|
!options.fetch(:ignore_cache, false)
|
128
148
|
end
|
@@ -130,6 +150,7 @@ module BlizzardApi
|
|
130
150
|
def http_connection(url)
|
131
151
|
Net::HTTP.new(url.host, url.port).tap do |http|
|
132
152
|
http.use_ssl = true
|
153
|
+
http.keep_alive_timeout = 30
|
133
154
|
end
|
134
155
|
end
|
135
156
|
|
data/lib/blizzard_api/version.rb
CHANGED
@@ -39,6 +39,12 @@ module BlizzardApi
|
|
39
39
|
|
40
40
|
api_request "#{base_url(:game_data)}/connected-realm/#{connected_realm_id}/auctions", **opts
|
41
41
|
end
|
42
|
+
|
43
|
+
def commodities(**options)
|
44
|
+
opts = { ttl: CACHE_HOUR, namespace: :dynamic }.merge(options)
|
45
|
+
|
46
|
+
api_request "#{base_url(:game_data)}/auctions/commodities", **opts
|
47
|
+
end
|
42
48
|
end
|
43
49
|
end
|
44
50
|
end
|
@@ -9,16 +9,11 @@ module BlizzardApi
|
|
9
9
|
#
|
10
10
|
# You can get an instance of this class using the default region as follows:
|
11
11
|
# api_instance = BlizzardApi::Wow.wow_token
|
12
|
-
class WowToken <
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
# @!macro response
|
19
|
-
def get(**options)
|
20
|
-
opts = { namespace: :dynamic, ttl: CACHE_HOUR }.merge(options)
|
21
|
-
api_request "#{base_url(:game_data)}/token/index", **opts
|
12
|
+
class WowToken < GenericDataEndpoint
|
13
|
+
setup 'token', :dynamic, CACHE_HOUR
|
14
|
+
|
15
|
+
def get
|
16
|
+
raise BlizzardApi::ApiException, 'This endpoint does not have a index method'
|
22
17
|
end
|
23
18
|
end
|
24
19
|
end
|
data/lib/blizzard_api.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'blizzard_api/configuration'
|
4
4
|
require_relative 'blizzard_api/token_manager'
|
5
5
|
require_relative 'blizzard_api/api_standards'
|
6
|
+
require_relative 'blizzard_api/api_response'
|
6
7
|
require_relative 'blizzard_api/request'
|
7
8
|
require_relative 'blizzard_api/exception'
|
8
9
|
require_relative 'blizzard_api/version'
|
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: 2.0
|
4
|
+
version: 3.2.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: 2022-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -121,12 +121,13 @@ files:
|
|
121
121
|
- bin/setup
|
122
122
|
- blizzard_api.gemspec
|
123
123
|
- lib/blizzard_api.rb
|
124
|
+
- lib/blizzard_api/api_response.rb
|
124
125
|
- lib/blizzard_api/api_standards.rb
|
125
126
|
- lib/blizzard_api/configuration.rb
|
126
127
|
- lib/blizzard_api/diablo.rb
|
127
128
|
- lib/blizzard_api/diablo/community/act.rb
|
128
129
|
- lib/blizzard_api/diablo/community/artisan.rb
|
129
|
-
- lib/blizzard_api/diablo/community/
|
130
|
+
- lib/blizzard_api/diablo/community/character_class.rb
|
130
131
|
- lib/blizzard_api/diablo/community/follower.rb
|
131
132
|
- lib/blizzard_api/diablo/community/item.rb
|
132
133
|
- lib/blizzard_api/diablo/community/item_type.rb
|