currency_cloud 0.12.4 → 0.17.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/HALL_OF_FAME.md +1 -0
  4. data/README.md +12 -3
  5. data/currency_cloud.gemspec +9 -3
  6. data/lib/currency_cloud/balance.rb +5 -0
  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 +10 -0
  10. data/lib/currency_cloud/payment_fee_rule.rb +5 -0
  11. data/lib/currency_cloud/payment_tracking_info.rb +5 -0
  12. data/lib/currency_cloud/quote_payment_fee.rb +5 -0
  13. data/lib/currency_cloud/reference.rb +5 -0
  14. data/lib/currency_cloud/version.rb +2 -2
  15. data/lib/currency_cloud/withdrawal_account.rb +17 -0
  16. data/lib/currency_cloud/withdrawal_account_funds.rb +5 -0
  17. data/lib/currency_cloud/withdrawal_accounts.rb +6 -0
  18. data/spec/integration/actions_spec.rb +11 -0
  19. data/spec/integration/funding_account_spec.rb +33 -0
  20. data/spec/integration/payments_spec.rb +28 -0
  21. data/spec/integration/rates_spec.rb +8 -0
  22. data/spec/integration/reference_spec.rb +47 -0
  23. data/spec/integration/withdrawal_accounts_spec.rb +69 -0
  24. data/spec/support/vcr_cassettes/Accounts/can_retrieve_account_payment_charges_settings.yml +2 -2
  25. data/spec/support/vcr_cassettes/Accounts/can_update_account_payment_charges_settings.yml +2 -2
  26. data/spec/support/vcr_cassettes/Actions/can_top_up_margin_balance.yml +39 -0
  27. data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/with_notes/has_a_non-empty_notes_attribute.yml +3 -3
  28. data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/without_notes/has_a_empty_notes_attribute.yml +3 -3
  29. data/spec/support/vcr_cassettes/Conversions/can_cancellation_quote.yml +2 -2
  30. data/spec/support/vcr_cassettes/Conversions/can_date_change_conversion.yml +3 -3
  31. data/spec/support/vcr_cassettes/Conversions/can_retrieve_cancellation_quote.yml +3 -3
  32. data/spec/support/vcr_cassettes/Conversions/can_retrieve_date_change_quote.yml +3 -3
  33. data/spec/support/vcr_cassettes/Conversions/can_retrieve_profit_and_loss.yml +2 -2
  34. data/spec/support/vcr_cassettes/Conversions/can_split_conversion.yml +3 -3
  35. data/spec/support/vcr_cassettes/Conversions/can_split_history.yml +3 -3
  36. data/spec/support/vcr_cassettes/Conversions/can_split_preview.yml +3 -3
  37. data/spec/support/vcr_cassettes/FundingAccounts/can_find.yml +141 -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 +2 -2
  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_get_the_submission.yml +4 -4
  44. data/spec/support/vcr_cassettes/Payments/can_retrieve_confirmation.yml +3 -3
  45. data/spec/support/vcr_cassettes/Payments/can_retrieve_payment_delivery_date.yml +2 -2
  46. data/spec/support/vcr_cassettes/Payments/can_retrieve_payment_tracking_info.yml +291 -0
  47. data/spec/support/vcr_cassettes/Payments/can_retrieve_quote_payment_fee.yml +115 -0
  48. data/spec/support/vcr_cassettes/Rates/can_provided_detailed_rate_with_conversion_date_preference.yml +68 -0
  49. data/spec/support/vcr_cassettes/Reference/can_retrieve_bank_details.yml +2 -2
  50. data/spec/support/vcr_cassettes/Reference/can_retrieve_beneficiary_required_details.yml +2 -2
  51. data/spec/support/vcr_cassettes/Reference/can_retrieve_conversion_dates.yml +2 -2
  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 +225 -0
  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_conversions_report.yml +2 -2
  59. data/spec/support/vcr_cassettes/Reports/can_create_payments_report.yml +2 -2
  60. data/spec/support/vcr_cassettes/Reports/can_find_report_requests.yml +2 -2
  61. data/spec/support/vcr_cassettes/Reports/can_retrieve_report_request.yml +2 -2
  62. data/spec/support/vcr_cassettes/Settlements/can_add_conversion.yml +1 -1
  63. data/spec/support/vcr_cassettes/Settlements/can_release.yml +1 -1
  64. data/spec/support/vcr_cassettes/Settlements/can_remove_conversion.yml +1 -1
  65. data/spec/support/vcr_cassettes/Settlements/can_unrelease.yml +1 -1
  66. data/spec/support/vcr_cassettes/Transactions/can_retrieve_sender_details.yml +2 -2
  67. data/spec/support/vcr_cassettes/Transfers/can_create.yml +2 -2
  68. data/spec/support/vcr_cassettes/Transfers/can_find.yml +3 -3
  69. data/spec/support/vcr_cassettes/Transfers/can_retrieve.yml +3 -3
  70. data/spec/support/vcr_cassettes/VirtualAccounts/can_find.yml +2 -2
  71. data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_a_specific_subaccount.yml +2 -2
  72. data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_subaccounts.yml +2 -2
  73. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_find_withdrawal_accounts.yml +133 -0
  74. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_find_withdrawal_accounts2.yml +140 -0
  75. data/spec/support/vcr_cassettes/WithdrawalAccounts/can_pull_funds.yml +140 -0
  76. metadata +49 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8769ddb100767e2a3e0126d1e59096b515b962fdf8a7d916189649fcd0c67743
4
- data.tar.gz: '06812fbddff99b861924480e8bfa8d91dfc56f46567795d430660e63970768d2'
3
+ metadata.gz: 8ab773d8854600c1bc676cf305a64f1b3c87f7027e5b99a71dbe6b019e1b75d4
4
+ data.tar.gz: d6c90092195034c587e0ebf7553f7efa3cca5cabebdff2cbf30f30e3ef1387f5
5
5
  SHA512:
6
- metadata.gz: '09c4d829fc6c1ac0f72eda2e4ba1f435a17219f0fdc7982b4a8ea8a097f532b0790c77a9a7267413591595ea7437aa4b977b0a0e0cbc0b6279023ca58c66d041'
7
- data.tar.gz: 5c711b797d6814dd9c35f150f8dd7841d03c6f58dbbdb683fb44e056d5ad318ad60a379c7d91487ba2e3a35e20c5b50ea16da8c19e52b89035ab0cf2e7574d4b
6
+ metadata.gz: d1f076184d075b65e2ee64d9e32114e0bc648d29bf5039b050390bcda0a711ce78ab729af8e55e03ebdb5a81ddfb0b4831d8ca4aa66164f38e463312d3b1687f
7
+ data.tar.gz: 88bf5453a2c8591ab6aed1fc76ab0c96428ed08311577cce616458ec1449d2ab8f89ce5816141ee3e63a82f68c7640d89d258c8935d7c614c5161f831b393687
@@ -8,6 +8,8 @@ rvm:
8
8
  - 2.2
9
9
  - 2.3.4
10
10
  - 2.4.1
11
+ - 2.5.3
12
+ - 2.6.3
11
13
  - jruby-19mode
12
14
  - jruby-9.1.17.0
13
15
  - jruby-9.2.0.0
@@ -8,6 +8,7 @@ Many people have helped us along the way and we are sincerely grateful to all of
8
8
 
9
9
  |Name|Link/e-mail|
10
10
  |--|--|
11
+ |Sergei Zinin|https://github.com/einzige|
11
12
 
12
13
  In our book, they have reached [**honorificabilitudinitatibus**][sesqui] :-)
13
14
 
data/README.md CHANGED
@@ -16,16 +16,25 @@ 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
34
+ * MRI 2.3.4
35
+ * MRI 2.4.1
36
+ * MRI 2.5.3
37
+ * MRI 2.6.3
29
38
  * [JRuby][jruby]
30
39
  * [Rubinius][rubinius]
31
40
 
@@ -153,7 +162,7 @@ Deprecation means that we discourage the use of a feature, design or practice be
153
162
 
154
163
  We remove deprecated features after **three months** from the time of announcement.
155
164
 
156
- The security of our customers' assets is of paramount importance to us and sometimes we have to deprecate features because they may pose a security threat or because new, more secure, ways are available. On such occasions we reserve the right to set a different deprecation period which may range from **immediate removal** to the standard **three months**.
165
+ The security of our customers' assets is of paramount importance to us and sometimes we have to deprecate features because they may pose a security threat or because new, more secure, ways are available. On such occasions we reserve the right to set a different deprecation period which may range from **immediate removal** to the standard **three months**.
157
166
 
158
167
  Once a feature has been marked as deprecated, we no longer develop the code or implement bug fixes. We only do security fixes.
159
168
 
@@ -178,4 +187,4 @@ Copyright (c) 2016-2019 Currencycloud. See [LICENSE][license] for details.
178
187
  [semver]: http://semver.org/
179
188
  [license]: LICENSE.md
180
189
  [contr]: CONTRIBUTING.md
181
- [hof]: HALL_OF_FAME.md
190
+ [hof]: HALL_OF_FAME.md
@@ -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.4'.freeze # Gem Version
4
+ API_VERSION = "v2".freeze # API Version
5
+ VERSION = "0.17.7".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
@@ -95,4 +95,51 @@ describe 'Reference', vcr: true do
95
95
  expect(details.bank_country_ISO).to eq('GB')
96
96
  expect(details.currency).to be_nil
97
97
  end
98
+
99
+ it 'can retrieve #payment_fee_rules' do
100
+ payment_fee_rules1 = CurrencyCloud::Reference.payment_fee_rules()
101
+ expect(payment_fee_rules1.size).to eq(3)
102
+
103
+ fee_rule1_1 = payment_fee_rules1[0]
104
+ expect(fee_rule1_1).to be_a(CurrencyCloud::PaymentFeeRule)
105
+ expect(fee_rule1_1.charge_type).to eq('shared')
106
+ expect(fee_rule1_1.fee_amount).to eq('2.00')
107
+ expect(fee_rule1_1.fee_currency).to eq('AED')
108
+ expect(fee_rule1_1.payment_type).to eq('priority')
109
+
110
+ fee_rule1_2 = payment_fee_rules1[1]
111
+ expect(fee_rule1_2).to be_a(CurrencyCloud::PaymentFeeRule)
112
+ expect(fee_rule1_2.charge_type).to eq('shared')
113
+ expect(fee_rule1_2.fee_amount).to eq('12.00')
114
+ expect(fee_rule1_2.fee_currency).to eq('USD')
115
+ expect(fee_rule1_2.payment_type).to eq('regular')
116
+
117
+ fee_rule1_3 = payment_fee_rules1[2]
118
+ expect(fee_rule1_3).to be_a(CurrencyCloud::PaymentFeeRule)
119
+ expect(fee_rule1_3.charge_type).to eq('ours')
120
+ expect(fee_rule1_3.fee_amount).to eq('5.25')
121
+ expect(fee_rule1_3.fee_currency).to eq('GBP')
122
+ expect(fee_rule1_3.payment_type).to eq('priority')
123
+
124
+ payment_fee_rules2 = CurrencyCloud::Reference.payment_fee_rules(payment_type: 'regular')
125
+ expect(payment_fee_rules2.size).to eq(1)
126
+
127
+ fee_rule2_1 = payment_fee_rules2[0]
128
+ expect(fee_rule2_1).to be_a(CurrencyCloud::PaymentFeeRule)
129
+ expect(fee_rule2_1.charge_type).to eq('shared')
130
+ expect(fee_rule2_1.fee_amount).to eq('12.00')
131
+ expect(fee_rule2_1.fee_currency).to eq('USD')
132
+ expect(fee_rule2_1.payment_type).to eq('regular')
133
+
134
+ payment_fee_rules3 = CurrencyCloud::Reference.payment_fee_rules(charge_type: 'ours')
135
+ expect(payment_fee_rules3.size).to eq(1)
136
+
137
+ fee_rule3_1 = payment_fee_rules3[0]
138
+ expect(fee_rule3_1).to be_a(CurrencyCloud::PaymentFeeRule)
139
+ expect(fee_rule3_1.charge_type).to eq('ours')
140
+ expect(fee_rule3_1.fee_amount).to eq('5.25')
141
+ expect(fee_rule3_1.fee_currency).to eq('GBP')
142
+ expect(fee_rule3_1.payment_type).to eq('priority')
143
+ end
144
+
98
145
  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/0.17.7
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/0.17.7
62
62
  response:
63
63
  status:
64
64
  code: 200