currency_cloud 0.7.2 → 0.8.0
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/.rubocop.yml +5 -0
- data/.travis.yml +5 -2
- data/Gemfile +1 -0
- data/README.md +7 -7
- data/currency_cloud.gemspec +1 -0
- data/lib/currency_cloud.rb +1 -1
- data/lib/currency_cloud/actions.rb +8 -8
- data/lib/currency_cloud/actions/create.rb +1 -1
- data/lib/currency_cloud/actions/current.rb +1 -1
- data/lib/currency_cloud/actions/find.rb +8 -9
- data/lib/currency_cloud/actions/update.rb +1 -1
- data/lib/currency_cloud/beneficiary.rb +1 -1
- data/lib/currency_cloud/client.rb +2 -2
- data/lib/currency_cloud/errors/api_error.rb +2 -3
- data/lib/currency_cloud/errors/error_utils.rb +1 -1
- data/lib/currency_cloud/errors/general_error.rb +1 -3
- data/lib/currency_cloud/errors/unexpected_error.rb +3 -4
- data/lib/currency_cloud/rate.rb +4 -4
- data/lib/currency_cloud/reference.rb +7 -7
- data/lib/currency_cloud/request_handler.rb +10 -10
- data/lib/currency_cloud/resource.rb +7 -7
- data/lib/currency_cloud/resourceful_collection.rb +3 -3
- data/lib/currency_cloud/response_handler.rb +2 -5
- data/lib/currency_cloud/session.rb +9 -9
- data/lib/currency_cloud/version.rb +2 -2
- data/spec/currency_cloud/request_handler_spec.rb +8 -8
- data/spec/currency_cloud/resource_spec.rb +4 -4
- data/spec/currency_cloud_spec.rb +28 -36
- data/spec/integration/actions_spec.rb +27 -27
- data/spec/integration/authentication_spec.rb +2 -2
- data/spec/integration/errors_spec.rb +8 -9
- data/spec/integration/rates_spec.rb +1 -1
- data/spec/integration/reference_spec.rb +15 -15
- data/spec/integration/settlements_spec.rb +7 -8
- data/spec/spec_helper.rb +1 -1
- data/spec/support/vcr_cassettes/Actions/can_create.yml +1 -1
- data/spec/support/vcr_cassettes/Actions/can_current.yml +2 -2
- data/spec/support/vcr_cassettes/Actions/can_delete.yml +1 -1
- data/spec/support/vcr_cassettes/Actions/can_find.yml +1 -1
- data/spec/support/vcr_cassettes/Actions/can_first.yml +1 -1
- data/spec/support/vcr_cassettes/Actions/can_retrieve.yml +1 -1
- data/spec/support/vcr_cassettes/Actions/can_update.yml +1 -1
- data/spec/support/vcr_cassettes/Actions/can_use_currency_to_retrieve_balance.yml +1 -1
- data/spec/support/vcr_cassettes/Actions/can_validate_beneficiaries.yml +1 -1
- data/spec/support/vcr_cassettes/Authentication/can_be_closed.yml +2 -2
- data/spec/support/vcr_cassettes/Authentication/can_use_just_a_token.yml +1 -1
- data/spec/support/vcr_cassettes/Authentication/handles_session_timeout_error.yml +3 -3
- data/spec/support/vcr_cassettes/Authentication/happens_lazily.yml +1 -1
- data/spec/support/vcr_cassettes/Error/contains_full_details_for_api_error.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_a_bad_request.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_a_forbidden_request.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_an_internal_server_error.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_incorrect_authentication_details.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_when_a_resource_is_not_found.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_when_too_many_requests_have_been_issued.yml +1 -1
- data/spec/support/vcr_cassettes/Rates/can_find.yml +1 -1
- data/spec/support/vcr_cassettes/Rates/can_provided_detailed_rate.yml +1 -1
- data/spec/support/vcr_cassettes/Reference/can_retrieve_beneficiary_required_details.yml +1 -1
- data/spec/support/vcr_cassettes/Reference/can_retrieve_conversion_dates.yml +1 -1
- data/spec/support/vcr_cassettes/Reference/can_retrieve_currencies.yml +1 -1
- data/spec/support/vcr_cassettes/Reference/can_retrieve_settlement_accounts.yml +1 -1
- data/spec/support/vcr_cassettes/Settlements/can_add_conversion.yml +3 -3
- data/spec/support/vcr_cassettes/Settlements/can_release.yml +2 -2
- data/spec/support/vcr_cassettes/Settlements/can_remove_conversion.yml +2 -2
- data/spec/support/vcr_cassettes/Settlements/can_unrelease.yml +2 -2
- metadata +34 -19
@@ -1,17 +1,17 @@
|
|
1
1
|
module CurrencyCloud
|
2
2
|
class Session
|
3
3
|
ENVIRONMENTS = {
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:
|
7
|
-
}
|
4
|
+
production: 'https://api.currencycloud.com',
|
5
|
+
demonstration: 'https://devapi.currencycloud.com',
|
6
|
+
uat: 'https://api-uat1.ccycloud.com'
|
7
|
+
}.freeze
|
8
8
|
|
9
9
|
attr_reader :environment, :login_id, :api_key
|
10
10
|
attr_accessor :token, :on_behalf_of
|
11
11
|
|
12
12
|
def self.validate_environment(environment)
|
13
13
|
unless ENVIRONMENTS.keys.include?(environment)
|
14
|
-
raise CurrencyCloud::GeneralError, "'#{environment}' is not a valid environment, must be one of: #{ENVIRONMENTS.keys.join(
|
14
|
+
raise CurrencyCloud::GeneralError, "'#{environment}' is not a valid environment, must be one of: #{ENVIRONMENTS.keys.join(', ')}"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -38,8 +38,8 @@ module CurrencyCloud
|
|
38
38
|
|
39
39
|
def authenticate
|
40
40
|
validate
|
41
|
-
params = {:
|
42
|
-
CurrencyCloud.token = @token = request.post('authenticate/api', params, :
|
41
|
+
params = { login_id: login_id, api_key: api_key }
|
42
|
+
CurrencyCloud.token = @token = request.post('authenticate/api', params, should_retry: false)['auth_token']
|
43
43
|
end
|
44
44
|
|
45
45
|
def reauthenticate
|
@@ -51,8 +51,8 @@ module CurrencyCloud
|
|
51
51
|
|
52
52
|
def validate
|
53
53
|
self.class.validate_environment(environment)
|
54
|
-
raise CurrencyCloud::GeneralError,
|
55
|
-
raise CurrencyCloud::GeneralError,
|
54
|
+
raise CurrencyCloud::GeneralError, 'login_id must be set using CurrencyCloud.login_id=' unless login_id
|
55
|
+
raise CurrencyCloud::GeneralError, 'api_key must be set using CurrencyCloud.api_key=' unless api_key
|
56
56
|
end
|
57
57
|
|
58
58
|
def request
|
@@ -1,32 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'RequestHandler' do
|
4
|
-
let(:session) { CurrencyCloud::Session.new(:demonstration, nil, nil, '4df5b3e5882a412f148dcd08fa4e5b73')}
|
4
|
+
let(:session) { CurrencyCloud::Session.new(:demonstration, nil, nil, '4df5b3e5882a412f148dcd08fa4e5b73') }
|
5
5
|
let(:response) { double('Response', code: 200, body: '{}') }
|
6
6
|
|
7
7
|
subject { CurrencyCloud::RequestHandler.new(session) }
|
8
8
|
|
9
9
|
describe 'with on_behalf_of parameter' do
|
10
|
-
it
|
11
|
-
session.on_behalf_of =
|
10
|
+
it 'adds it to parameters in HTTP call' do
|
11
|
+
session.on_behalf_of = 'd1f7f5c2-4187-41da-88fc-b3ae40fa958f'
|
12
12
|
|
13
13
|
allow(HTTParty).to receive(:post) do |_, params|
|
14
14
|
expect(params).to include(:body)
|
15
|
-
expect(params[:body]).to include(on_behalf_of:
|
15
|
+
expect(params[:body]).to include(on_behalf_of: 'd1f7f5c2-4187-41da-88fc-b3ae40fa958f')
|
16
16
|
end.and_return(response)
|
17
17
|
|
18
|
-
subject.post('accounts/create', account_name:
|
18
|
+
subject.post('accounts/create', account_name: 'Test Account')
|
19
19
|
end
|
20
20
|
|
21
21
|
it "ignores it if it's not a uuid" do
|
22
|
-
session.on_behalf_of =
|
22
|
+
session.on_behalf_of = 'nonsense variable'
|
23
23
|
|
24
24
|
allow(HTTParty).to receive(:post) do |_, params|
|
25
25
|
expect(params).to include(:body)
|
26
|
-
expect(params[:body]).to eq(account_name:
|
26
|
+
expect(params[:body]).to eq(account_name: 'Test Account')
|
27
27
|
end.and_return(response)
|
28
28
|
|
29
|
-
subject.post('accounts/create', account_name:
|
29
|
+
subject.post('accounts/create', account_name: 'Test Account')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -9,8 +9,8 @@ describe 'Resource' do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
12
|
+
describe '#save' do
|
13
|
+
it 'only updates changed records' do
|
14
14
|
person = Person.new(id: 1, name: 'Richard', surname: 'Nienaber')
|
15
15
|
allow(Person.client).to receive(:post).with(1, name: 'John').and_return(id: 1, name: 'John', surname: 'Nienaber')
|
16
16
|
person.name = 'John'
|
@@ -19,7 +19,7 @@ describe 'Resource' do
|
|
19
19
|
expect(person.changed_attributes).to eq(Set.new)
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'does nothing if nothing has changed' do
|
23
23
|
person = Person.new(id: 1, name: 'Richard', surname: 'Nienaber')
|
24
24
|
|
25
25
|
expect(person.save).to eq(person)
|
@@ -27,7 +27,7 @@ describe 'Resource' do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
30
|
+
describe '#delete' do
|
31
31
|
it 'removes resource' do
|
32
32
|
person = Person.new(id: 1, name: 'Richard', surname: 'Nienaber')
|
33
33
|
# Uses the class method to perform the deletion
|
data/spec/currency_cloud_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CurrencyCloud do
|
4
|
-
|
5
4
|
before do
|
6
5
|
CurrencyCloud.environment = nil
|
7
6
|
CurrencyCloud.login_id = nil
|
@@ -9,95 +8,88 @@ describe CurrencyCloud do
|
|
9
8
|
CurrencyCloud.reset_session
|
10
9
|
end
|
11
10
|
|
12
|
-
describe
|
13
|
-
|
14
|
-
it "can set the environment" do
|
11
|
+
describe '#environment' do
|
12
|
+
it 'can set the environment' do
|
15
13
|
CurrencyCloud.environment = :development
|
16
14
|
expect(CurrencyCloud.environment).to eq(:development)
|
17
15
|
end
|
18
|
-
|
19
16
|
end
|
20
17
|
|
21
|
-
describe
|
22
|
-
|
23
|
-
it "can set the login_id" do
|
18
|
+
describe '#login_id' do
|
19
|
+
it 'can set the login_id' do
|
24
20
|
CurrencyCloud.login_id = 'test@example.com'
|
25
21
|
expect(CurrencyCloud.login_id).to eq('test@example.com')
|
26
22
|
end
|
27
|
-
|
28
23
|
end
|
29
24
|
|
30
|
-
describe
|
31
|
-
|
32
|
-
it "can set the api_key" do
|
25
|
+
describe '#api_key' do
|
26
|
+
it 'can set the api_key' do
|
33
27
|
CurrencyCloud.api_key = 'e3b0d6895f91f46d9eaf5c95aa0f64dca9007b7ab0778721b6cdc0a8bc7c563b'
|
34
28
|
expect(CurrencyCloud.api_key).to eq('e3b0d6895f91f46d9eaf5c95aa0f64dca9007b7ab0778721b6cdc0a8bc7c563b')
|
35
29
|
end
|
36
|
-
|
37
30
|
end
|
38
31
|
|
39
|
-
describe
|
40
|
-
|
41
|
-
it "returns a session object" do
|
32
|
+
describe '#session' do
|
33
|
+
it 'returns a session object' do
|
42
34
|
CurrencyCloud.environment = :demonstration
|
43
35
|
CurrencyCloud.login_id = 'test@example.com'
|
44
36
|
CurrencyCloud.api_key = 'e3b0d6895f91f46d9eaf5c95aa0f64dca9007b7ab0778721b6cdc0a8bc7c563b'
|
45
37
|
|
46
38
|
request_handler = double('RequestHandler')
|
47
|
-
expect(request_handler).to receive(:post).and_return(
|
39
|
+
expect(request_handler).to receive(:post).and_return('auth_token' => '123')
|
48
40
|
expect(CurrencyCloud::RequestHandler).to receive(:new).and_return(request_handler)
|
49
41
|
|
50
42
|
expect(CurrencyCloud.session).to be_a(CurrencyCloud::Session)
|
51
43
|
end
|
52
44
|
|
53
|
-
it
|
45
|
+
it 'raises an error if the environment is not set' do
|
54
46
|
CurrencyCloud.environment = nil
|
55
47
|
expect { CurrencyCloud.session }
|
56
|
-
|
48
|
+
.to raise_error(CurrencyCloud::GeneralError, "'' is not a valid environment, must be one of: production, demonstration, uat")
|
57
49
|
end
|
58
50
|
|
59
|
-
it
|
51
|
+
it 'raises an error if the environment is invalid' do
|
60
52
|
CurrencyCloud.environment = :invalid
|
61
53
|
expect { CurrencyCloud.session }
|
62
|
-
|
54
|
+
.to raise_error(CurrencyCloud::GeneralError, "'invalid' is not a valid environment, must be one of: production, demonstration, uat")
|
63
55
|
end
|
64
56
|
|
65
|
-
it
|
57
|
+
it 'raises an error if the login_id is not set' do
|
66
58
|
CurrencyCloud.environment = :demonstration
|
67
59
|
expect { CurrencyCloud.session }
|
68
|
-
|
60
|
+
.to raise_error(CurrencyCloud::GeneralError, 'login_id must be set using CurrencyCloud.login_id=')
|
69
61
|
end
|
70
62
|
|
71
|
-
it
|
63
|
+
it 'raises an error if the api_key is not set' do
|
72
64
|
CurrencyCloud.environment = :demonstration
|
73
65
|
CurrencyCloud.login_id = 'test@example.com'
|
74
66
|
expect { CurrencyCloud.session }
|
75
|
-
|
67
|
+
.to raise_error(CurrencyCloud::GeneralError, 'api_key must be set using CurrencyCloud.api_key=')
|
76
68
|
end
|
77
69
|
end
|
78
70
|
|
79
|
-
describe
|
71
|
+
describe '#on_behalf_of' do
|
80
72
|
before do
|
81
73
|
CurrencyCloud.environment = :demonstration
|
82
74
|
CurrencyCloud.token = '4df5b3e5882a412f148dcd08fa4e5b73'
|
83
75
|
CurrencyCloud.session.on_behalf_of = nil
|
84
76
|
end
|
85
77
|
|
86
|
-
it
|
78
|
+
it 'sets the value on the session, and removes it when done' do
|
87
79
|
CurrencyCloud.on_behalf_of('c6ece846-6df1-461d-acaa-b42a6aa74045') do
|
88
80
|
expect(CurrencyCloud.session.on_behalf_of).to eq('c6ece846-6df1-461d-acaa-b42a6aa74045')
|
89
81
|
end
|
90
82
|
expect(CurrencyCloud.session.on_behalf_of).to be_nil
|
91
83
|
end
|
92
84
|
|
93
|
-
it
|
94
|
-
expect do
|
85
|
+
it 'still removes the value from the session on error' do
|
86
|
+
expect do
|
95
87
|
CurrencyCloud.on_behalf_of('c6ece846-6df1-461d-acaa-b42a6aa74045') do
|
96
88
|
expect(CurrencyCloud.session.on_behalf_of).to eq('c6ece846-6df1-461d-acaa-b42a6aa74045')
|
97
89
|
raise 'Completed Expected error'
|
98
90
|
end
|
99
91
|
end.to raise_error('Completed Expected error')
|
100
|
-
|
92
|
+
|
101
93
|
expect(CurrencyCloud.session.on_behalf_of).to be_nil
|
102
94
|
end
|
103
95
|
|
@@ -105,18 +97,18 @@ describe CurrencyCloud do
|
|
105
97
|
expect do
|
106
98
|
CurrencyCloud.on_behalf_of('c6ece846-6df1-461d-acaa-b42a6aa74045') do
|
107
99
|
CurrencyCloud.on_behalf_of('f57b2d33-652c-4589-a8ff-7762add2706d') do
|
108
|
-
raise
|
100
|
+
raise 'Should raise exception'
|
109
101
|
end
|
110
102
|
end
|
111
|
-
end.to raise_error(CurrencyCloud::GeneralError,
|
103
|
+
end.to raise_error(CurrencyCloud::GeneralError, '#on_behalf_of has already been set')
|
112
104
|
end
|
113
105
|
|
114
106
|
it 'prevents reentrant usage' do
|
115
107
|
expect do
|
116
108
|
CurrencyCloud.on_behalf_of('Richard Nienaber') do
|
117
|
-
raise
|
109
|
+
raise 'Should raise exception'
|
118
110
|
end
|
119
|
-
end.to raise_error(CurrencyCloud::GeneralError,
|
120
|
-
end
|
111
|
+
end.to raise_error(CurrencyCloud::GeneralError, 'contact id for on behalf of is not a UUID')
|
112
|
+
end
|
121
113
|
end
|
122
|
-
end
|
114
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Actions', :
|
3
|
+
describe 'Actions', vcr: true do
|
4
4
|
before do
|
5
5
|
CurrencyCloud.reset_session
|
6
6
|
CurrencyCloud.environment = :demonstration
|
7
7
|
CurrencyCloud.token = '4df5b3e5882a412f148dcd08fa4e5b73'
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'can #create' do
|
11
11
|
params = {
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
12
|
+
bank_account_holder_name: 'Test User',
|
13
|
+
bank_country: 'GB',
|
14
|
+
currency: 'GBP',
|
15
|
+
name: 'Test User',
|
16
|
+
account_number: '12345678',
|
17
|
+
routing_code_type_1: 'sort_code',
|
18
|
+
routing_code_value_1: '123456',
|
19
|
+
payment_types: ['regular']
|
20
20
|
}
|
21
21
|
|
22
22
|
beneficiary = CurrencyCloud::Beneficiary.create(params)
|
@@ -29,7 +29,7 @@ describe 'Actions', :vcr => true do
|
|
29
29
|
expect(beneficiary.updated_at).to eq('2015-04-25T09:21:00+00:00')
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'can #retrieve' do
|
33
33
|
beneficiary = CurrencyCloud::Beneficiary.retrieve('081596c9-02de-483e-9f2a-4cf55dcdf98c')
|
34
34
|
expect(beneficiary).to be_a_kind_of(CurrencyCloud::Beneficiary)
|
35
35
|
|
@@ -40,8 +40,8 @@ describe 'Actions', :vcr => true do
|
|
40
40
|
expect(beneficiary.updated_at).to eq('2015-04-25T09:21:00+00:00')
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
44
|
-
beneficiary = CurrencyCloud::Beneficiary.first(:
|
43
|
+
it 'can #first' do
|
44
|
+
beneficiary = CurrencyCloud::Beneficiary.first(bank_account_holder_name: 'Test User')
|
45
45
|
expect(beneficiary).to be_a_kind_of(CurrencyCloud::Beneficiary)
|
46
46
|
|
47
47
|
expect(beneficiary.id).to eq('081596c9-02de-483e-9f2a-4cf55dcdf98c')
|
@@ -51,7 +51,7 @@ describe 'Actions', :vcr => true do
|
|
51
51
|
expect(beneficiary.updated_at).to eq('2015-04-25T10:58:21+00:00')
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it 'can #find' do
|
55
55
|
beneficiaries = CurrencyCloud::Beneficiary.find
|
56
56
|
expect(beneficiaries).to_not be_empty
|
57
57
|
expect(beneficiaries.length).to eq(1)
|
@@ -72,13 +72,13 @@ describe 'Actions', :vcr => true do
|
|
72
72
|
expect(pagination.order_asc_desc).to eq('asc')
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
76
|
-
beneficiary = CurrencyCloud::Beneficiary.update('081596c9-02de-483e-9f2a-4cf55dcdf98c', :
|
75
|
+
it 'can #update' do
|
76
|
+
beneficiary = CurrencyCloud::Beneficiary.update('081596c9-02de-483e-9f2a-4cf55dcdf98c', bank_account_holder_name: 'Test User 2')
|
77
77
|
expect(beneficiary).to be_a_kind_of(CurrencyCloud::Beneficiary)
|
78
78
|
expect(beneficiary.bank_account_holder_name).to eq('Test User 2')
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it 'can #delete' do
|
82
82
|
beneficiary = CurrencyCloud::Beneficiary.delete('081596c9-02de-483e-9f2a-4cf55dcdf98c')
|
83
83
|
expect(beneficiary).to be_a_kind_of(CurrencyCloud::Beneficiary)
|
84
84
|
|
@@ -89,7 +89,7 @@ describe 'Actions', :vcr => true do
|
|
89
89
|
expect(beneficiary.updated_at).to eq('2015-04-25T11:06:27+00:00')
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
92
|
+
it 'can #current' do
|
93
93
|
account = CurrencyCloud::Account.current
|
94
94
|
|
95
95
|
expect(account).to be_a_kind_of(CurrencyCloud::Account)
|
@@ -99,14 +99,14 @@ describe 'Actions', :vcr => true do
|
|
99
99
|
expect(account.updated_at).to eq('2015-04-24T15:57:55+00:00')
|
100
100
|
end
|
101
101
|
|
102
|
-
it
|
102
|
+
it 'can #validate beneficiaries' do
|
103
103
|
params = {
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
104
|
+
bank_country: 'GB',
|
105
|
+
currency: 'GBP',
|
106
|
+
account_number: '12345678',
|
107
|
+
routing_code_type_1: 'sort_code',
|
108
|
+
routing_code_value_1: '123456',
|
109
|
+
payment_types: ['regular']
|
110
110
|
}
|
111
111
|
|
112
112
|
beneficiary = CurrencyCloud::Beneficiary.validate(params)
|
@@ -116,12 +116,12 @@ describe 'Actions', :vcr => true do
|
|
116
116
|
expect(beneficiary.payment_types).to include('regular')
|
117
117
|
end
|
118
118
|
|
119
|
-
it
|
119
|
+
it 'can use #currency to retrieve balance' do
|
120
120
|
balance = CurrencyCloud::Balance.currency('GBP')
|
121
121
|
|
122
122
|
expect(balance).to be_a_kind_of(CurrencyCloud::Balance)
|
123
123
|
|
124
|
-
expect(balance.id).to eq(
|
124
|
+
expect(balance.id).to eq('5a998e06-3eb7-46d6-ba58-f749864159ce')
|
125
125
|
expect(balance.amount).to eq('999866.78')
|
126
126
|
expect(balance.created_at).to eq('2014-12-04T09:50:35+00:00')
|
127
127
|
expect(balance.updated_at).to eq('2015-03-23T14:33:37+00:00')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Authentication', :
|
3
|
+
describe 'Authentication', vcr: true do
|
4
4
|
before do
|
5
5
|
CurrencyCloud.reset_session
|
6
6
|
CurrencyCloud.environment = :demonstration
|
@@ -34,7 +34,7 @@ describe 'Authentication', :vcr => true do
|
|
34
34
|
response = CurrencyCloud::Beneficiary.find
|
35
35
|
expect(response).to_not be_nil
|
36
36
|
|
37
|
-
#should have changed after reauthentication
|
37
|
+
# should have changed after reauthentication
|
38
38
|
expect(CurrencyCloud.token).to eq('038022bcd2f372cac7bab448db7b5c3b')
|
39
39
|
end
|
40
40
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'net/http'
|
3
3
|
|
4
|
-
describe 'Error', :
|
4
|
+
describe 'Error', vcr: true do
|
5
5
|
before(:each) do
|
6
6
|
CurrencyCloud.reset_session
|
7
7
|
CurrencyCloud.environment = :demonstration
|
@@ -21,7 +21,7 @@ describe 'Error', :vcr => true do
|
|
21
21
|
rescue CurrencyCloud::BadRequestError => error
|
22
22
|
end
|
23
23
|
|
24
|
-
expected_error = %
|
24
|
+
expected_error = %{CurrencyCloud::BadRequestError
|
25
25
|
---
|
26
26
|
platform: #{error.platform}
|
27
27
|
request:
|
@@ -29,7 +29,7 @@ request:
|
|
29
29
|
login_id: non-existent-login-id
|
30
30
|
api_key: ef0fd50fca1fb14c1fab3a8436b9ecb57528f0
|
31
31
|
verb: post
|
32
|
-
url: https://devapi.
|
32
|
+
url: https://devapi.currencycloud.com/v2/authenticate/api
|
33
33
|
response:
|
34
34
|
status_code: 400
|
35
35
|
date: Wed, 29 Apr 2015 22:46:53 GMT
|
@@ -64,7 +64,7 @@ errors:
|
|
64
64
|
expect(error_message.field).to eq('api_key')
|
65
65
|
expect(error_message.code).to eq('api_key_length_is_invalid')
|
66
66
|
expect(error_message.message).to eq('api_key should be 64 character(s) long')
|
67
|
-
expect(error_message.params).to include(
|
67
|
+
expect(error_message.params).to include('length' => 64)
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'is raised on incorrect authentication details' do
|
@@ -100,7 +100,7 @@ errors:
|
|
100
100
|
rescue CurrencyCloud::UnexpectedError => error
|
101
101
|
end
|
102
102
|
|
103
|
-
|
103
|
+
expected_error = %(CurrencyCloud::UnexpectedError
|
104
104
|
---
|
105
105
|
platform: #{error.platform}
|
106
106
|
request:
|
@@ -108,9 +108,9 @@ request:
|
|
108
108
|
login_id: rjnienaber@gmail.com
|
109
109
|
api_key: ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0
|
110
110
|
verb: post
|
111
|
-
url: https://devapi.
|
111
|
+
url: https://devapi.currencycloud.com/v2/authenticate/api
|
112
112
|
inner_error: Timeout::Error
|
113
|
-
|
113
|
+
)
|
114
114
|
|
115
115
|
expect(error.to_s).to eq(expected_error)
|
116
116
|
expect(error.inner_error).to_not be_nil
|
@@ -159,7 +159,6 @@ inner_error: Timeout::Error
|
|
159
159
|
end
|
160
160
|
|
161
161
|
it 'is raised on an internal server error' do
|
162
|
-
|
163
162
|
error = nil
|
164
163
|
begin
|
165
164
|
CurrencyCloud.session
|
@@ -176,7 +175,7 @@ inner_error: Timeout::Error
|
|
176
175
|
expect(error_message.field).to eq('base')
|
177
176
|
expect(error_message.code).to eq('internal_application_error')
|
178
177
|
expect(error_message.message).to eq('A general application error occurred')
|
179
|
-
expect(error_message.params).to include(
|
178
|
+
expect(error_message.params).to include('request_id' => 2771875643610572878)
|
180
179
|
end
|
181
180
|
|
182
181
|
it 'is raised when too many requests have been issued' do
|