Class: Loqate::Bank::Gateway
- Inherits:
-
Object
- Object
- Loqate::Bank::Gateway
- Includes:
- Result::Mixin
- Defined in:
- lib/loqate/bank/gateway.rb
Overview
Validates bank accounts, branches and cards.
Constant Summary collapse
- RETRIEVE_BY_SORTCODE_ENDPOINT =
'/BankAccountValidation/Interactive/RetrieveBySortcode/v1.00/json3.ws'.freeze
- VALIDATE_CARD_ENDPOINT =
'/CardValidation/Interactive/Validate/v1/json3.ws'.freeze
- VALIDATE_ACCOUNT_ENDPOINT =
'/BankAccountValidation/Interactive/Validate/v2/json3.ws'.freeze
- VALIDATE_ACCOUNTS_ENDPOINT =
'/BankAccountValidation/Batch/Validate/v1/json3.ws'.freeze
- VALIDATE_INT_ACCOUNT_ENDPOINT =
'/InternationalBankValidation/Interactive/Validate/v1/json3.ws'.freeze
Constants included from Result::Mixin
Result::Mixin::Failure, Result::Mixin::Success
Instance Method Summary collapse
-
#batch_validate_accounts(options) ⇒ Result
Batch validates the bank account and sort code for an UK bank account are correct.
-
#batch_validate_accounts!(options) ⇒ Array<BatchAccountValidation>
Batch validates the bank account and sort code for an UK bank account are correct.
-
#initialize(client) ⇒ Gateway
constructor
Creates a bank gateway.
-
#retrieve_by_sortcode(options) ⇒ Result
Returns details of the holding branch.
-
#retrieve_by_sortcode!(options) ⇒ Branch
Returns details of the holding branch.
-
#validate_account(options) ⇒ Result
Validates the bank account and sort code for an UK bank account are correct.
-
#validate_account!(options) ⇒ AccountValidation
Validates the bank account and sort code for an UK bank account are correct.
-
#validate_card(options) ⇒ Result
Validates the credit card number follows the correct format for the card type.
-
#validate_card!(options) ⇒ CardValidation
Validates the credit card number follows the correct format for the card type.
-
#validate_international_account(options) ⇒ Result
Validates if the international bank account number for an international bank account is correct.
-
#validate_international_account!(options) ⇒ InternationalAccountValidation
Validates if the international bank account number for an international bank account is correct.
Methods included from Result::Mixin
#Failure, #Success, #unwrap_result_or_raise
Constructor Details
#initialize(client) ⇒ Gateway
Creates a bank gateway
29 30 31 32 33 |
# File 'lib/loqate/bank/gateway.rb', line 29 def initialize(client) @client = client @mapper = Mappers::GenericMapper.new @error_mapper = Mappers::ErrorMapper.new end |
Instance Method Details
#batch_validate_accounts(options) ⇒ Result
Batch validates the bank account and sort code for an UK bank account are correct. Returns details of the holding branch, IBAN and correct BACS account details.
53 54 55 56 57 |
# File 'lib/loqate/bank/gateway.rb', line 53 def batch_validate_accounts() response = client.get(VALIDATE_ACCOUNTS_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_account_validations_from(response.items) end |
#batch_validate_accounts!(options) ⇒ Array<BatchAccountValidation>
Batch validates the bank account and sort code for an UK bank account are correct. Returns details of the holding branch, IBAN and correct BACS account details.
148 149 150 |
# File 'lib/loqate/bank/gateway.rb', line 148 def batch_validate_accounts!() unwrap_result_or_raise { batch_validate_accounts() } end |
#retrieve_by_sortcode(options) ⇒ Result
Returns details of the holding branch.
105 106 107 108 109 |
# File 'lib/loqate/bank/gateway.rb', line 105 def retrieve_by_sortcode() response = client.get(RETRIEVE_BY_SORTCODE_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_branch_from(response.items) end |
#retrieve_by_sortcode!(options) ⇒ Branch
Returns details of the holding branch.
198 199 200 |
# File 'lib/loqate/bank/gateway.rb', line 198 def retrieve_by_sortcode!() unwrap_result_or_raise { retrieve_by_sortcode() } end |
#validate_account(options) ⇒ Result
Validates the bank account and sort code for an UK bank account are correct. Returns details of the holding branch, IBAN and correct BACS account details.
71 72 73 74 75 76 |
# File 'lib/loqate/bank/gateway.rb', line 71 def validate_account() response = client.get(VALIDATE_ACCOUNT_ENDPOINT, ) first_result = response.items.first response.errors? && build_error_from(first_result) || build_account_validation_from(first_result) end |
#validate_account!(options) ⇒ AccountValidation
Validates the bank account and sort code for an UK bank account are correct. Returns details of the holding branch, IBAN and correct BACS account details.
166 167 168 |
# File 'lib/loqate/bank/gateway.rb', line 166 def validate_account!() unwrap_result_or_raise { validate_account() } end |
#validate_card(options) ⇒ Result
Validates the credit card number follows the correct format for the card type.
122 123 124 125 126 |
# File 'lib/loqate/bank/gateway.rb', line 122 def validate_card() response = client.get(VALIDATE_CARD_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_card_validation_from(response.items.first) end |
#validate_card!(options) ⇒ CardValidation
Validates the credit card number follows the correct format for the card type.
215 216 217 |
# File 'lib/loqate/bank/gateway.rb', line 215 def validate_card!() unwrap_result_or_raise { validate_card() } end |
#validate_international_account(options) ⇒ Result
Validates if the international bank account number for an international bank account is correct.
88 89 90 91 92 93 |
# File 'lib/loqate/bank/gateway.rb', line 88 def validate_international_account() response = client.get(VALIDATE_INT_ACCOUNT_ENDPOINT, ) first_result = response.items.first response.errors? && build_error_from(first_result) || build_int_acc_validation_from(first_result) end |
#validate_international_account!(options) ⇒ InternationalAccountValidation
Validates if the international bank account number for an international bank account is correct.
182 183 184 |
# File 'lib/loqate/bank/gateway.rb', line 182 def validate_international_account!() unwrap_result_or_raise { validate_international_account() } end |