booker_ruby 1.8.1 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/booker/client.rb +7 -7
- data/lib/booker/errors.rb +4 -2
- 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: b87fef997d139ba93a730c4d6cb2d8958316d233
|
4
|
+
data.tar.gz: 5f2457eeb14aca8ed0d260690aaa0331b56db506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bc6460b6adc7f22525dc39915127c8d044ebb99859f42284bc0f51cce5524ca5b83c2a6da25c9eced8a47a1e2e2678047969da0d0dd0fa6bc9267b2506e5710
|
7
|
+
data.tar.gz: 9604fc0de4482c71c5bcd6fd9353dd4eba1cf48cff6c68e4ef177abcaa0c8bb4ec35f3ec9ab0a6af33cd552f23e75d3189e7c367fe540aa58d8f85c0495db219
|
data/lib/booker/client.rb
CHANGED
@@ -82,7 +82,7 @@ module Booker
|
|
82
82
|
|
83
83
|
# Allow it to retry the first time unless it is an authorization error
|
84
84
|
begin
|
85
|
-
booker_resources = handle_errors!(http_options, HTTParty.send(http_method, url, http_options))
|
85
|
+
booker_resources = handle_errors!(url, http_options, HTTParty.send(http_method, url, http_options))
|
86
86
|
rescue Booker::Error, Net::ReadTimeout => ex
|
87
87
|
if ex.is_a? Booker::InvalidApiCredentials
|
88
88
|
raise ex
|
@@ -93,9 +93,9 @@ module Booker
|
|
93
93
|
end
|
94
94
|
|
95
95
|
return results_from_response(booker_resources, booker_model) if booker_resources.present?
|
96
|
-
booker_resources = handle_errors!(http_options, HTTParty.send(http_method, url, http_options))
|
96
|
+
booker_resources = handle_errors!(url, http_options, HTTParty.send(http_method, url, http_options))
|
97
97
|
return results_from_response(booker_resources, booker_model) if booker_resources.present?
|
98
|
-
raise Booker::Error.new(http_options, booker_resources)
|
98
|
+
raise Booker::Error.new(url: url, request: http_options, response: booker_resources)
|
99
99
|
end
|
100
100
|
|
101
101
|
def full_url(path)
|
@@ -103,14 +103,14 @@ module Booker
|
|
103
103
|
uri.scheme ? path : "#{self.base_url}#{path}"
|
104
104
|
end
|
105
105
|
|
106
|
-
def handle_errors!(request, response)
|
106
|
+
def handle_errors!(url, request, response)
|
107
107
|
puts "BOOKER RESPONSE: #{response}" if ENV['BOOKER_API_DEBUG'] == 'true'
|
108
108
|
|
109
|
-
ex = Booker::Error.new(request, response)
|
109
|
+
ex = Booker::Error.new(url: url, request: request, response: response)
|
110
110
|
if ex.error.present? || !response.success?
|
111
111
|
case ex.error
|
112
112
|
when 'invalid_client'
|
113
|
-
raise Booker::InvalidApiCredentials.new(request, response)
|
113
|
+
raise Booker::InvalidApiCredentials.new(url: url, request: request, response: response)
|
114
114
|
when 'invalid access token'
|
115
115
|
get_access_token
|
116
116
|
return nil
|
@@ -157,7 +157,7 @@ module Booker
|
|
157
157
|
if (response = ex.response).present?
|
158
158
|
raise ex
|
159
159
|
else
|
160
|
-
raise Booker::InvalidApiCredentials.new(ex.request, response)
|
160
|
+
raise Booker::InvalidApiCredentials.new(url: ex.url, request: ex.request, response: response)
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
data/lib/booker/errors.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Booker
|
2
2
|
class Error < StandardError
|
3
|
-
attr_accessor :error, :description, :request, :response
|
3
|
+
attr_accessor :error, :description, :url, :request, :response
|
4
4
|
|
5
|
-
def initialize(request
|
5
|
+
def initialize(url: nil, request: nil, response: nil)
|
6
6
|
if request.present?
|
7
7
|
self.request = request
|
8
8
|
end
|
@@ -12,6 +12,8 @@ module Booker
|
|
12
12
|
self.error = response['error'] || response['ErrorMessage']
|
13
13
|
self.description = response['error_description']
|
14
14
|
end
|
15
|
+
|
16
|
+
self.url = url
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
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: 1.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|