Class: IbanClient::Iban
- Inherits:
-
Object
- Object
- IbanClient::Iban
- Defined in:
- lib/iban_client/iban.rb
Constant Summary collapse
- BANK_DATA_GETTER =
%w(bic bank address city state zip country country_iso account)- SEPA_DATA_GETTER =
%w(sct sdd cor1 b2b scc)- VALIDATION_MESSAGES =
{ '201' => :invalid_account_number, '202' => :invalid_iban_digit, '203' => :invalid_iban_length, '205' => :invalid_iban_structure }
Instance Attribute Summary collapse
-
#iban ⇒ Object
readonly
Returns the value of attribute iban.
Instance Method Summary collapse
- #attributes ⇒ Object
- #errors ⇒ Object
-
#initialize(iban) ⇒ Iban
constructor
A new instance of Iban.
- #valid? ⇒ Boolean
Constructor Details
#initialize(iban) ⇒ Iban
Returns a new instance of Iban.
15 16 17 |
# File 'lib/iban_client/iban.rb', line 15 def initialize(iban) @iban = iban end |
Instance Attribute Details
#iban ⇒ Object (readonly)
Returns the value of attribute iban.
13 14 15 |
# File 'lib/iban_client/iban.rb', line 13 def iban @iban end |
Instance Method Details
#attributes ⇒ Object
31 32 33 |
# File 'lib/iban_client/iban.rb', line 31 def attributes handle_result { (result['bank_data'] || {}).merge('iban' => iban) } end |
#errors ⇒ Object
39 40 41 42 43 44 |
# File 'lib/iban_client/iban.rb', line 39 def errors handle_result do (result['validations'] || []).map { |validation| VALIDATION_MESSAGES[validation['code']] } .reject(&:nil?) end end |
#valid? ⇒ Boolean
35 36 37 |
# File 'lib/iban_client/iban.rb', line 35 def valid? errors.empty? end |