diff --git a/lib/currency_cloud/account_verification.rb b/lib/currency_cloud/account_verification.rb new file mode 100644 index 0000000..11d882f --- /dev/null +++ b/lib/currency_cloud/account_verification.rb @@ -0,0 +1,5 @@ +module CurrencyCloud + class AccountVerification + include CurrencyCloud::Resource + end +end \ No newline at end of file diff --git a/lib/currency_cloud/beneficiary.rb b/lib/currency_cloud/beneficiary.rb index 8ab3b8e..8c7f95b 100644 --- a/lib/currency_cloud/beneficiary.rb +++ b/lib/currency_cloud/beneficiary.rb @@ -9,5 +9,9 @@ class Beneficiary def self.validate(params) new(client.post('validate', params)) end + + def self.account_verification(params) + result = AccountVerification::new(client.post('account_verification', params)) + end end end diff --git a/spec/integration/actions_spec.rb b/spec/integration/actions_spec.rb index 89dba59..b1b3153 100644 --- a/spec/integration/actions_spec.rb +++ b/spec/integration/actions_spec.rb @@ -128,6 +128,30 @@ expect(beneficiary.payment_types).to include('regular') end + it 'can #account_verify beneficiaries' do + params = { + bank_country: 'GB', + account_number: '12345678', + routing_code_type_1: 'sort_code', + routing_code_value_1: '123456', + payment_type: 'regular', + beneficiary_entity_type: 'individual', + beneficiary_first_name: 'test', + beneficiary_last_name: 'last', + } + + puts "test1" + account_verifaction = CurrencyCloud::Beneficiary.account_verification(params) + puts "test3" + + expect(account_verifaction).to be_a_kind_of(CurrencyCloud::AccountVerification) + + expect(account_verifaction.actual_name).to include('test last') + expect(account_verifaction.reason_code).to include('AV100') + expect(account_verifaction.answer).to include('full_match') + expect(account_verifaction.reason_type).to include('okay') + end + it 'can use #currency to retrieve balance' do balance = CurrencyCloud::Balance.currency('GBP') diff --git a/spec/support/vcr_cassettes/Actions/can_account_verify_beneficiaries.yml b/spec/support/vcr_cassettes/Actions/can_account_verify_beneficiaries.yml new file mode 100644 index 0000000..ea880e5 --- /dev/null +++ b/spec/support/vcr_cassettes/Actions/can_account_verify_beneficiaries.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: post + uri: https://devapi.currencycloud.com/v2/beneficiaries/account_verification + body: + encoding: UTF-8 + string: bank_country=GB&account_number=12345678&routing_code_type_1=sort_code&routing_code_value_1=123456&payment_type=regular&beneficiary_entity_type=individual&beneficiary_first_name=test&beneficiary_last_name=last + headers: + X-Auth-Token: + - bbdd421bdda373ea69670c9101fa9197 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Sun, 03 May 2015 16:55:03 GMT + Content-Type: + - application/json;charset=utf-8 + Content-Length: + - '126' + Connection: + - keep-alive + X-Request-Id: + - '2777975414238700878' + X-Content-Type-Options: + - nosniff + body: + encoding: UTF-8 + string: '{ "answer": "full_match", "actual_name": "test last", "reason_code": "AV100", "reason": "Full match.", "reason_type": "okay" }' + http_version: + recorded_at: Sun, 03 May 2015 16:55:03 GMT +recorded_with: VCR 2.9.3 \ No newline at end of file diff --git a/spec/support/vcr_cassettes/Actions/can_validate_beneficiaries.yml b/spec/support/vcr_cassettes/Actions/can_validate_beneficiaries.yml index b69c8df..ac054f3 100644 --- a/spec/support/vcr_cassettes/Actions/can_validate_beneficiaries.yml +++ b/spec/support/vcr_cassettes/Actions/can_validate_beneficiaries.yml @@ -35,4 +35,4 @@ http_interactions: Wimbledon Hill Rd","Wimbledon","London"]}' http_version: recorded_at: Sun, 03 May 2015 16:55:03 GMT -recorded_with: VCR 2.9.3 +recorded_with: VCR 2.9.3 \ No newline at end of file