class BankPayments::Beneficiary

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”.

@author Michael Litton

Attributes

account[RW]

IBAN

account_type[RW]

Configuration used for the address record in Swedbank SPISU

address[RW]

Required regular fields

bank_id[RW]

The BIC (Bank Identification Code) for countires within EU

bank_name[RW]

Can be empty for European payments

cost_carrier[RW]

Configuration used for the address record in Swedbank SPISU

country_code[RW]

Required regular fields

name[RW]

Required regular fields

priority[RW]

Configuration used for the address record in Swedbank SPISU

Public Class Methods

new() { |self| ... } click to toggle source

Creates a new Beneficiary object with defaults for part of the Swedbank payments

# 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

Public Instance Methods

eql?(other) click to toggle source
# File lib/bank_payments/beneficiary.rb, line 36
def eql?(other)
  instance_values == other.instance_values
end
hash() click to toggle source
# File lib/bank_payments/beneficiary.rb, line 40
def hash
  instance_values.hash
end
instance_values() click to toggle source
# 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() click to toggle source
# 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