armor_payments 0.1.0 → 0.1.1

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: e9ae49ac2caa04bfb73d0346bd9c92b84fe4f0e1
4
- data.tar.gz: 29ea37edd11f94a17a774d916313d595aee355ee
3
+ metadata.gz: 7cf2945e84365c34ab146858819d477cbfcf3bf7
4
+ data.tar.gz: c37ef7519e27b2e4e5b67003728d719b7e0cc266
5
5
  SHA512:
6
- metadata.gz: 00d147bcaf1634320188c2baa9a01c1667646a7a44a6dfc863ed1b874069069e649f9b36b426f047fb7d65c932861395e3c1a8f2c9ce601225ee407559ef1624
7
- data.tar.gz: 303ddf688969c99d82361b6f53166f3fb969a4640583061a425b6410e4473578e4e69c152027d797bd2d03a9b454f59465e24d5113a3c43b0dbdf417fc8e208d
6
+ metadata.gz: 52c0bfedf73fcd7dc0afe3aefb84a2a4255b47a7d9d2afbead8a82ab03e180f1cee757a90360dfcba2d9a7e9cf71107a511466d16cb9cc855652cd7a4b4d0f3d
7
+ data.tar.gz: 36fbfb8cafd38e6c8c6b44d9bfe60b291820483243e488802054a2fbdd47bbc4f56bd09b652f22eed6b5a2852cc9d836ba965b08c714df6833377085ef8ea287
data/README.md CHANGED
@@ -25,23 +25,35 @@ require 'armor_payments'
25
25
 
26
26
  client = ArmorPayments::API.new 'your-key', 'your-secret', should_use_sandbox
27
27
 
28
- # There are three top-level resources: accounts, users, and orders
29
- # Querying users and orders requires an account_id
28
+ # There are three top-level resources: accounts, partner, and shipmentcarriers
30
29
 
31
30
  client.accounts.all
32
31
  client.accounts.get(account_id)
33
32
 
33
+ client.partner.get(partner_id)
34
+
35
+ client.shipmentcarriers.all
36
+ client.shipmentcarriers.get(carrier_id)
37
+
38
+ # For convenience, orders and users can be called as top-level resources,
39
+ # but they can also be chained from accounts
34
40
  client.users(account_id).all
35
41
  client.users(account_id).get(user_id)
36
42
 
37
43
  client.orders(account_id).all
38
44
  client.orders(account_id).get(order_id)
39
45
 
40
- # From accounts, we chain bank accounts
46
+ # From accounts, we chain bank accounts, orders, and users
41
47
 
42
48
  client.accounts.bankaccounts(account_id).all
43
49
  client.accounts.bankaccounts(account_id).get(bank_account_id)
44
50
 
51
+ client.accounts.orders(account_id).all
52
+ client.accounts.orders(account_id).get(order_id)
53
+
54
+ client.accounts.users(account_id).all
55
+ client.accounts.users(account_id).get(user_id)
56
+
45
57
  # From orders, many things chain: documents, notes, disputes, shipments, payment instructions, order events
46
58
 
47
59
  client.orders(account_id).documents(order_id).all
@@ -83,6 +95,10 @@ client.orders(account_id).disputes(order_id).offers(dispute_id).
83
95
  notes(offer_id).all
84
96
  client.orders(account_id).disputes(order_id).offers(dispute_id).
85
97
  notes(offer_id).get(note_id)
98
+
99
+ # From partner, you can chain the accounts and users associated with your partner account
100
+ partner.accounts(partner_id).all()
101
+ partner.users(partner_id).all()
86
102
  ```
87
103
 
88
104
  Some of the resource endpoints support Create/Update `POST` operations, and this client aims to support those as well:
@@ -93,6 +109,8 @@ client.accounts.update(account_id, your_data)
93
109
 
94
110
  client.accounts.bankaccounts(account_id).create(your_data)
95
111
 
112
+ client.accounts.users(account_id).authentications(user_id).create(your_data)
113
+
96
114
  client.orders(account_id).create(your_data)
97
115
 
98
116
  client.orders(account_id).shipments(order_id).create(your_data)
@@ -15,5 +15,9 @@ module ArmorPayments
15
15
  ArmorPayments::BankAccounts.new(host, authenticator, uri(account_id))
16
16
  end
17
17
 
18
+ def users account_id
19
+ ArmorPayments::Users.new(host, authenticator, uri(account_id))
20
+ end
21
+
18
22
  end
19
23
  end
@@ -0,0 +1,10 @@
1
+ module ArmorPayments
2
+ class Authentications < Resource
3
+
4
+ def create data
5
+ headers = authenticator.secure_headers 'post', uri
6
+ request :post, { path: uri, headers: headers, body: JSON.generate(data) }
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module ArmorPayments
2
+ class Milestones < Resource
3
+
4
+ end
5
+ end
@@ -15,6 +15,10 @@ module ArmorPayments
15
15
  ArmorPayments::Documents.new(host, authenticator, uri(order_id))
16
16
  end
17
17
 
18
+ def milestones order_id
19
+ ArmorPayments::Milestones.new(host, authenticator, uri(order_id))
20
+ end
21
+
18
22
  def notes order_id
19
23
  ArmorPayments::Notes.new(host, authenticator, uri(order_id))
20
24
  end
@@ -0,0 +1,19 @@
1
+ module ArmorPayments
2
+ class Partner < Resource
3
+
4
+ # Attempting to chain from the Accounts resource returned here will work
5
+ # with .all(). Attempting to chain with other methods (for example, with
6
+ # .get(account_id)) will result in a 404.
7
+ def accounts partner_id
8
+ ArmorPayments::Accounts.new(host, authenticator, uri(partner_id))
9
+ end
10
+
11
+ # Attempting to chain from the Users resource returned here will work
12
+ # with .all(). Attempting to chain with other methods (for example, with
13
+ # .get(user_id)) will result in a 404.
14
+ def users partner_id
15
+ ArmorPayments::Users.new(host, authenticator, uri(partner_id))
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module ArmorPayments
2
+ class ShipmentCarriers < Resource
3
+ end
4
+ end
@@ -6,5 +6,9 @@ module ArmorPayments
6
6
  request :post, { path: uri(user_id), headers: headers, body: JSON.generate(data) }
7
7
  end
8
8
 
9
+ def authentications user_id
10
+ ArmorPayments::Authentications.new(host, authenticator, uri(user_id))
11
+ end
12
+
9
13
  end
10
14
  end
@@ -3,13 +3,17 @@ require 'json'
3
3
  require 'armor_payments/authenticator'
4
4
  require 'armor_payments/api/resource'
5
5
  require 'armor_payments/api/accounts'
6
+ require 'armor_payments/api/authentications'
6
7
  require 'armor_payments/api/orders'
7
8
  require 'armor_payments/api/documents'
9
+ require 'armor_payments/api/milestones'
8
10
  require 'armor_payments/api/notes'
9
11
  require 'armor_payments/api/disputes'
10
12
  require 'armor_payments/api/offers'
13
+ require 'armor_payments/api/partner'
11
14
  require 'armor_payments/api/users'
12
15
  require 'armor_payments/api/paymentinstructions'
16
+ require 'armor_payments/api/shipmentcarriers'
13
17
  require 'armor_payments/api/shipments'
14
18
  require 'armor_payments/api/orderevents'
15
19
  require 'armor_payments/api/bankaccounts'
@@ -36,6 +40,14 @@ module ArmorPayments
36
40
  ArmorPayments::Orders.new(armor_host, authenticator, accounts.uri(account_id))
37
41
  end
38
42
 
43
+ def partner
44
+ @partner ||= ArmorPayments::Partner.new(armor_host, authenticator, '')
45
+ end
46
+
47
+ def shipmentcarriers
48
+ @shipmentcarriers ||= ArmorPayments::ShipmentCarriers.new(armor_host, authenticator, '')
49
+ end
50
+
39
51
  def users account_id
40
52
  ArmorPayments::Users.new(armor_host, authenticator, accounts.uri(account_id))
41
53
  end
@@ -1,3 +1,3 @@
1
1
  module ArmorPayments
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -8,18 +8,18 @@ module ArmorPayments
8
8
 
9
9
  describe "#uri" do
10
10
  it "returns '/accounts' if given no id" do
11
- accounts.uri.should == '/accounts'
11
+ expect(accounts.uri).to eq '/accounts'
12
12
  end
13
13
 
14
14
  it "returns '/accounts/:id' if given an id" do
15
- accounts.uri(456).should == '/accounts/456'
15
+ expect(accounts.uri(456)).to eq '/accounts/456'
16
16
  end
17
17
  end
18
18
 
19
19
  describe "#create" do
20
20
 
21
21
  it "makes POST with /accounts and JSONified data" do
22
- accounts.should_receive(:request).with( :post, hash_including(path: '/accounts', body: '{"name":"Bobby Lee"}'))
22
+ expect(accounts).to receive(:request).with( :post, hash_including(path: '/accounts', body: '{"name":"Bobby Lee"}'))
23
23
  accounts.create({ 'name' => 'Bobby Lee'})
24
24
  end
25
25
 
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ module ArmorPayments
4
+ describe Authentications do
5
+ let(:authenticator) { Authenticator.new('my-api-key', 'my-secret-code') }
6
+ let(:host) { 'https://sandbox.armorpayments.com' }
7
+ let(:authentications) { Authentications.new(host, authenticator, '/accounts/1234/users/2345') }
8
+
9
+ describe "#uri" do
10
+ it "returns '/accounts/:aid/users/:uid/authentications' if given no id" do
11
+ expect(authentications.uri).to eq '/accounts/1234/users/2345/authentications'
12
+ end
13
+
14
+ it "returns '/accounts/:aid/users/:uid/authentications/:auth_id' if given an id" do
15
+ expect(authentications.uri(3456)).to eq '/accounts/1234/users/2345/authentications/3456'
16
+ end
17
+ end
18
+
19
+ describe "#create" do
20
+ it "makes POST with the right uri and JSONified data" do
21
+ expect(authentications).to receive(:request).with( :post, hash_including(path: '/accounts/1234/users/2345/authentications', body: '{"uri":"/accounts/1234/orders/5678"}'))
22
+ authentications.create({ 'uri' => '/accounts/1234/orders/5678'})
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,11 +8,11 @@ module ArmorPayments
8
8
 
9
9
  describe "#uri" do
10
10
  it "returns '/accounts/:aid/orders/:oid/disputes' if given no id" do
11
- disputes.uri.should == '/accounts/1234/orders/56/disputes'
11
+ expect(disputes.uri).to eq '/accounts/1234/orders/56/disputes'
12
12
  end
13
13
 
14
14
  it "returns '/accounts/:aid/disputes/:dispute_id' if given an id" do
15
- disputes.uri(78).should == '/accounts/1234/orders/56/disputes/78'
15
+ expect(disputes.uri(78)).to eq '/accounts/1234/orders/56/disputes/78'
16
16
  end
17
17
  end
18
18
 
@@ -9,7 +9,7 @@ module ArmorPayments
9
9
  describe "#create" do
10
10
 
11
11
  it "makes POST with the right uri and JSONified data" do
12
- documents.should_receive(:request).with( :post, hash_including(path: '/accounts/123/orders/456/documents', body: '{"name":"Bobby Lee"}'))
12
+ expect(documents).to receive(:request).with( :post, hash_including(path: '/accounts/123/orders/456/documents', body: '{"name":"Bobby Lee"}'))
13
13
  documents.create({ 'name' => 'Bobby Lee'})
14
14
  end
15
15
 
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ module ArmorPayments
4
+ describe Milestones do
5
+ let(:authenticator) { Authenticator.new('my-api-key', 'my-secret-code') }
6
+ let(:host) { 'https://sandbox.armorpayments.com' }
7
+ let(:milestones) { Milestones.new(host, authenticator, '/accounts/1234/orders/56') }
8
+
9
+ describe "#uri" do
10
+ it "returns '/accounts/:aid/orders/:oid/milestones' if given no id" do
11
+ expect(milestones.uri).to eq '/accounts/1234/orders/56/milestones'
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -9,7 +9,7 @@ module ArmorPayments
9
9
  describe "#create" do
10
10
 
11
11
  it "makes POST with the right uri and JSONified data" do
12
- notes.should_receive(:request).with( :post, hash_including(path: '/accounts/123/orders/456/notes', body: '{"name":"Bobby Lee"}'))
12
+ expect(notes).to receive(:request).with( :post, hash_including(path: '/accounts/123/orders/456/notes', body: '{"name":"Bobby Lee"}'))
13
13
  notes.create({ 'name' => 'Bobby Lee'})
14
14
  end
15
15
 
@@ -8,7 +8,7 @@ module ArmorPayments
8
8
 
9
9
  describe "#update" do
10
10
  it "makes POST with the right uri and JSONified data" do
11
- offers.should_receive(:request).with(
11
+ expect(offers).to receive(:request).with(
12
12
  :post,
13
13
  hash_including(path: '/accounts/1234/offers/90', body: '{"name":"Bobby Lee"}')
14
14
  )
@@ -8,17 +8,17 @@ module ArmorPayments
8
8
 
9
9
  describe "#uri" do
10
10
  it "returns '/accounts/:aid/orders' if given no id" do
11
- orders.uri.should == '/accounts/1234/orders'
11
+ expect(orders.uri).to eq '/accounts/1234/orders'
12
12
  end
13
13
 
14
14
  it "returns '/accounts/:aid/orders/:order_id' if given an id" do
15
- orders.uri(456).should == '/accounts/1234/orders/456'
15
+ expect(orders.uri(456)).to eq '/accounts/1234/orders/456'
16
16
  end
17
17
  end
18
18
 
19
19
  describe "#update" do
20
20
  it "makes POST with the right uri and JSONified data" do
21
- orders.should_receive(:request).with(
21
+ expect(orders).to receive(:request).with(
22
22
  :post,
23
23
  hash_including(path: '/accounts/1234/orders/90', body: '{"name":"Bobby Lee"}')
24
24
  )
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ module ArmorPayments
4
+ describe Partner do
5
+ let(:authenticator) { Authenticator.new('my-api-key', 'my-secret-code') }
6
+ let(:host) { 'https://sandbox.armorpayments.com' }
7
+ let(:partner) { Partner.new(host, authenticator, '') }
8
+
9
+ describe "#uri" do
10
+ it "returns '/partner' if given no id" do
11
+ expect(partner.uri).to eq '/partner'
12
+ end
13
+
14
+ it "returns '/partner/:id' if given an id" do
15
+ expect(partner.uri(456)).to eq '/partner/456'
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -2,7 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  module ArmorPayments
4
4
  describe Resource do
5
- let(:authenticator) { Authenticator.new('my-api-key', 'my-secret-code') }
5
+ let(:api_key) { 'my-api-key' }
6
+ let(:api_secret) { 'my-secret-code' }
7
+ let(:authenticator) { Authenticator.new(api_key, api_secret) }
6
8
  let(:host) { 'https://sandbox.armorpayments.com' }
7
9
  let(:uri_root) { '/wibble/123' }
8
10
  let(:resource) { Resource.new(host, authenticator, uri_root) }
@@ -10,43 +12,45 @@ module ArmorPayments
10
12
 
11
13
  describe "#uri" do
12
14
  it "returns '/%{uri_root}/resource_name' if given no id" do
13
- resource.uri.should == '/wibble/123/resource'
15
+ expect(resource.uri).to eq '/wibble/123/resource'
14
16
  end
15
17
 
16
18
  it "returns '/%{uri_root}/resource_name/:id' if given an id" do
17
- resource.uri(456).should == '/wibble/123/resource/456'
19
+ expect(resource.uri(456)).to eq '/wibble/123/resource/456'
18
20
  end
19
21
  end
20
22
 
21
23
  describe "#request" do
22
24
  context "on a response with a JSON body" do
23
25
  it "returns the parsed JSON body" do
24
- resource.connection.stub(:get).and_return(successful_response)
26
+ allow(resource.connection).to receive(:get).and_return(successful_response)
25
27
  response = resource.request('get', {})
26
- response.body.should == { 'whee' => 42 }
28
+ expect(response.body).to eq 'whee' => 42
27
29
  end
28
30
  end
29
31
 
30
32
  context "on a response without JSON" do
31
33
  it "returns the full response object" do
32
34
  failed_response = Excon::Response.new(status: 502, body: 'Gateway Timeout')
33
- resource.connection.stub(:get).and_return(failed_response)
35
+ allow(resource.connection).to receive(:get).and_return(failed_response)
34
36
  response = resource.request('get', {})
35
- response.body.should == 'Gateway Timeout'
37
+ expect(response.body).to eq 'Gateway Timeout'
36
38
  end
37
39
  end
38
40
  end
39
41
 
40
42
  context "smoketest" do
43
+ let(:given_time) { Time.new(2014, 2, 22, 12, 0, 0, "+00:00") }
44
+
41
45
  describe "#all" do
42
46
  it "queries the host for all of the resources, with approprate headers" do
43
- Timecop.freeze(2014, 2, 22, 12, 0, 0) do
44
- resource.connection.should_receive(:get).with({
47
+ Timecop.freeze(given_time) do
48
+ expect(resource.connection).to receive(:get).with({
45
49
  path: '/wibble/123/resource',
46
50
  headers: {
47
- "X_ARMORPAYMENTS_APIKEY" => "my-api-key",
48
- "X_ARMORPAYMENTS_REQUESTTIMESTAMP" => "2014-02-22T17:00:00Z",
49
- "X_ARMORPAYMENTS_SIGNATURE" => "ec41629dc204b449c71bf89d1be4630f5353e37869197f5a926539f6fc676ebcccdb5426fb3f01a01fa7dc9551d38d152e41294a5147b15e460d09ff60cf1562"
51
+ "x-armorpayments-apikey" => "my-api-key",
52
+ "x-armorpayments-requesttimestamp" => given_time.utc.iso8601,
53
+ "x-armorpayments-signature" => Digest::SHA512.hexdigest("#{api_secret}:GET:/wibble/123/resource:#{given_time.utc.iso8601}")
50
54
  }
51
55
  }).and_return(successful_response)
52
56
 
@@ -57,13 +61,13 @@ module ArmorPayments
57
61
 
58
62
  describe "#get" do
59
63
  it "queries the host for a specific resource, with approprate headers" do
60
- Timecop.freeze(2014, 2, 22, 12, 0, 0) do
61
- resource.connection.should_receive(:get).with({
64
+ Timecop.freeze(given_time) do
65
+ expect(resource.connection).to receive(:get).with({
62
66
  path: '/wibble/123/resource/456',
63
67
  headers: {
64
- "X_ARMORPAYMENTS_APIKEY" => "my-api-key",
65
- "X_ARMORPAYMENTS_REQUESTTIMESTAMP" => "2014-02-22T17:00:00Z",
66
- "X_ARMORPAYMENTS_SIGNATURE" => "48886620cfebb95ffd9ee351f4f68d4f103a8f4bdc0e3301f7ee709ec2cf3c19588ae1b67aa8ee38305de802651fb10093cf1af40f467ac936185d551a58a844"
68
+ "x-armorpayments-apikey" => "my-api-key",
69
+ "x-armorpayments-requesttimestamp" => given_time.utc.iso8601,
70
+ "x-armorpayments-signature" => Digest::SHA512.hexdigest("#{api_secret}:GET:/wibble/123/resource/456:#{given_time.utc.iso8601}")
67
71
  }
68
72
  }).and_return(successful_response)
69
73
 
@@ -7,12 +7,12 @@ module ArmorPayments
7
7
  let(:users) { Users.new(host, authenticator, '/accounts/1234') }
8
8
 
9
9
  describe "#uri" do
10
- it "returns '/users' if given no id" do
11
- users.uri.should == '/accounts/1234/users'
10
+ it "returns 'accounts/:aid/users' if given no id" do
11
+ expect(users.uri).to eq '/accounts/1234/users'
12
12
  end
13
13
 
14
- it "returns '/users/:id' if given an id" do
15
- users.uri(456).should == '/accounts/1234/users/456'
14
+ it "returns 'accounts/:aid/users/:id' if given an id" do
15
+ expect(users.uri(456)).to eq '/accounts/1234/users/456'
16
16
  end
17
17
  end
18
18
 
@@ -7,15 +7,15 @@ module ArmorPayments
7
7
  describe "#armor_host" do
8
8
  context "in sandbox mode" do
9
9
  it "returns https://sandbox.armorpayments.com" do
10
- client.sandbox.should be_true
11
- client.armor_host.should == "https://sandbox.armorpayments.com"
10
+ expect(client.sandbox).to be true
11
+ expect(client.armor_host).to eq "https://sandbox.armorpayments.com"
12
12
  end
13
13
  end
14
14
 
15
15
  context "*not* in sandbox mode" do
16
16
  it "returns https://api.armorpayments.com" do
17
17
  client.sandbox = false
18
- client.armor_host.should == "https://api.armorpayments.com"
18
+ expect(client.armor_host).to eq "https://api.armorpayments.com"
19
19
  end
20
20
  end
21
21
  end
@@ -3,46 +3,50 @@ require 'armor_payments/authenticator'
3
3
 
4
4
  module ArmorPayments
5
5
  describe Authenticator do
6
- let(:authenticator) { Authenticator.new('my-api-key', 'my-secret-code') }
6
+ let(:api_key) { 'my-api-key' }
7
+ let(:api_secret) { 'my-secret-code' }
8
+ let(:authenticator) { Authenticator.new(api_key, api_secret) }
9
+ let(:given_time) { Time.new(2014, 2, 22, 12, 0, 0, "+00:00") }
7
10
 
8
11
  describe "#current_timestamp" do
9
12
  it "returns the current time in iso8601 format" do
10
- Timecop.freeze(2014, 2, 22, 12, 0, 0) do
11
- authenticator.current_timestamp.should == '2014-02-22T17:00:00Z'
13
+ Timecop.freeze(given_time) do
14
+ expect(authenticator.current_timestamp).to eq '2014-02-22T12:00:00Z'
12
15
  end
13
16
  end
14
17
  end
15
18
 
16
19
  describe "#request_signature" do
17
20
  it "hands a concatenated string encompassing the secret, request method, uri, and date to the digest service" do
18
- Timecop.freeze(2014, 2, 22, 12, 0, 0) do
21
+ Timecop.freeze(given_time) do
19
22
  the_beast = "#{authenticator.api_secret}:GET:/accounts:#{authenticator.current_timestamp}"
20
- Digest::SHA512.should_receive(:hexdigest).with(the_beast)
23
+ expect(Digest::SHA512).to receive(:hexdigest).with(the_beast)
21
24
  authenticator.request_signature('get', '/accounts')
22
25
  end
23
26
  end
24
27
 
25
28
  it "returns a SHA512 hash value" do
26
- Timecop.freeze(2014, 2, 22, 12, 0, 0) do
27
- authenticator.request_signature("get", "/accounts").should ==
28
- "777990373678937074c1b357d632e0ea3439d0e834e573c03076ee557f526565f9ac2b38483b3e41024b96ec2644d60b4f70f0d9c760b2ebeb9827f9b335d069"
29
+ Timecop.freeze(given_time) do
30
+ expect(authenticator.request_signature("get", "/accounts")).to eq(
31
+ Digest::SHA512.hexdigest "#{api_secret}:GET:/accounts:#{given_time.utc.iso8601}"
32
+ )
29
33
  end
30
34
  end
31
35
  end
32
36
 
33
37
  describe "#secure_headers" do
34
38
  it "returns a hash with the required headers in" do
35
- required_headers = %w( X_ARMORPAYMENTS_APIKEY X_ARMORPAYMENTS_REQUESTTIMESTAMP X_ARMORPAYMENTS_SIGNATURE )
36
- authenticator.secure_headers('get', '/accounts').keys.sort.should == required_headers.sort
39
+ required_headers = %w( x-armorpayments-apikey x-armorpayments-requesttimestamp x-armorpayments-signature )
40
+ expect(authenticator.secure_headers('get', '/accounts').keys.sort).to eq required_headers.sort
37
41
  end
38
42
 
39
43
  it "assigns the correct value for each of the headers" do
40
- Timecop.freeze(2014, 2, 22, 12, 0, 0) do
41
- authenticator.secure_headers('get', '/accounts').should == {
42
- "X_ARMORPAYMENTS_APIKEY" => "my-api-key",
43
- "X_ARMORPAYMENTS_SIGNATURE" => "777990373678937074c1b357d632e0ea3439d0e834e573c03076ee557f526565f9ac2b38483b3e41024b96ec2644d60b4f70f0d9c760b2ebeb9827f9b335d069",
44
- "X_ARMORPAYMENTS_REQUESTTIMESTAMP" => "2014-02-22T17:00:00Z"
45
- }
44
+ Timecop.freeze(given_time) do
45
+ expect(authenticator.secure_headers('get', '/accounts')).to eq({
46
+ "x-armorpayments-apikey" => api_key,
47
+ "x-armorpayments-signature" => Digest::SHA512.hexdigest("#{api_secret}:GET:/accounts:#{given_time.utc.iso8601}"),
48
+ "x-armorpayments-requesttimestamp" => given_time.utc.iso8601
49
+ })
46
50
  end
47
51
  end
48
52
  end
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,6 @@ Timecop.safe_mode = true
6
6
 
7
7
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
8
  RSpec.configure do |config|
9
- config.treat_symbols_as_metadata_keys_with_true_values = true
10
9
  config.run_all_when_everything_filtered = true
11
10
  config.filter_run :focus
12
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: armor_payments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-03 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,25 +142,32 @@ files:
142
142
  - lib/armor_payments.rb
143
143
  - lib/armor_payments/api.rb
144
144
  - lib/armor_payments/api/accounts.rb
145
+ - lib/armor_payments/api/authentications.rb
145
146
  - lib/armor_payments/api/bankaccounts.rb
146
147
  - lib/armor_payments/api/disputes.rb
147
148
  - lib/armor_payments/api/documents.rb
149
+ - lib/armor_payments/api/milestones.rb
148
150
  - lib/armor_payments/api/notes.rb
149
151
  - lib/armor_payments/api/offers.rb
150
152
  - lib/armor_payments/api/orderevents.rb
151
153
  - lib/armor_payments/api/orders.rb
154
+ - lib/armor_payments/api/partner.rb
152
155
  - lib/armor_payments/api/paymentinstructions.rb
153
156
  - lib/armor_payments/api/resource.rb
157
+ - lib/armor_payments/api/shipmentcarriers.rb
154
158
  - lib/armor_payments/api/shipments.rb
155
159
  - lib/armor_payments/api/users.rb
156
160
  - lib/armor_payments/authenticator.rb
157
161
  - lib/armor_payments/version.rb
158
162
  - spec/armor_payments/api/accounts_spec.rb
163
+ - spec/armor_payments/api/authentications_spec.rb
159
164
  - spec/armor_payments/api/disputes_spec.rb
160
165
  - spec/armor_payments/api/documents_spec.rb
166
+ - spec/armor_payments/api/milestones_spec.rb
161
167
  - spec/armor_payments/api/notes_spec.rb
162
168
  - spec/armor_payments/api/offers_spec.rb
163
169
  - spec/armor_payments/api/orders_spec.rb
170
+ - spec/armor_payments/api/partner_spec.rb
164
171
  - spec/armor_payments/api/resource_spec.rb
165
172
  - spec/armor_payments/api/users_spec.rb
166
173
  - spec/armor_payments/api_spec.rb
@@ -192,11 +199,14 @@ specification_version: 4
192
199
  summary: Ruby gem for interacting with Armor Payments.
193
200
  test_files:
194
201
  - spec/armor_payments/api/accounts_spec.rb
202
+ - spec/armor_payments/api/authentications_spec.rb
195
203
  - spec/armor_payments/api/disputes_spec.rb
196
204
  - spec/armor_payments/api/documents_spec.rb
205
+ - spec/armor_payments/api/milestones_spec.rb
197
206
  - spec/armor_payments/api/notes_spec.rb
198
207
  - spec/armor_payments/api/offers_spec.rb
199
208
  - spec/armor_payments/api/orders_spec.rb
209
+ - spec/armor_payments/api/partner_spec.rb
200
210
  - spec/armor_payments/api/resource_spec.rb
201
211
  - spec/armor_payments/api/users_spec.rb
202
212
  - spec/armor_payments/api_spec.rb