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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 264eec7506c4257374c9c315ee8e9f85812fc845
4
- data.tar.gz: 9687012147f9c6a73cc0590f91672625e2ae54ab
3
+ metadata.gz: 0b84f18fee1c0bb65b0fe3254ea67774733e4180
4
+ data.tar.gz: 0f674a5ecd51872697e297847d997393f26a22af
5
5
  SHA512:
6
- metadata.gz: 6483a097e8dfef5684c9cc68cd90f4e1cb7a57fa9aac9a56b74a3b7c0c5fb95f398199d0158a4deeb936b76166690cb5a11aa319e9c9b27ba30ff6d9e175581f
7
- data.tar.gz: 3929e52aade312c104db482ffb6cd3242107608b7eefbb21807c15b9808d3d9f8d6d47a0b11e694f996f9995985edc504b4da93abec501aa707bef8477f56568
6
+ metadata.gz: 1578c40b762f651464433aa0c6acd422ebd6ca6d0e27419c53d99871ecc5e509c537ebea071a49c95923c438b309e33312df00b834a8361380339f4aa3d5b75e
7
+ data.tar.gz: 0e16ae3129d5ddfbcc0aa1b5d1ce569d1aa376c08b2ddbb7dc185e9b73eb944bff333c951a172a51799523e50b75ac5c6faf11ec810bbe5965ace379c41fb589
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bridge_api (0.0.1)
4
+ bridge_api (0.0.2)
5
5
  faraday (~> 0.9.0)
6
6
  faraday_middleware (~> 0.9.0)
7
7
  footrest (>= 0.5.1)
@@ -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[:basic_api_token]
56
- faraday.headers[:authorization] = "Basic #{config[:basic_api_token]}"
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 token provided'
61
+ raise 'No api authorization provided'
61
62
  end
62
63
  end
63
64
  end
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.0.2' unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.0.3' unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -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", basic_api_token: "test_token")
6
- expect(client.connection.headers['Authorization']).to(eq("Basic test_token"))
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer