bridge_api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bridge_api/client.rb +4 -3
- data/lib/bridge_api/version.rb +1 -1
- data/spec/bridge_api/client_spec.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b84f18fee1c0bb65b0fe3254ea67774733e4180
|
4
|
+
data.tar.gz: 0f674a5ecd51872697e297847d997393f26a22af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1578c40b762f651464433aa0c6acd422ebd6ca6d0e27419c53d99871ecc5e509c537ebea071a49c95923c438b309e33312df00b834a8361380339f4aa3d5b75e
|
7
|
+
data.tar.gz: 0e16ae3129d5ddfbcc0aa1b5d1ce569d1aa376c08b2ddbb7dc185e9b73eb944bff333c951a172a51799523e50b75ac5c6faf11ec810bbe5965ace379c41fb589
|
data/Gemfile.lock
CHANGED
data/lib/bridge_api/client.rb
CHANGED
@@ -6,6 +6,7 @@ require 'footrest/http_error'
|
|
6
6
|
require 'footrest/pagination'
|
7
7
|
require 'footrest/follow_redirects'
|
8
8
|
require 'footrest/parse_json'
|
9
|
+
require 'base64'
|
9
10
|
|
10
11
|
|
11
12
|
module BridgeAPI
|
@@ -52,12 +53,12 @@ module BridgeAPI
|
|
52
53
|
faraday.headers[:accept] = "application/json"
|
53
54
|
faraday.headers[:authorization] = "Bearer #{config[:token]}" if config[:token]
|
54
55
|
faraday.headers[:user_agent] = "Footrest"
|
55
|
-
if config[:
|
56
|
-
faraday.headers[:authorization] =
|
56
|
+
if config[:api_key] && config[:api_secret]
|
57
|
+
faraday.headers[:authorization] = 'Basic ' + Base64.strict_encode64("#{config[:api_key]}:#{config[:api_secret]}")
|
57
58
|
elsif config[:token]
|
58
59
|
faraday.headers[:authorization] = "Bearer #{config[:token]}"
|
59
60
|
else
|
60
|
-
raise 'No authorization
|
61
|
+
raise 'No api authorization provided'
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
data/lib/bridge_api/version.rb
CHANGED
@@ -2,8 +2,13 @@
|
|
2
2
|
describe BridgeAPI::Client do
|
3
3
|
|
4
4
|
it 'should set the auth header to basic auth' do
|
5
|
-
client = BridgeAPI::Client.new(prefix: "https://www.fake.com",
|
6
|
-
expect(client.connection.headers['Authorization']).to(eq("Basic
|
5
|
+
client = BridgeAPI::Client.new(prefix: "https://www.fake.com", api_key: "fake_token", api_secret: "fake_secret")
|
6
|
+
expect(client.connection.headers['Authorization']).to(eq("Basic ZmFrZV90b2tlbjpmYWtlX3NlY3JldA=="))
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should set the auth header to bearer auth' do
|
10
|
+
client = BridgeAPI::Client.new(prefix: "https://www.fake.com", token: "test_token")
|
11
|
+
expect(client.connection.headers['Authorization']).to(eq("Bearer test_token"))
|
7
12
|
end
|
8
13
|
|
9
14
|
|