bookingsync-api 0.0.22 → 0.0.23

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: d266f143b5485fb802a2ca679b463bfe5114c6d2
4
- data.tar.gz: ef12933a93a4f3cda873b11003f59a53f629052d
3
+ metadata.gz: be87f9275c1ee79cf68acae5e1eccf5144f06d56
4
+ data.tar.gz: 089bc7b775c85b231e3927f4618d781ac6222521
5
5
  SHA512:
6
- metadata.gz: bc4c02905c35cc51762cec8d5a11960bda57729211b126b14584b80d8d4630c5177e6b1a6ca48dc2d880d65e7d2c02f70d4f035c85ad77e5e15c8d8ecf93fa10
7
- data.tar.gz: ef0b52ef4c204465124b13533ba29c2737773d8dd4b1bb253c5362703c1978096e280696b82646c9f233694b4b39c9065614d4ef9e1acbbd18f9dc4fd86cc3a9
6
+ metadata.gz: 42b1ae4973ea0525f49639b1dca2b22ae9471b97b253b33c2e3b5b1b429f4063685c14e8a1623b2ec09297070d62be6276998094337eb1c5e7b6b57ffe36f764
7
+ data.tar.gz: 988eaf038f553c9e5c8016c3db8b62a59adfffe7aafd21883d29a10b04092e2e1cc9455cc86f4f1682bb45aeee7feb0b81c0dd730e90c8fef55a2f951e72a659
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.2
4
- - 2.0.0
5
- - 1.9.3
3
+ - "1.9.3"
4
+ - "2.0"
5
+ - "2.1"
6
+ - "2.2"
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.0.23
6
+
7
+ - Add BookingSync::Engine::APIClient that automatically refreshes token on 401 expired responses.
8
+
5
9
  ## 0.0.22
6
10
 
7
11
  - Handle 403 responses from the API. Raises BookingSync::API::Forbidden
@@ -1,4 +1,3 @@
1
- require "bookingsync/api/middleware/authentication"
2
1
  require "bookingsync/api/middleware/logger"
3
2
  require "bookingsync/api/client/amenities"
4
3
  require "bookingsync/api/client/availabilities"
@@ -206,6 +205,8 @@ module BookingSync::API
206
205
  data = nil
207
206
  end
208
207
  options ||= {}
208
+ options[:headers] ||= {}
209
+ options[:headers]["Authorization"] = "Bearer #{token}"
209
210
 
210
211
  if options.has_key?(:query)
211
212
  if options[:query].has_key?(:ids)
@@ -227,9 +228,7 @@ module BookingSync::API
227
228
  if params = options[:query]
228
229
  req.params.update params
229
230
  end
230
- if headers = options[:headers]
231
- req.headers.update headers
232
- end
231
+ req.headers.update options[:headers]
233
232
  end
234
233
  handle_response(res)
235
234
  end
@@ -239,7 +238,6 @@ module BookingSync::API
239
238
 
240
239
  def middleware
241
240
  Faraday::RackBuilder.new do |builder|
242
- builder.use :authentication, token
243
241
  builder.use :logger, logger
244
242
  builder.adapter Faraday.default_adapter
245
243
  end
@@ -1,5 +1,5 @@
1
1
  module BookingSync
2
2
  module API
3
- VERSION = "0.0.22"
3
+ VERSION = "0.0.23"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookingsync-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Grosjean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-13 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -122,7 +122,6 @@ files:
122
122
  - lib/bookingsync/api/client/sources.rb
123
123
  - lib/bookingsync/api/client/special_offers.rb
124
124
  - lib/bookingsync/api/error.rb
125
- - lib/bookingsync/api/middleware/authentication.rb
126
125
  - lib/bookingsync/api/middleware/logger.rb
127
126
  - lib/bookingsync/api/relation.rb
128
127
  - lib/bookingsync/api/resource.rb
@@ -1,18 +0,0 @@
1
- module BookingSync::API::Middleware
2
- # Provides faraday middleware for authentication using OAuth token
3
- # We don't use default FaradayMiddleware::OAuth2 because
4
- # it adds access_token param to the URL
5
- class Authentication < Faraday::Middleware
6
- def initialize(app, token)
7
- @app = app
8
- @token = token
9
- end
10
-
11
- def call(env)
12
- env[:request_headers]["Authorization"] = "Bearer #{@token}"
13
- @app.call(env)
14
- end
15
- end
16
-
17
- Faraday::Middleware.register_middleware authentication: Authentication
18
- end