bungie_client 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bungie_client.gemspec +1 -0
- data/lib/bungie_client.rb +1 -0
- data/lib/bungie_client/client.rb +26 -2
- data/lib/bungie_client/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f0b5c103d49481ce7300bd2724679f860977880
|
4
|
+
data.tar.gz: 998c54fc103ba3ccec2473bb9e6e53f747293781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3f1ef5947d8e36f9109d7c9aa86a2bae01ffa84b2432e16c64f063b4821b246fa8cefe97a09495f25a0f81ddce9b74854b222b0bb95ae1c93778263a10f6aa
|
7
|
+
data.tar.gz: 270f89f6c368a7dc9f756329fc8ba3f6d7dde138d2036e5cedabf65bc53851bb343d6f1c9bb40b93bf52f49c2c7f21da65c712431a0981420bd8cc5e00de827a
|
data/bungie_client.gemspec
CHANGED
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.12"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "hashie", "~> 3.4"
|
24
25
|
spec.add_development_dependency 'mechanize', "~> 2.7", ">= 2.7.0"
|
25
26
|
end
|
data/lib/bungie_client.rb
CHANGED
data/lib/bungie_client/client.rb
CHANGED
@@ -117,21 +117,25 @@ class BungieClient::Client
|
|
117
117
|
# @option options [Boolean] :cache_none - disable response caching
|
118
118
|
# @option options [Boolean] :cache_rewrite - update cache value
|
119
119
|
# @option options [Integer] :cache_ttl - special cache ttl
|
120
|
+
# @option options [Boolean] :cache_only - allow get result only from cache
|
120
121
|
#
|
121
|
-
# @return [
|
122
|
+
# @return [Hash|nil]
|
122
123
|
def get_response(uri, parameters = {}, options = {})
|
123
124
|
if allow_get_cache options
|
124
125
|
result = @cache.get "#{uri}+#{parameters}"
|
125
126
|
|
126
127
|
return result unless result.nil?
|
127
128
|
end
|
129
|
+
return nil if options[:cache_only]
|
128
130
|
|
129
131
|
result = get uri, parameters
|
130
132
|
|
131
133
|
if !result.nil? && result != ''
|
132
134
|
result = JSON.parse result
|
133
135
|
|
134
|
-
if
|
136
|
+
if result.is_a?(Hash) && !result['Response'].nil? && result['ErrorCode'] == 1
|
137
|
+
result = Hashie::Mash.new result
|
138
|
+
|
135
139
|
@cache.set "#{uri}+#{parameters}", result['Response'], options[:cache_ttl] if allow_set_cache options
|
136
140
|
|
137
141
|
result['Response']
|
@@ -149,6 +153,26 @@ class BungieClient::Client
|
|
149
153
|
@agent.post(self.class.request_uri(uri), query, headers).body rescue nil
|
150
154
|
end
|
151
155
|
|
156
|
+
# Get Response field after post request to bungie
|
157
|
+
#
|
158
|
+
# @param [String] uri
|
159
|
+
# @param [Hash] query for post
|
160
|
+
#
|
161
|
+
# @return [Hash|nil]
|
162
|
+
def post_response(uri, query = {})
|
163
|
+
result = post uri, query
|
164
|
+
|
165
|
+
if !result.nil? && result != ''
|
166
|
+
result = JSON.parse result
|
167
|
+
|
168
|
+
if result.is_a?(Hash) && !result['Response'].nil? && result['ErrorCode'] == 1
|
169
|
+
result = Hashie::Mash.new result
|
170
|
+
|
171
|
+
result['Response']
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
152
176
|
protected
|
153
177
|
|
154
178
|
# Headers for requests
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bungie_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Ruban
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mechanize
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|