Class: SepaFileParser::Account
- Inherits:
-
Object
- Object
- SepaFileParser::Account
- Defined in:
- lib/sepa_file_parser/general/account.rb
Class Method Summary collapse
Instance Method Summary collapse
- #account_number ⇒ String
- #bank_name ⇒ String
- #bic ⇒ String
- #currency ⇒ String
- #iban ⇒ String
-
#initialize(iban: nil, other_id: nil, bic:, bank_name:, currency:, owner: nil) ⇒ Account
constructor
A new instance of Account.
- #other_id ⇒ String
- #owner ⇒ Object
Constructor Details
#initialize(iban: nil, other_id: nil, bic:, bank_name:, currency:, owner: nil) ⇒ Account
Returns a new instance of Account.
29 30 31 32 33 34 35 36 |
# File 'lib/sepa_file_parser/general/account.rb', line 29 def initialize(iban: nil, other_id: nil, bic:, bank_name:, currency:, owner: nil) @iban = iban @other_id = other_id @bic = bic @bank_name = bank_name @currency = currency @owner = owner end |
Class Method Details
.from_camt_data(xml_data) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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, owner: SepaFileParser::Owner.new(xml_data.xpath('Ownr')) ) end |
.from_pain_data(xml_data, currency, context) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/sepa_file_parser/general/account.rb', line 20 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_number ⇒ String
49 50 51 |
# File 'lib/sepa_file_parser/general/account.rb', line 49 def account_number iban != '' ? iban : other_id end |
#bank_name ⇒ String
59 60 61 |
# File 'lib/sepa_file_parser/general/account.rb', line 59 def bank_name @bank_name.to_s end |
#bic ⇒ String
54 55 56 |
# File 'lib/sepa_file_parser/general/account.rb', line 54 def bic @bic.to_s end |
#currency ⇒ String
64 65 66 |
# File 'lib/sepa_file_parser/general/account.rb', line 64 def currency @currency.to_s end |
#iban ⇒ String
39 40 41 |
# File 'lib/sepa_file_parser/general/account.rb', line 39 def iban @iban.to_s end |
#other_id ⇒ String
44 45 46 |
# File 'lib/sepa_file_parser/general/account.rb', line 44 def other_id @other_id.to_s end |
#owner ⇒ Object
68 69 70 |
# File 'lib/sepa_file_parser/general/account.rb', line 68 def owner @owner end |