booker_ruby 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c32d18a501108616082cfd6f1c4d9a9bb77c4acf
4
- data.tar.gz: 1b518f4e5395d7a9221d34e36cb23c2cdcf42db5
3
+ metadata.gz: 088c7a05c2013cac483d93837359785744c458ce
4
+ data.tar.gz: 48ff6f27165a65c8690b3c20111a01283a4732ba
5
5
  SHA512:
6
- metadata.gz: 5c8fe78924f6479548746e2b428b97beed68012a8f4baebd628c382dc1738d31a1294cfc63ad46a881967ca8487cdf52e38aa8b0e48ce4ff1fa8a356e8b11860
7
- data.tar.gz: c3882ef8de57340214414ccdc1dd19605ea73c94ec1ba6e666fde98f4f910f1b1e9115e50c00a2bede580d692ff26c0ab6c9b6cfd66217e4d5ced3adbbf9c9be
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
- puts "BOOKER REQUEST: #{http_method} #{path} #{http_options}" if ENV['BOOKER_API_DEBUG'] == 'true'
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, "#{self.base_url}#{path}", http_options))
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
- results_from_response(booker_resources, booker_model)
86
- else
87
- booker_resources = handle_errors!(http_options, HTTParty.send(http_method, "#{self.base_url}#{path}", http_options))
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
- if booker_resources
90
- results_from_response(booker_resources, booker_model)
91
- else
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
- if self.temp_access_token && !temp_access_token_expired?
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
@@ -1,3 +1,3 @@
1
1
  module Booker
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
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: 1.4.0
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-23 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty