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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ba59dbde75634577c6ad38ce8c4eb332b8bfb11
4
- data.tar.gz: e61e0742deb27500c6bb8d983a86b9b4114401ae
3
+ metadata.gz: 0ff2cd935b939e53f89c55bad2268cbef23e47fc
4
+ data.tar.gz: 8f8c108b173fa61aca02ae8eea617e3ce3ffca38
5
5
  SHA512:
6
- metadata.gz: 1e7336e0c42a7239ad65b115cb042b7e78ea100c49d064dca635b22cdfae1bff045612054bb58a5686bb5e37b471a1da251c4570e242047b861b433fcd115dbc
7
- data.tar.gz: 17441b65f3b30012d3663c7b49f2220ae57873c4ec849cb0da5a0ed9b3fa03d2e87ed3a12786aa9fe1fbe7c11ce7ff8ea803b433cc2caa14b5eaf81aea05e9fd
6
+ metadata.gz: 854ccd7e1b3a21abb582a7b928bf257a34d2e2c2e2925c7cce1422d74c23edc03de22e4537a38d16459cf665b72ffc2906d89bdede1e4722d61845060a9008f4
7
+ data.tar.gz: c733a1c8d4a78c60d5bd921ed818e78d17c6303d941b05ccbd57cd69e0d75a59471dcc5362debd0bdce019292dc86024ddd7128af0a592755c16214c6b0c053d
@@ -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
- raise error_class.new(url: url, request: request, response: response) if error_class
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
@@ -1,3 +1,3 @@
1
1
  module Booker
2
- VERSION = '3.2.2'
2
+ VERSION = '3.2.3'
3
3
  end
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.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-07-27 00:00:00.000000000 Z
11
+ date: 2017-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty