Class: SepaFileParser::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/sepa_file_parser/general/account.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iban: nil, other_id: nil, bic:, bank_name:, currency:) ⇒ Account

Returns a new instance of Account.



28
29
30
31
32
33
34
# File 'lib/sepa_file_parser/general/account.rb', line 28

def initialize(iban: nil, other_id: nil, bic:, bank_name:, currency:)
  @iban      = iban
  @other_id  = other_id
  @bic       = bic
  @bank_name = bank_name
  @currency  = currency
end

Class Method Details

.from_camt_data(xml_data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sepa_file_parser/general/account.rb', line 6

def self.from_camt_data(xml_data)
  self.new(
    iban:      xml_data.xpath('Id/IBAN/text()').text,
    other_id:  xml_data.xpath('Id/Othr/Id/text()').text,
    bic:       [
      xml_data.xpath('Svcr/FinInstnId/BIC/text()').text,
      xml_data.xpath('Svcr/FinInstnId/BICFI/text()').text,
    ].reject(&:empty?).first.to_s,
    bank_name: xml_data.xpath('Svcr/FinInstnId/Nm/text()').text,
    currency:  xml_data.xpath('Ccy/text()').text,
  )
end

.from_pain_data(xml_data, currency, context) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/sepa_file_parser/general/account.rb', line 19

def self.from_pain_data(xml_data, currency, context)
  self.new(
    iban:      xml_data.xpath("#{context}Acct/Id/IBAN/text()").text,
    bic:       xml_data.xpath("#{context}Agt/FinInstnId/BIC/text()").text,
    bank_name: xml_data.xpath("#{context}/Nm/text()").text,
    currency:  currency,
  )
end

Instance Method Details

#account_numberString

Returns:



47
48
49
# File 'lib/sepa_file_parser/general/account.rb', line 47

def 
  iban != '' ? iban : other_id
end

#bank_nameString

Returns:



57
58
59
# File 'lib/sepa_file_parser/general/account.rb', line 57

def bank_name
  @bank_name.to_s
end

#bicString

Returns:



52
53
54
# File 'lib/sepa_file_parser/general/account.rb', line 52

def bic
  @bic.to_s
end

#currencyString

Returns:



62
63
64
# File 'lib/sepa_file_parser/general/account.rb', line 62

def currency
  @currency.to_s
end

#ibanString

Returns:



37
38
39
# File 'lib/sepa_file_parser/general/account.rb', line 37

def iban
  @iban.to_s
end

#other_idString

Returns:



42
43
44
# File 'lib/sepa_file_parser/general/account.rb', line 42

def other_id
  @other_id.to_s
end