Class: Ibandit::Sweden::LocalDetailsConverter
- Inherits:
-
Object
- Object
- Ibandit::Sweden::LocalDetailsConverter
- Defined in:
- lib/ibandit/sweden/local_details_converter.rb
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(branch_code: nil, account_number: nil) ⇒ LocalDetailsConverter
constructor
Converts local Swedish details into SWIFT details.
Constructor Details
#initialize(branch_code: nil, account_number: nil) ⇒ LocalDetailsConverter
Converts local Swedish details into SWIFT details.
Local details can be provided as either:
-
branch_code: clearing number, account_number: serial number
-
branch_code: nil, account_number: #number#number
The reverse conversion (extracting local details from SWIFT details) is not possible, since the clearing number cannot be derived. You should NOT pass this class a SWIFT account number, as it will not convert it to local details successfully.
16 17 18 19 |
# File 'lib/ibandit/sweden/local_details_converter.rb', line 16 def initialize(branch_code: nil, account_number: nil) @branch_code = branch_code @account_number = account_number end |
Instance Method Details
#convert ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ibandit/sweden/local_details_converter.rb', line 21 def convert if bank_info.nil? return { swift_bank_code: nil, swift_account_number: cleaned_account_number.rjust(17, "0") } end { account_number: serial_number, branch_code: clearing_code, swift_bank_code: bank_info.fetch(:bank_code).to_s, swift_account_number: swift_account_number, } end |