booker_ruby 3.2.2 → 3.2.3
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 +4 -4
- data/lib/booker/client.rb +14 -6
- data/lib/booker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ff2cd935b939e53f89c55bad2268cbef23e47fc
|
4
|
+
data.tar.gz: 8f8c108b173fa61aca02ae8eea617e3ce3ffca38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 854ccd7e1b3a21abb582a7b928bf257a34d2e2c2e2925c7cce1422d74c23edc03de22e4537a38d16459cf665b72ffc2906d89bdede1e4722d61845060a9008f4
|
7
|
+
data.tar.gz: c733a1c8d4a78c60d5bd921ed818e78d17c6303d941b05ccbd57cd69e0d75a59471dcc5362debd0bdce019292dc86024ddd7128af0a592755c16214c6b0c053d
|
data/lib/booker/client.rb
CHANGED
@@ -145,13 +145,21 @@ module Booker
|
|
145
145
|
uri.scheme ? path : "#{self.base_url}#{path}"
|
146
146
|
end
|
147
147
|
|
148
|
-
def handle_errors!(url, request, response)
|
148
|
+
def handle_errors!(url, request, response, retry_unauthorized=true)
|
149
149
|
puts "BOOKER RESPONSE: #{response}" if ENV['BOOKER_API_DEBUG'] == 'true'
|
150
150
|
|
151
151
|
error_class = API_GATEWAY_ERRORS[response.code]
|
152
|
-
|
152
|
+
|
153
|
+
begin
|
154
|
+
raise error_class.new(url: url, request: request, response: response) if error_class
|
155
|
+
rescue Booker::InvalidApiCredentials => ex
|
156
|
+
raise ex unless response.code == 401 && retry_unauthorized
|
157
|
+
get_access_token
|
158
|
+
return nil
|
159
|
+
end
|
153
160
|
|
154
161
|
ex = Booker::Error.new(url: url, request: request, response: response)
|
162
|
+
|
155
163
|
if ex.error.present? || !response.success?
|
156
164
|
case ex.error
|
157
165
|
when 'invalid_client'
|
@@ -219,11 +227,11 @@ module Booker
|
|
219
227
|
url = "#{self.auth_base_url}#{CREATE_TOKEN_PATH}"
|
220
228
|
|
221
229
|
begin
|
222
|
-
handle_errors! url, options, HTTParty.post(url, options)
|
230
|
+
handle_errors! url, options, HTTParty.post(url, options), false
|
223
231
|
rescue Booker::ServiceUnavailable, Booker::RateLimitExceeded
|
224
232
|
# retry once
|
225
233
|
sleep 1
|
226
|
-
handle_errors! url, options, HTTParty.post(url, options)
|
234
|
+
handle_errors! url, options, HTTParty.post(url, options), false
|
227
235
|
end
|
228
236
|
end
|
229
237
|
|
@@ -242,11 +250,11 @@ module Booker
|
|
242
250
|
url = "#{self.auth_base_url}#{UPDATE_TOKEN_CONTEXT_PATH}"
|
243
251
|
|
244
252
|
begin
|
245
|
-
resp = handle_errors! url, options, HTTParty.post(url, options)
|
253
|
+
resp = handle_errors! url, options, HTTParty.post(url, options), false
|
246
254
|
rescue Booker::ServiceUnavailable, Booker::RateLimitExceeded
|
247
255
|
# retry once
|
248
256
|
sleep 1
|
249
|
-
resp = handle_errors! url, options, HTTParty.post(url, options)
|
257
|
+
resp = handle_errors! url, options, HTTParty.post(url, options), false
|
250
258
|
end
|
251
259
|
|
252
260
|
resp.parsed_response
|
data/lib/booker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: booker_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|