Class: BankPayments::Beneficiary
- Inherits:
-
Object
- Object
- BankPayments::Beneficiary
- Defined in:
- lib/bank_payments/beneficiary.rb
Overview
Encapulates all the information about the destination of a payment. We choose this class name since this is what Swedbank seems to call it on their english homepage. Another viable option is also “Payee”.
Instance Attribute Summary collapse
-
#account ⇒ Object
IBAN.
-
#account_type ⇒ Object
Configuration used for the address record in Swedbank SPISU.
-
#address ⇒ Object
Required regular fields.
-
#bank_id ⇒ Object
The BIC (Bank Identification Code) for countires within EU.
-
#bank_name ⇒ Object
Can be empty for European payments.
-
#cost_carrier ⇒ Object
Configuration used for the address record in Swedbank SPISU.
-
#country_code ⇒ Object
Required regular fields.
-
#name ⇒ Object
Required regular fields.
-
#priority ⇒ Object
Configuration used for the address record in Swedbank SPISU.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize {|_self| ... } ⇒ Beneficiary
constructor
Creates a new Beneficiary object with defaults for part of the Swedbank payments.
- #instance_values ⇒ Object
- #to_spisu_records ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Beneficiary
Creates a new Beneficiary object with defaults for part of the Swedbank payments
27 28 29 30 31 32 33 34 |
# File 'lib/bank_payments/beneficiary.rb', line 27 def initialize yield self if block_given? # Set sensible defaults @account_type ||= BankPayments::SwedbankExport::AccountType::CURRENCY_ACCOUNT @cost_carrier ||= BankPayments::SwedbankExport::CostResponsibility::OWN_EXPENSES @priority ||= BankPayments::SwedbankExport::Priority::NORMAL end |
Instance Attribute Details
#account ⇒ Object
IBAN
20 21 22 |
# File 'lib/bank_payments/beneficiary.rb', line 20 def account @account end |
#account_type ⇒ Object
Configuration used for the address record in Swedbank SPISU
23 24 25 |
# File 'lib/bank_payments/beneficiary.rb', line 23 def account_type @account_type end |
#address ⇒ Object
Required regular fields
11 12 13 |
# File 'lib/bank_payments/beneficiary.rb', line 11 def address @address end |
#bank_id ⇒ Object
The BIC (Bank Identification Code) for countires within EU
14 15 16 |
# File 'lib/bank_payments/beneficiary.rb', line 14 def bank_id @bank_id end |
#bank_name ⇒ Object
Can be empty for European payments
17 18 19 |
# File 'lib/bank_payments/beneficiary.rb', line 17 def bank_name @bank_name end |
#cost_carrier ⇒ Object
Configuration used for the address record in Swedbank SPISU
23 24 25 |
# File 'lib/bank_payments/beneficiary.rb', line 23 def cost_carrier @cost_carrier end |
#country_code ⇒ Object
Required regular fields
11 12 13 |
# File 'lib/bank_payments/beneficiary.rb', line 11 def country_code @country_code end |
#name ⇒ Object
Required regular fields
11 12 13 |
# File 'lib/bank_payments/beneficiary.rb', line 11 def name @name end |
#priority ⇒ Object
Configuration used for the address record in Swedbank SPISU
23 24 25 |
# File 'lib/bank_payments/beneficiary.rb', line 23 def priority @priority end |
Instance Method Details
#eql?(other) ⇒ Boolean
36 37 38 |
# File 'lib/bank_payments/beneficiary.rb', line 36 def eql?(other) instance_values == other.instance_values end |
#hash ⇒ Object
40 41 42 |
# File 'lib/bank_payments/beneficiary.rb', line 40 def hash instance_values.hash end |
#instance_values ⇒ Object
44 45 46 47 48 |
# File 'lib/bank_payments/beneficiary.rb', line 44 def instance_values Hash[instance_variables.map do |variable| [variable[1..-1], instance_variable_get(variable)] end] end |
#to_spisu_records ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bank_payments/beneficiary.rb', line 50 def to_spisu_records name = BankPayments::SwedbankExport::NameRecord.new name.name = @name address = BankPayments::SwedbankExport::AddressRecord.new address.address = @address address.country_code = @country_code address.account_type = @account_type address.cost_carrier = @cost_carrier address.priority = @priority bank = BankPayments::SwedbankExport::BankRecord.new bank.bank_id = @bank_id bank.name = @bank_name || '' bank.account = @account [name, address, bank] end |