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
28 29 30 31 32 |
# File 'lib/loqate/bank/gateway.rb', line 28 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.
52 53 54 55 56 |
# File 'lib/loqate/bank/gateway.rb', line 52 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.
147 148 149 |
# File 'lib/loqate/bank/gateway.rb', line 147 def batch_validate_accounts!() unwrap_result_or_raise { batch_validate_accounts() } end |
#retrieve_by_sortcode(options) ⇒ Result
Returns details of the holding branch.
104 105 106 107 108 |
# File 'lib/loqate/bank/gateway.rb', line 104 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.
197 198 199 |
# File 'lib/loqate/bank/gateway.rb', line 197 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.
70 71 72 73 74 75 |
# File 'lib/loqate/bank/gateway.rb', line 70 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.
165 166 167 |
# File 'lib/loqate/bank/gateway.rb', line 165 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.
121 122 123 124 125 |
# File 'lib/loqate/bank/gateway.rb', line 121 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.
214 215 216 |
# File 'lib/loqate/bank/gateway.rb', line 214 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.
87 88 89 90 91 92 |
# File 'lib/loqate/bank/gateway.rb', line 87 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.
181 182 183 |
# File 'lib/loqate/bank/gateway.rb', line 181 def validate_international_account!() unwrap_result_or_raise { validate_international_account() } end |