currency_cloud 0.14.2 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/README.md +9 -8
  4. data/currency_cloud.gemspec +8 -2
  5. data/lib/currency_cloud/balance.rb +5 -0
  6. data/lib/currency_cloud/errors/api_error.rb +6 -2
  7. data/lib/currency_cloud/funding_account.rb +8 -0
  8. data/lib/currency_cloud/margin_balance_top_up.rb +5 -0
  9. data/lib/currency_cloud/payment.rb +4 -0
  10. data/lib/currency_cloud/payment_tracking_info.rb +5 -0
  11. data/lib/currency_cloud/version.rb +2 -2
  12. data/lib/currency_cloud/withdrawal_account.rb +17 -0
  13. data/lib/currency_cloud/withdrawal_account_funds.rb +5 -0
  14. data/lib/currency_cloud/withdrawal_accounts.rb +6 -0
  15. data/spec/integration/actions_spec.rb +11 -0
  16. data/spec/integration/funding_account_spec.rb +62 -0
  17. data/spec/integration/payments_spec.rb +29 -0
  18. data/spec/integration/rates_spec.rb +8 -0
  19. data/spec/integration/reference_spec.rb +5 -3
  20. data/spec/integration/withdrawal_accounts_spec.rb +69 -0
  21. data/spec/support/vcr_cassettes/Accounts/can_retrieve_account_payment_charges_settings.yml +2 -2
  22. data/spec/support/vcr_cassettes/Accounts/can_update_account_payment_charges_settings.yml +2 -2
  23. data/spec/support/vcr_cassettes/Actions/can_top_up_margin_balance.yml +39 -0
  24. data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/with_notes/has_a_non-empty_notes_attribute.yml +4 -4
  25. data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/without_notes/has_a_empty_notes_attribute.yml +4 -4
  26. data/spec/support/vcr_cassettes/Conversions/can_cancellation_quote.yml +3 -3
  27. data/spec/support/vcr_cassettes/Conversions/can_date_change_conversion.yml +4 -4
  28. data/spec/support/vcr_cassettes/Conversions/can_retrieve_cancellation_quote.yml +4 -4
  29. data/spec/support/vcr_cassettes/Conversions/can_retrieve_date_change_quote.yml +4 -4
  30. data/spec/support/vcr_cassettes/Conversions/can_retrieve_profit_and_loss.yml +2 -2
  31. data/spec/support/vcr_cassettes/Conversions/can_split_conversion.yml +4 -4
  32. data/spec/support/vcr_cassettes/Conversions/can_split_history.yml +4 -4
  33. data/spec/support/vcr_cassettes/Conversions/can_split_preview.yml +4 -4
  34. data/spec/support/vcr_cassettes/FundingAccounts/can_find.yml +141 -0
  35. data/spec/support/vcr_cassettes/FundingAccounts/can_find_bad_request.yml +142 -0
  36. data/spec/support/vcr_cassettes/FundingAccounts/can_find_missing_currency.yml +122 -0
  37. data/spec/support/vcr_cassettes/FundingAccounts/can_find_unauthorized.yml +62 -0
  38. data/spec/support/vcr_cassettes/IBANs/can_IBANs_for_a_specific_subaccount.yml +2 -2
  39. data/spec/support/vcr_cassettes/IBANs/can_IBANs_for_subaccounts.yml +2 -2
  40. data/spec/support/vcr_cassettes/IBANs/can_find.yml +1 -1
  41. data/spec/support/vcr_cassettes/Payments/can_authorise/when_payment_ids_are_valid.yml +5 -5
  42. data/spec/support/vcr_cassettes/Payments/can_create.yml +3 -3
  43. data/spec/support/vcr_cassettes/Payments/can_create_bad_request.yml +191 -0
  44. data/spec/support/vcr_cassettes/Payments/can_get_the_submission.yml +4 -4
  45. data/spec/support/vcr_cassettes/Payments/can_retrieve_confirmation.yml +3 -3
  46. data/spec/support/vcr_cassettes/Payments/can_retrieve_payment_delivery_date.yml +2 -2
  47. data/spec/support/vcr_cassettes/Payments/can_retrieve_payment_tracking_info.yml +291 -0
  48. data/spec/support/vcr_cassettes/Payments/can_retrieve_quote_payment_fee.yml +2 -2
  49. data/spec/support/vcr_cassettes/Rates/can_provided_detailed_rate_with_conversion_date_preference.yml +68 -0
  50. data/spec/support/vcr_cassettes/Reference/can_retrieve_bank_details.yml +2 -2
  51. data/spec/support/vcr_cassettes/Reference/can_retrieve_conversion_dates.yml +253 -110
  52. data/spec/support/vcr_cassettes/Reference/can_retrieve_currencies.yml +2 -2
  53. data/spec/support/vcr_cassettes/Reference/can_retrieve_payer_required_details.yml +2 -2
  54. data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_dates.yml +2 -2
  55. data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_fee_rules.yml +1 -1
  56. data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_purpose_codes.yml +2 -2
  57. data/spec/support/vcr_cassettes/Reference/can_retrieve_settlement_accounts.yml +2 -2
  58. data/spec/support/vcr_cassettes/Reports/can_create_payments_report.yml +2 -2
  59. data/spec/support/vcr_cassettes/Reports/can_find_report_requests.yml +2 -2
  60. data/spec/support/vcr_cassettes/Reports/can_retrieve_report_request.yml +2 -2
  61. data/spec/support/vcr_cassettes/Transactions/can_retrieve_sender_details.yml +2 -2
  62. data/spec/support/vcr_cassettes/Transfers/can_create.yml +2 -2
  63. data/spec/support/vcr_cassettes/Transfers/can_find.yml +3 -3
  64. data/spec/support/vcr_cassettes/Transfers/can_retrieve.yml +3 -3
  65. data/spec/support/vcr_cassettes/VirtualAccounts/can_find.yml +2 -2
  66. data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_a_specific_subaccount.yml +2 -2
  67. data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_subaccounts.yml +2 -2
  68. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_find_withdrawal_accounts.yml +133 -0
  69. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_find_withdrawal_accounts2.yml +140 -0
  70. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_pull_funds.yml +140 -0
  71. metadata +48 -27
  72. data/lib/currency_cloud/settlement.rb +0 -55
  73. data/spec/integration/settlements_spec.rb +0 -66
  74. data/spec/support/vcr_cassettes/Settlements/can_add_conversion.yml +0 -152
  75. data/spec/support/vcr_cassettes/Settlements/can_release.yml +0 -119
  76. data/spec/support/vcr_cassettes/Settlements/can_remove_conversion.yml +0 -119
  77. data/spec/support/vcr_cassettes/Settlements/can_unrelease.yml +0 -119
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 863888f159fbc69a264fa92eec5beb7e340b452cb2e0c1bcc7a3f3346189f49c
4
- data.tar.gz: cf813dadc2ba0a10488e65b749a8e6f74d2bc441bbd5f6d3c95ab0f161ea7cc3
3
+ metadata.gz: 8de279160095c51a40e0e4880cfcc5909a453cdf2cac7234a3458c230fe70299
4
+ data.tar.gz: 245c4f7210c6a683e3ef346833c05e0ed3d75c4ed350e03e56e1fe74105635a4
5
5
  SHA512:
6
- metadata.gz: fda08c6b04b98b6703d1e67c22f13d2d79a862b941f7e5a26b912d132802933fab5c7c7aa88d8b2ea0af29064ccb4723e032a9d793ce826a36076e98e25b9188
7
- data.tar.gz: ce286bd78f9287a629ea20b4a29ef15b49aff2f076c73633d19eb3c2c0d784768e613313d87dec24b7a31c4d92fc61a1f9b8f06f3bd2794eac1422d1bf4c7774
6
+ metadata.gz: 47d718f59102b97dfc980541a1c69eb06957d83d556f978f1aeb95772bd246d908154571fa1de76729015294d0c62a8b1b1faac1058c2bada34344c87d747556
7
+ data.tar.gz: 345a2bfa8649b55882d09d08e8815b6c4f995c4789b6935d136c83fbf80bddc8dad2960d1d1d76ab3537de2738868c521919cdfdd85fb716e066a2b10bb61538
data/.travis.yml CHANGED
@@ -4,12 +4,12 @@ script: bundle exec rspec
4
4
  cache: bundler
5
5
 
6
6
  rvm:
7
- - 1.9.3
8
7
  - 2.2
9
8
  - 2.3.4
10
9
  - 2.4.1
11
- - 2.5.3
12
- - 2.6.3
10
+ - 2.5.8
11
+ - 2.6.6
12
+ - 2.7.2
13
13
  - jruby-19mode
14
14
  - jruby-9.1.17.0
15
15
  - jruby-9.2.0.0
data/README.md CHANGED
@@ -16,20 +16,21 @@ you just want to use the library in your application, you should run:
16
16
  If you want to build the gem from source:
17
17
 
18
18
  `gem build currency_cloud.gemspec`
19
+
20
+ ## Deprecation Announcement
21
+
22
+ February 2021: Please be aware that __Ruby 2.0, 2.1, 2,2, 2.3 and 2.4__ are now deprecated, it will not be supported from May 2021.
23
+ Please upgrade to a supported, secure version of Ruby, listed below.
24
+
19
25
 
20
26
  ## Supported Ruby versions
21
27
 
22
28
  This library aims to support and is [tested against][travis] the following Ruby
23
29
  implementations:
24
30
 
25
- * MRI 1.9.3
26
- * MRI 2.0.0
27
- * MRI 2.1.0
28
- * MRI 2.2.0
29
- * MRI 2.3.4
30
- * MRI 2.4.1
31
- * MRI 2.5.3
32
- * MRI 2.6.3
31
+ * MRI 2.5
32
+ * MRI 2.6
33
+ * MRI 2.7
33
34
  * [JRuby][jruby]
34
35
  * [Rubinius][rubinius]
35
36
 
@@ -14,10 +14,16 @@ Gem::Specification.new do |s|
14
14
  s.required_ruby_version = '>= 1.9'
15
15
 
16
16
  s.add_dependency('httparty', '~> 0.14')
17
- s.add_dependency('json', '>= 1.8')
17
+
18
+ if RUBY_VERSION == '1.9.3'
19
+ s.add_dependency('json', '>= 1.8', '<= 2.2')
20
+ s.add_development_dependency('rake', '~> 10.3')
21
+ else
22
+ s.add_dependency('json', '~> 2.3')
23
+ s.add_development_dependency('rake', '~> 12.3.3')
24
+ end
18
25
 
19
26
  s.add_development_dependency('addressable', '<= 2.4.0')
20
- s.add_development_dependency('rake', '~> 10.3')
21
27
  s.add_development_dependency('rspec', '~> 3.1')
22
28
  s.add_development_dependency('vcr', '~> 3.0.3')
23
29
  s.add_development_dependency('webmock', '~> 2.3.2')
@@ -8,5 +8,10 @@ module CurrencyCloud
8
8
  def self.currency(ccy)
9
9
  new(client.get(ccy))
10
10
  end
11
+
12
+ def self.top_up_margin(params)
13
+ top_up = client.post("top_up_margin", params)
14
+ MarginBalanceTopUp.new(top_up)
15
+ end
11
16
  end
12
17
  end
@@ -37,8 +37,12 @@ module CurrencyCloud
37
37
  return unless errors['error_messages']
38
38
 
39
39
  errors['error_messages'].each do |field, messages|
40
- messages.each do |message|
41
- @messages << ApiErrorMessage.new(field, message)
40
+ if messages.is_a?(Array)
41
+ messages.each do |message|
42
+ @messages << ApiErrorMessage.new(field, message)
43
+ end
44
+ else
45
+ @messages << ApiErrorMessage.new(field, messages)
42
46
  end
43
47
  end
44
48
  end
@@ -0,0 +1,8 @@
1
+ module CurrencyCloud
2
+ class FundingAccount
3
+ include CurrencyCloud::Resource
4
+
5
+ resource :funding_accounts
6
+ actions :find
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module CurrencyCloud
2
+ class MarginBalanceTopUp
3
+ include CurrencyCloud::Resource
4
+ end
5
+ end
@@ -30,5 +30,9 @@ module CurrencyCloud
30
30
  QuotePaymentFee.new(result)
31
31
  end
32
32
 
33
+ def self.tracking_info(id)
34
+ result = client.get("#{id}/tracking_info")
35
+ PaymentTrackingInfo.new(result)
36
+ end
33
37
  end
34
38
  end
@@ -0,0 +1,5 @@
1
+ module CurrencyCloud
2
+ class PaymentTrackingInfo
3
+ include CurrencyCloud::Resource
4
+ end
5
+ end
@@ -1,6 +1,6 @@
1
1
  # Separate Gem version from 'API version'
2
2
 
3
3
  module CurrencyCloud
4
- API_VERSION = 'v2'.freeze # API Version
5
- VERSION = '0.14.2'.freeze # Gem Version
4
+ API_VERSION = "v2".freeze # API Version
5
+ VERSION = "1.1.4".freeze # Gem Version
6
6
  end
@@ -0,0 +1,17 @@
1
+ module CurrencyCloud
2
+ class WithdrawalAccount
3
+ include CurrencyCloud::Resource
4
+
5
+ resource :withdrawal_accounts
6
+
7
+ def self.find(params = {})
8
+ result = client.get("/", params)
9
+ WithdrawalAccounts.new(:withdrawal_accounts, self, result)
10
+ end
11
+
12
+ def self.pull_funds(withdrawal_account_id, params = {})
13
+ result = client.post("#{withdrawal_account_id}/pull_funds", params)
14
+ WithdrawalAccountFunds.new(result)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module CurrencyCloud
2
+ class WithdrawalAccountFunds
3
+ include CurrencyCloud::Resource
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "currency_cloud/resourceful_collection"
2
+
3
+ module CurrencyCloud
4
+ class WithdrawalAccounts < CurrencyCloud::ResourcefulCollection
5
+ end
6
+ end
@@ -126,4 +126,15 @@ describe 'Actions', vcr: true do
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')
128
128
  end
129
+
130
+ it 'can top up margin balance' do
131
+ top_up = CurrencyCloud::Balance.top_up_margin(currency: 'GBP', amount: 450)
132
+
133
+ expect(top_up).to be_a_kind_of(CurrencyCloud::MarginBalanceTopUp)
134
+
135
+ expect(top_up.account_id).to eq('6c046c51-2387-4004-8e87-4bf97102e36d')
136
+ expect(top_up.transferred_amount).to eq('450.0')
137
+ expect(top_up.currency).to eq('GBP')
138
+ expect(top_up.transfer_completed_at).to eq('2007-11-19T08:37:48-06:00')
139
+ end
129
140
  end
@@ -0,0 +1,62 @@
1
+ require "spec_helper"
2
+
3
+ describe "FundingAccounts", vcr: true do
4
+ before do
5
+ CurrencyCloud.login_id = "development@currencycloud.com"
6
+ CurrencyCloud.api_key = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
7
+ CurrencyCloud.environment = :demonstration
8
+ CurrencyCloud.reset_session
9
+ end
10
+ it 'can #find' do
11
+
12
+ accounts = CurrencyCloud::FundingAccount.find(currency: 'GBP', per_page: 5)
13
+ expect(accounts.length).to eq 1
14
+
15
+ account = accounts[0]
16
+ expect(account).to be_a(CurrencyCloud::FundingAccount)
17
+ expect(account.id).to eq "b7981972-8e29-485b-8a4a-9643fc6ae3sa"
18
+ expect(account.account_id).to eq "8d98bdc8-e8e3-47dc-bd08-3dd0f4f7ea7b"
19
+ expect(account.account_number).to eq "012345678"
20
+ expect(account.account_number_type).to eq "account_number"
21
+ expect(account.account_holder_name).to eq "Jon Doe"
22
+ expect(account.bank_name).to eq "Starling"
23
+ expect(account.bank_address).to eq "3rd floor, 2 Finsbury Avenue, London, EC2M 2PP, GB"
24
+ expect(account.bank_country).to eq "UK"
25
+ expect(account.currency).to eq "GBP"
26
+ expect(account.payment_type).to eq "regular"
27
+ expect(account.routing_code).to eq "010203"
28
+ expect(account.routing_code_type).to eq "sort_code"
29
+ expect(account.created_at).to eq "2018-05-14T14:18:30+00:00"
30
+ expect(account.updated_at).to eq "2018-05-14T14:19:30+00:00"
31
+ end
32
+
33
+ it "can find #missing_currency" do
34
+ begin
35
+ accounts = CurrencyCloud::FundingAccount.find()
36
+ rescue CurrencyCloud::BadRequestError => error
37
+ # All Good. Expected
38
+ expect(error.messages.length).to eq 1
39
+ expect(error.messages[0].code).to eq "currency_is_required"
40
+ end
41
+ end
42
+
43
+ it "can find #bad_request" do
44
+ begin
45
+ accounts = CurrencyCloud::FundingAccount.find(currency: "a", payment_type: "x", account_id: "x")
46
+ rescue CurrencyCloud::BadRequestError => error
47
+ # All Good. Expected
48
+ expect(error.messages.length).to eq 3
49
+ end
50
+ end
51
+
52
+ it "can find #unauthorized" do
53
+ begin
54
+ accounts = CurrencyCloud::FundingAccount.find(currency: "GBP")
55
+ rescue CurrencyCloud::AuthenticationError => error
56
+ # All Good. Expected
57
+ expect(error.messages.length).to eq 1
58
+ expect(error.messages[0].code).to eq "invalid_supplied_credentials"
59
+ end
60
+ end
61
+
62
+ end
@@ -107,4 +107,33 @@ describe 'Payments', vcr: true do
107
107
  expect(quote_payment_fee.payment_type).to eq("regular")
108
108
  expect(quote_payment_fee.charge_type).to be_nil
109
109
  end
110
+
111
+ it "can retrieve #payment_tracking_info" do
112
+ payment_tracking_info = CurrencyCloud::Payment.tracking_info("46ed4827-7b6f-4491-a06f-b548d5a7512d")
113
+
114
+ expect(payment_tracking_info).to be_a(CurrencyCloud::PaymentTrackingInfo)
115
+ expect(payment_tracking_info.uetr).to eq("46ed4827-7b6f-4491-a06f-b548d5a7512d")
116
+ expect(payment_tracking_info.transaction_status["status"]).to eq("processing")
117
+ expect(payment_tracking_info.transaction_status["reason"]).to eq("transferred_and_tracked")
118
+ expect(payment_tracking_info.initiation_time).to eq("2019-07-09T13:20:30+00:00")
119
+ expect(payment_tracking_info.completion_time).to be_nil
120
+ expect(payment_tracking_info.last_update_time).to eq("2019-07-10T15:39:08+00:00")
121
+ expect(payment_tracking_info.payment_events.length).to eq(7)
122
+ expect(payment_tracking_info.payment_events[6]["tracker_event_type"]).to eq("customer_credit_transfer_payment")
123
+ expect(payment_tracking_info.payment_events[6]["instructed_amount"]["amount"]).to eq("745437.57")
124
+ end
125
+
126
+ it 'can create #bad_request' do
127
+ begin
128
+ payment = CurrencyCloud::Payment.create()
129
+ rescue CurrencyCloud::BadRequestError => error
130
+ #All Good. Expected
131
+ expect(error.messages.length).to eq 10
132
+ expect(error.messages[0].field).to eq "currency"
133
+ expect(error.messages[0].code).to eq "currency_is_required"
134
+ expect(error.messages[2].field).to eq "beneficiary_id"
135
+ expect(error.messages[2].code).to eq "beneficiary_id_is_required"
136
+ end
137
+ end
138
+
110
139
  end
@@ -36,4 +36,12 @@ describe 'Rates', vcr: true do
36
36
  expect(detailed_rate.client_sell_amount).to eq('15234.00')
37
37
  expect(detailed_rate.settlement_cut_off_time).to eq('2015-04-29T14:00:00Z')
38
38
  end
39
+
40
+ it 'can provided #detailed rate with conversion date preference' do
41
+ detailed_rate = CurrencyCloud::Rate.detailed(buy_currency: 'GBP', sell_currency: 'USD', fixed_side: 'buy', amount: '10000', conversion_date_preference: 'optimize_liquidity')
42
+
43
+ expect(detailed_rate).to be_a_kind_of(CurrencyCloud::Rate)
44
+ expect(detailed_rate.client_sell_amount).to eq('14081.00')
45
+ expect(detailed_rate.settlement_cut_off_time).to eq('2020-05-21T14:00:00Z')
46
+ end
39
47
  end
@@ -24,9 +24,11 @@ describe 'Reference', vcr: true do
24
24
 
25
25
  expect(dates.invalid_conversion_dates).to_not be_empty
26
26
  invalid_conversion_date = dates.invalid_conversion_dates.first
27
- expect(invalid_conversion_date).to eq(['2018-07-21', 'No trading on Saturday'])
28
- expect(dates.first_conversion_date).to eq('2018-07-16')
29
- expect(dates.default_conversion_date).to eq('2018-07-18')
27
+ expect(invalid_conversion_date).to eq(["2020-11-11", "Veterans' Day"])
28
+ expect(dates.first_conversion_date).to eq("2020-11-10")
29
+ expect(dates.default_conversion_date).to eq("2020-11-12")
30
+ expect(dates.first_conversion_cutoff_datetime).to eq("2020-11-10T15:30:00+00:00")
31
+ expect(dates.optimize_liquidity_conversion_date).to eq("2020-11-12")
30
32
  end
31
33
 
32
34
  it 'can retrieve #currencies' do
@@ -0,0 +1,69 @@
1
+ require "spec_helper"
2
+
3
+ describe "WithdrawalAccounts", vcr: true do
4
+ before do
5
+ CurrencyCloud.login_id = "development@currencycloud.com"
6
+ CurrencyCloud.api_key = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
7
+ CurrencyCloud.environment = :demonstration
8
+ CurrencyCloud.reset_session
9
+ end
10
+
11
+ it "can find #withdrawal_accounts" do
12
+ withdrawal_accounts = CurrencyCloud::WithdrawalAccount.find(
13
+ account_id: "72970a7c-7921-431c-b95f-3438724ba16f"
14
+ )
15
+ expect(withdrawal_accounts.length).to eq(1)
16
+
17
+ withdrawal_account = withdrawal_accounts[0]
18
+ expect(withdrawal_account).to be_a(CurrencyCloud::WithdrawalAccount)
19
+ expect(withdrawal_account.id).to eq("0886ac00-6ab6-41a6-b0e1-8d3faf2e0de2")
20
+ expect(withdrawal_account.account_name).to eq("currencycloud")
21
+ expect(withdrawal_account.account_holder_name).to eq("The Currency Cloud")
22
+ expect(withdrawal_account.account_holder_dob).to be_nil
23
+ expect(withdrawal_account.routing_code).to eq("123456789")
24
+ expect(withdrawal_account.account_number).to eq("01234567890")
25
+ expect(withdrawal_account.currency).to eq("USD")
26
+ expect(withdrawal_account.account_id).to eq("72970a7c-7921-431c-b95f-3438724ba16f")
27
+ end
28
+
29
+ it "can find #withdrawal_accounts2" do
30
+ withdrawal_accounts = CurrencyCloud::WithdrawalAccount.find()
31
+ expect(withdrawal_accounts.length).to eq(2)
32
+
33
+ withdrawal_account1 = withdrawal_accounts[0]
34
+ expect(withdrawal_account1).to be_a(CurrencyCloud::WithdrawalAccount)
35
+ expect(withdrawal_account1.id).to eq("0886ac00-6ab6-41a6-b0e1-8d3faf2e0de2")
36
+ expect(withdrawal_account1.account_name).to eq("currencycloud")
37
+ expect(withdrawal_account1.account_holder_name).to eq("The Currency Cloud")
38
+ expect(withdrawal_account1.account_holder_dob).to be_nil
39
+ expect(withdrawal_account1.routing_code).to eq("123456789")
40
+ expect(withdrawal_account1.account_number).to eq("01234567890")
41
+ expect(withdrawal_account1.currency).to eq("USD")
42
+ expect(withdrawal_account1.account_id).to eq("72970a7c-7921-431c-b95f-3438724ba16f")
43
+
44
+ withdrawal_account2 = withdrawal_accounts[1]
45
+ expect(withdrawal_account2).to be_a(CurrencyCloud::WithdrawalAccount)
46
+ expect(withdrawal_account2.id).to eq("0886ac00-6ab6-41a6-b0e1-8d3faf2e0de3")
47
+ expect(withdrawal_account2.account_name).to eq("currencycloud2")
48
+ expect(withdrawal_account2.account_holder_name).to eq("The Currency Cloud 2")
49
+ expect(withdrawal_account2.account_holder_dob).to eq("1990-07-20")
50
+ expect(withdrawal_account2.routing_code).to eq("223456789")
51
+ expect(withdrawal_account2.account_number).to eq("01234567892")
52
+ expect(withdrawal_account2.currency).to eq("GBP")
53
+ expect(withdrawal_account2.account_id).to eq("72970a7c-7921-431c-b95f-3438724ba16e")
54
+ end
55
+
56
+ it "can pull funds" do
57
+ withdrawal_account_funds = CurrencyCloud::WithdrawalAccount.pull_funds(
58
+ "0886ac00-6ab6-41a6-b0e1-8d3faf2e0de2",
59
+ reference: "PullFunds1",
60
+ amount: 100.0
61
+ )
62
+ expect(withdrawal_account_funds).to be_a(CurrencyCloud::WithdrawalAccountFunds)
63
+ expect(withdrawal_account_funds.id).to eq("e2e6b7aa-c9e8-4625-96a6-b97d4baab758")
64
+ expect(withdrawal_account_funds.withdrawal_account_id).to eq("0886ac00-6ab6-41a6-b0e1-8d3faf2e0de2")
65
+ expect(withdrawal_account_funds.reference).to eq("PullFunds1")
66
+ expect(withdrawal_account_funds.amount).to eq("100.00")
67
+ expect(withdrawal_account_funds.created_at).to eq("2020-06-29T08:02:31+00:00")
68
+ end
69
+ end
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: login_id=development%40currencycloud.com&api_key=deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
9
9
  headers:
10
10
  User-Agent:
11
- - CurrencyCloudSDK/2.0 Ruby/0.14.2
11
+ - CurrencyCloudSDK/2.0 Ruby/1.1.4
12
12
  response:
13
13
  status:
14
14
  code: 200
@@ -58,7 +58,7 @@ http_interactions:
58
58
  X-Auth-Token:
59
59
  - deadbeefdeadbeefdeadbeefdeadbeef
60
60
  User-Agent:
61
- - CurrencyCloudSDK/2.0 Ruby/0.14.2
61
+ - CurrencyCloudSDK/2.0 Ruby/1.1.4
62
62
  response:
63
63
  status:
64
64
  code: 200
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: login_id=development%40currencycloud.com&api_key=deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
9
9
  headers:
10
10
  User-Agent:
11
- - CurrencyCloudSDK/2.0 Ruby/0.14.2
11
+ - CurrencyCloudSDK/2.0 Ruby/1.1.4
12
12
  response:
13
13
  status:
14
14
  code: 200
@@ -58,7 +58,7 @@ http_interactions:
58
58
  X-Auth-Token:
59
59
  - deadbeefdeadbeefdeadbeefdeadbeef
60
60
  User-Agent:
61
- - CurrencyCloudSDK/2.0 Ruby/0.14.2
61
+ - CurrencyCloudSDK/2.0 Ruby/1.1.4
62
62
  response:
63
63
  status:
64
64
  code: 200
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://devapi.currencycloud.com/v2/balances/top_up_margin
6
+ body:
7
+ encoding: UTF-8
8
+ string: currency=GBP&amount=450
9
+ headers:
10
+ X-Auth-Token:
11
+ - 4df5b3e5882a412f148dcd08fa4e5b73
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Fri, 03 Jan 2020 11:01:36 GMT
21
+ Content-Type:
22
+ - application/json;charset=utf-8
23
+ Content-Length:
24
+ - '1021'
25
+ Connection:
26
+ - keep-alive
27
+ X-Request-Id:
28
+ - '2771999306691376475'
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"account_id": "6c046c51-2387-4004-8e87-4bf97102e36d",
34
+ "currency": "GBP",
35
+ "transferred_amount": "450.0",
36
+ "transfer_completed_at": "2007-11-19T08:37:48-06:00"}'
37
+ http_version:
38
+ recorded_at: Fri, 03 Jan 2020 11:01:36 GMT
39
+ recorded_with: VCR 2.9.3