armor_payments 0.1.0 → 0.1.1
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/README.md +21 -3
- data/lib/armor_payments/api/accounts.rb +4 -0
- data/lib/armor_payments/api/authentications.rb +10 -0
- data/lib/armor_payments/api/milestones.rb +5 -0
- data/lib/armor_payments/api/orders.rb +4 -0
- data/lib/armor_payments/api/partner.rb +19 -0
- data/lib/armor_payments/api/shipmentcarriers.rb +4 -0
- data/lib/armor_payments/api/users.rb +4 -0
- data/lib/armor_payments/api.rb +12 -0
- data/lib/armor_payments/version.rb +1 -1
- data/spec/armor_payments/api/accounts_spec.rb +3 -3
- data/spec/armor_payments/api/authentications_spec.rb +26 -0
- data/spec/armor_payments/api/disputes_spec.rb +2 -2
- data/spec/armor_payments/api/documents_spec.rb +1 -1
- data/spec/armor_payments/api/milestones_spec.rb +16 -0
- data/spec/armor_payments/api/notes_spec.rb +1 -1
- data/spec/armor_payments/api/offers_spec.rb +1 -1
- data/spec/armor_payments/api/orders_spec.rb +3 -3
- data/spec/armor_payments/api/partner_spec.rb +20 -0
- data/spec/armor_payments/api/resource_spec.rb +21 -17
- data/spec/armor_payments/api/users_spec.rb +4 -4
- data/spec/armor_payments/api_spec.rb +3 -3
- data/spec/armor_payments/authenticator_spec.rb +20 -16
- data/spec/spec_helper.rb +0 -1
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cf2945e84365c34ab146858819d477cbfcf3bf7
|
4
|
+
data.tar.gz: c37ef7519e27b2e4e5b67003728d719b7e0cc266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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,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
|
data/lib/armor_payments/api.rb
CHANGED
@@ -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
|
@@ -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.
|
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).
|
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.
|
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.
|
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).
|
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.
|
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.
|
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.
|
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.
|
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).
|
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.
|
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(:
|
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.
|
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).
|
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.
|
26
|
+
allow(resource.connection).to receive(:get).and_return(successful_response)
|
25
27
|
response = resource.request('get', {})
|
26
|
-
response.body.
|
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.
|
35
|
+
allow(resource.connection).to receive(:get).and_return(failed_response)
|
34
36
|
response = resource.request('get', {})
|
35
|
-
response.body.
|
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(
|
44
|
-
resource.connection.
|
47
|
+
Timecop.freeze(given_time) do
|
48
|
+
expect(resource.connection).to receive(:get).with({
|
45
49
|
path: '/wibble/123/resource',
|
46
50
|
headers: {
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"
|
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(
|
61
|
-
resource.connection.
|
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
|
-
"
|
65
|
-
"
|
66
|
-
"
|
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.
|
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).
|
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.
|
11
|
-
client.armor_host.
|
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.
|
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(:
|
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(
|
11
|
-
authenticator.current_timestamp.
|
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(
|
21
|
+
Timecop.freeze(given_time) do
|
19
22
|
the_beast = "#{authenticator.api_secret}:GET:/accounts:#{authenticator.current_timestamp}"
|
20
|
-
Digest::SHA512.
|
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(
|
27
|
-
authenticator.request_signature("get", "/accounts").
|
28
|
-
"
|
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(
|
36
|
-
authenticator.secure_headers('get', '/accounts').keys.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(
|
41
|
-
authenticator.secure_headers('get', '/accounts').
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
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.
|
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:
|
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
|