currency_cloud 0.12.5 → 1.0.3

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -1
  3. data/currency_cloud.gemspec +9 -3
  4. data/lib/currency_cloud/balance.rb +5 -0
  5. data/lib/currency_cloud/funding_account.rb +8 -0
  6. data/lib/currency_cloud/margin_balance_top_up.rb +5 -0
  7. data/lib/currency_cloud/payment.rb +10 -0
  8. data/lib/currency_cloud/payment_fee_rule.rb +5 -0
  9. data/lib/currency_cloud/payment_tracking_info.rb +5 -0
  10. data/lib/currency_cloud/quote_payment_fee.rb +5 -0
  11. data/lib/currency_cloud/reference.rb +5 -0
  12. data/lib/currency_cloud/version.rb +2 -2
  13. data/lib/currency_cloud/withdrawal_account.rb +17 -0
  14. data/lib/currency_cloud/withdrawal_account_funds.rb +5 -0
  15. data/lib/currency_cloud/withdrawal_accounts.rb +6 -0
  16. data/spec/integration/actions_spec.rb +11 -0
  17. data/spec/integration/funding_account_spec.rb +33 -0
  18. data/spec/integration/payments_spec.rb +28 -0
  19. data/spec/integration/rates_spec.rb +8 -0
  20. data/spec/integration/reference_spec.rb +52 -3
  21. data/spec/integration/withdrawal_accounts_spec.rb +69 -0
  22. data/spec/support/vcr_cassettes/Accounts/can_retrieve_account_payment_charges_settings.yml +2 -2
  23. data/spec/support/vcr_cassettes/Accounts/can_update_account_payment_charges_settings.yml +2 -2
  24. data/spec/support/vcr_cassettes/Actions/can_top_up_margin_balance.yml +39 -0
  25. data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/with_notes/has_a_non-empty_notes_attribute.yml +3 -3
  26. data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/without_notes/has_a_empty_notes_attribute.yml +3 -3
  27. data/spec/support/vcr_cassettes/Conversions/can_cancellation_quote.yml +2 -2
  28. data/spec/support/vcr_cassettes/Conversions/can_date_change_conversion.yml +3 -3
  29. data/spec/support/vcr_cassettes/Conversions/can_retrieve_cancellation_quote.yml +3 -3
  30. data/spec/support/vcr_cassettes/Conversions/can_retrieve_date_change_quote.yml +3 -3
  31. data/spec/support/vcr_cassettes/Conversions/can_retrieve_profit_and_loss.yml +2 -2
  32. data/spec/support/vcr_cassettes/Conversions/can_split_conversion.yml +3 -3
  33. data/spec/support/vcr_cassettes/Conversions/can_split_history.yml +3 -3
  34. data/spec/support/vcr_cassettes/Conversions/can_split_preview.yml +3 -3
  35. data/spec/support/vcr_cassettes/FundingAccounts/can_find.yml +141 -0
  36. data/spec/support/vcr_cassettes/IBANs/can_IBANs_for_a_specific_subaccount.yml +2 -2
  37. data/spec/support/vcr_cassettes/IBANs/can_IBANs_for_subaccounts.yml +2 -2
  38. data/spec/support/vcr_cassettes/IBANs/can_find.yml +2 -2
  39. data/spec/support/vcr_cassettes/Payments/can_authorise/when_payment_ids_are_valid.yml +5 -5
  40. data/spec/support/vcr_cassettes/Payments/can_create.yml +3 -3
  41. data/spec/support/vcr_cassettes/Payments/can_get_the_submission.yml +4 -4
  42. data/spec/support/vcr_cassettes/Payments/can_retrieve_confirmation.yml +3 -3
  43. data/spec/support/vcr_cassettes/Payments/can_retrieve_payment_delivery_date.yml +2 -2
  44. data/spec/support/vcr_cassettes/Payments/can_retrieve_payment_tracking_info.yml +291 -0
  45. data/spec/support/vcr_cassettes/Payments/can_retrieve_quote_payment_fee.yml +115 -0
  46. data/spec/support/vcr_cassettes/Rates/can_provided_detailed_rate_with_conversion_date_preference.yml +68 -0
  47. data/spec/support/vcr_cassettes/Reference/can_retrieve_bank_details.yml +2 -2
  48. data/spec/support/vcr_cassettes/Reference/can_retrieve_beneficiary_required_details.yml +2 -2
  49. data/spec/support/vcr_cassettes/Reference/can_retrieve_conversion_dates.yml +253 -110
  50. data/spec/support/vcr_cassettes/Reference/can_retrieve_currencies.yml +2 -2
  51. data/spec/support/vcr_cassettes/Reference/can_retrieve_payer_required_details.yml +2 -2
  52. data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_dates.yml +2 -2
  53. data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_fee_rules.yml +225 -0
  54. data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_purpose_codes.yml +2 -2
  55. data/spec/support/vcr_cassettes/Reference/can_retrieve_settlement_accounts.yml +2 -2
  56. data/spec/support/vcr_cassettes/Reports/can_create_conversions_report.yml +2 -2
  57. data/spec/support/vcr_cassettes/Reports/can_create_payments_report.yml +2 -2
  58. data/spec/support/vcr_cassettes/Reports/can_find_report_requests.yml +2 -2
  59. data/spec/support/vcr_cassettes/Reports/can_retrieve_report_request.yml +2 -2
  60. data/spec/support/vcr_cassettes/Transactions/can_retrieve_sender_details.yml +2 -2
  61. data/spec/support/vcr_cassettes/Transfers/can_create.yml +2 -2
  62. data/spec/support/vcr_cassettes/Transfers/can_find.yml +3 -3
  63. data/spec/support/vcr_cassettes/Transfers/can_retrieve.yml +3 -3
  64. data/spec/support/vcr_cassettes/VirtualAccounts/can_find.yml +2 -2
  65. data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_a_specific_subaccount.yml +2 -2
  66. data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_subaccounts.yml +2 -2
  67. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_find_withdrawal_accounts.yml +133 -0
  68. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_find_withdrawal_accounts2.yml +140 -0
  69. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_pull_funds.yml +140 -0
  70. metadata +51 -33
  71. data/lib/currency_cloud/settlement.rb +0 -55
  72. data/spec/integration/settlements_spec.rb +0 -66
  73. data/spec/support/vcr_cassettes/Settlements/can_add_conversion.yml +0 -152
  74. data/spec/support/vcr_cassettes/Settlements/can_release.yml +0 -119
  75. data/spec/support/vcr_cassettes/Settlements/can_remove_conversion.yml +0 -119
  76. 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: 2b8d9b8ee2c5e1ca902791d041aa7600bc4563f5f311e06db860ecbc6fdab0c4
4
- data.tar.gz: 47131c437ff8989a7e97eaab55f2bec5c89b94318d5fadf36bb3102d04ef3640
3
+ metadata.gz: 6efa7b769f16b04b941b9f3b1990c78f4273cbf8cdd54b19b9851f85f1d76357
4
+ data.tar.gz: 6dfb96ea6e380647ec3eb5083dfa4d174dda50ad0bfb2619d28e7e7878f47a4e
5
5
  SHA512:
6
- metadata.gz: 71633d7f655e6f4833ba6d628c5fbab44933ad5eed7fa34488e32d301c6a99c064fcfc180b3c93e470e5502d0ac4b1716ca7e74320d1e10ae90ed0402d33f496
7
- data.tar.gz: 02b7afefe55c14578b8d3b8865341d1907bd47e7b551b08032449fd33ecd213045eb722c75e1af1b3c4993f5ce3452aaf22826520169b4545beab28d2e9bd790
6
+ metadata.gz: 98d4f5311d45853d0e3fec905c6030af279f187032db13943f0ddd9be45301556c78189e87dce869408f0eecfbf067da3e6b4ebf9240ee3ebcabb0062983936f
7
+ data.tar.gz: 0ff09b593d7f81ca3c11f2bd00c0f6386584ab07fa0e93f6069a4759400a2ea65155301e715f4276436269ef9b766ad5e25e55ba16ea2cd99313c5d2fac20382
data/README.md CHANGED
@@ -16,13 +16,18 @@ 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
+ October 2020: Please be aware that __Ruby 1.9__ is now deprecated, it will not be supported from January 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
31
  * MRI 2.0.0
27
32
  * MRI 2.1.0
28
33
  * MRI 2.2.0
@@ -13,11 +13,17 @@ Gem::Specification.new do |s|
13
13
  s.licenses = ['MIT']
14
14
  s.required_ruby_version = '>= 1.9'
15
15
 
16
- s.add_dependency('httparty', '0.14.0')
17
- s.add_dependency('json', '>= 1.8')
16
+ s.add_dependency('httparty', '~> 0.14')
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
@@ -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
@@ -24,5 +24,15 @@ module CurrencyCloud
24
24
  result = client.get("payment_delivery_date", params)
25
25
  PaymentDeliveryDateResult.new(result)
26
26
  end
27
+
28
+ def self.quote_payment_fee(params)
29
+ result = client.get("quote_payment_fee", params)
30
+ QuotePaymentFee.new(result)
31
+ end
32
+
33
+ def self.tracking_info(id)
34
+ result = client.get("#{id}/tracking_info")
35
+ PaymentTrackingInfo.new(result)
36
+ end
27
37
  end
28
38
  end
@@ -0,0 +1,5 @@
1
+ module CurrencyCloud
2
+ class PaymentFeeRule
3
+ include CurrencyCloud::Resource
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module CurrencyCloud
2
+ class PaymentTrackingInfo
3
+ include CurrencyCloud::Resource
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module CurrencyCloud
2
+ class QuotePaymentFee
3
+ include CurrencyCloud::Resource
4
+ end
5
+ end
@@ -43,5 +43,10 @@ module CurrencyCloud
43
43
  BankDetails.new(bank_details)
44
44
  end
45
45
 
46
+ def self.payment_fee_rules(params = {})
47
+ response = client.get('payment_fee_rules', params)
48
+ response['payment_fee_rules'].map { |s| PaymentFeeRule.new(s) }
49
+ end
50
+
46
51
  end
47
52
  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.12.5'.freeze # Gem Version
4
+ API_VERSION = "v2".freeze # API Version
5
+ VERSION = "1.0.3".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,33 @@
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
+ end
@@ -94,4 +94,32 @@ describe 'Payments', vcr: true do
94
94
  expect(result.currency).to eq('GBP')
95
95
  expect(result.bank_country).to eq('GB')
96
96
  end
97
+
98
+ it "can retrieve #quote_payment_fee" do
99
+ quote_payment_fee = CurrencyCloud::Payment.quote_payment_fee(payment_date: "2019-06-07", payment_type: "regular", currency: "GBP", bank_country: "GB")
100
+
101
+ expect(quote_payment_fee).to_not be_nil
102
+ expect(quote_payment_fee.account_id).to eq("0534aaf2-2egg-0134-2f36-10b11cd33cfb")
103
+ expect(quote_payment_fee.fee_amount).to eq("10.00")
104
+ expect(quote_payment_fee.fee_currency).to eq("EUR")
105
+ expect(quote_payment_fee.payment_currency).to eq("USD")
106
+ expect(quote_payment_fee.payment_destination_country).to eq("US")
107
+ expect(quote_payment_fee.payment_type).to eq("regular")
108
+ expect(quote_payment_fee.charge_type).to be_nil
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
97
125
  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
@@ -95,4 +97,51 @@ describe 'Reference', vcr: true do
95
97
  expect(details.bank_country_ISO).to eq('GB')
96
98
  expect(details.currency).to be_nil
97
99
  end
100
+
101
+ it 'can retrieve #payment_fee_rules' do
102
+ payment_fee_rules1 = CurrencyCloud::Reference.payment_fee_rules()
103
+ expect(payment_fee_rules1.size).to eq(3)
104
+
105
+ fee_rule1_1 = payment_fee_rules1[0]
106
+ expect(fee_rule1_1).to be_a(CurrencyCloud::PaymentFeeRule)
107
+ expect(fee_rule1_1.charge_type).to eq('shared')
108
+ expect(fee_rule1_1.fee_amount).to eq('2.00')
109
+ expect(fee_rule1_1.fee_currency).to eq('AED')
110
+ expect(fee_rule1_1.payment_type).to eq('priority')
111
+
112
+ fee_rule1_2 = payment_fee_rules1[1]
113
+ expect(fee_rule1_2).to be_a(CurrencyCloud::PaymentFeeRule)
114
+ expect(fee_rule1_2.charge_type).to eq('shared')
115
+ expect(fee_rule1_2.fee_amount).to eq('12.00')
116
+ expect(fee_rule1_2.fee_currency).to eq('USD')
117
+ expect(fee_rule1_2.payment_type).to eq('regular')
118
+
119
+ fee_rule1_3 = payment_fee_rules1[2]
120
+ expect(fee_rule1_3).to be_a(CurrencyCloud::PaymentFeeRule)
121
+ expect(fee_rule1_3.charge_type).to eq('ours')
122
+ expect(fee_rule1_3.fee_amount).to eq('5.25')
123
+ expect(fee_rule1_3.fee_currency).to eq('GBP')
124
+ expect(fee_rule1_3.payment_type).to eq('priority')
125
+
126
+ payment_fee_rules2 = CurrencyCloud::Reference.payment_fee_rules(payment_type: 'regular')
127
+ expect(payment_fee_rules2.size).to eq(1)
128
+
129
+ fee_rule2_1 = payment_fee_rules2[0]
130
+ expect(fee_rule2_1).to be_a(CurrencyCloud::PaymentFeeRule)
131
+ expect(fee_rule2_1.charge_type).to eq('shared')
132
+ expect(fee_rule2_1.fee_amount).to eq('12.00')
133
+ expect(fee_rule2_1.fee_currency).to eq('USD')
134
+ expect(fee_rule2_1.payment_type).to eq('regular')
135
+
136
+ payment_fee_rules3 = CurrencyCloud::Reference.payment_fee_rules(charge_type: 'ours')
137
+ expect(payment_fee_rules3.size).to eq(1)
138
+
139
+ fee_rule3_1 = payment_fee_rules3[0]
140
+ expect(fee_rule3_1).to be_a(CurrencyCloud::PaymentFeeRule)
141
+ expect(fee_rule3_1.charge_type).to eq('ours')
142
+ expect(fee_rule3_1.fee_amount).to eq('5.25')
143
+ expect(fee_rule3_1.fee_currency).to eq('GBP')
144
+ expect(fee_rule3_1.payment_type).to eq('priority')
145
+ end
146
+
98
147
  end
@@ -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.9.0
11
+ - CurrencyCloudSDK/2.0 Ruby/1.0.3
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.9.0
61
+ - CurrencyCloudSDK/2.0 Ruby/1.0.3
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.9.0
11
+ - CurrencyCloudSDK/2.0 Ruby/1.0.3
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.9.0
61
+ - CurrencyCloudSDK/2.0 Ruby/1.0.3
62
62
  response:
63
63
  status:
64
64
  code: 200