booker_ruby 1.4.0 → 1.5.0
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 +12 -17
- 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: 088c7a05c2013cac483d93837359785744c458ce
|
4
|
+
data.tar.gz: 48ff6f27165a65c8690b3c20111a01283a4732ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3318fe007b44a8ff692226cb431e927622f5f47f87fbf9ff7378ad739158aa1140b658b5dd0328c1b287360fba47d3cfd94760c209f3f31be5f25e5ad53eb64a
|
7
|
+
data.tar.gz: 3b69c38ea9c2392dae8974d6be4658c536ff6f290a38da1f4adbc1ec963dbee7027b2d4739eed64b88cf7e0c6e5d93f04a31183a29b67e9d0cc0e6be6abbf788
|
data/lib/booker/client.rb
CHANGED
@@ -67,11 +67,12 @@ module Booker
|
|
67
67
|
|
68
68
|
def get_booker_resources(http_method, path, params=nil, body=nil, booker_model=nil)
|
69
69
|
http_options = request_options(params, body)
|
70
|
-
|
70
|
+
url = full_url(path)
|
71
|
+
puts "BOOKER REQUEST: #{http_method} #{url} #{http_options}" if ENV['BOOKER_API_DEBUG'] == 'true'
|
71
72
|
|
72
73
|
# Allow it to retry the first time unless it is an authorization error
|
73
74
|
begin
|
74
|
-
booker_resources = handle_errors!(http_options, HTTParty.send(http_method,
|
75
|
+
booker_resources = handle_errors!(http_options, HTTParty.send(http_method, url, http_options))
|
75
76
|
rescue Booker::Error, Net::ReadTimeout => ex
|
76
77
|
if ex.is_a? Booker::InvalidApiCredentials
|
77
78
|
raise ex
|
@@ -81,17 +82,15 @@ module Booker
|
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
|
-
if booker_resources
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
return results_from_response(booker_resources, booker_model) if booker_resources.present?
|
86
|
+
booker_resources = handle_errors!(http_options, HTTParty.send(http_method, url, http_options))
|
87
|
+
return results_from_response(booker_resources, booker_model) if booker_resources.present?
|
88
|
+
raise Booker::Error.new(http_options, booker_resources)
|
89
|
+
end
|
88
90
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
raise Booker::Error.new(http_options, booker_resources)
|
93
|
-
end
|
94
|
-
end
|
91
|
+
def full_url(path)
|
92
|
+
uri = URI(path)
|
93
|
+
uri.scheme ? path : "#{self.base_url}#{path}"
|
95
94
|
end
|
96
95
|
|
97
96
|
def handle_errors!(request, response)
|
@@ -114,11 +113,7 @@ module Booker
|
|
114
113
|
end
|
115
114
|
|
116
115
|
def access_token
|
117
|
-
|
118
|
-
self.temp_access_token
|
119
|
-
else
|
120
|
-
get_access_token
|
121
|
-
end
|
116
|
+
(self.temp_access_token && !temp_access_token_expired?) ? self.temp_access_token : get_access_token
|
122
117
|
end
|
123
118
|
|
124
119
|
def access_token_options
|
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.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|