bookingsync-api 0.0.22 → 0.0.23
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/.travis.yml +4 -3
- data/CHANGELOG.md +4 -0
- data/lib/bookingsync/api/client.rb +3 -5
- data/lib/bookingsync/api/version.rb +1 -1
- metadata +2 -3
- data/lib/bookingsync/api/middleware/authentication.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be87f9275c1ee79cf68acae5e1eccf5144f06d56
|
4
|
+
data.tar.gz: 089bc7b775c85b231e3927f4618d781ac6222521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42b1ae4973ea0525f49639b1dca2b22ae9471b97b253b33c2e3b5b1b429f4063685c14e8a1623b2ec09297070d62be6276998094337eb1c5e7b6b57ffe36f764
|
7
|
+
data.tar.gz: 988eaf038f553c9e5c8016c3db8b62a59adfffe7aafd21883d29a10b04092e2e1cc9455cc86f4f1682bb45aeee7feb0b81c0dd730e90c8fef55a2f951e72a659
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
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.
|
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:
|
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
|