Class: AchClient::SiliconValleyBank::AchBatch
- Inherits:
-
Abstract::AchBatch
- Object
- Abstract::AchBatch
- AchClient::SiliconValleyBank::AchBatch
- Defined in:
- lib/ach_client/providers/sftp/silicon_valley_bank/ach_batch.rb
Overview
SiliconValleyBank implementation of an ach batch
Instance Method Summary collapse
-
#cook_some_nachas ⇒ ACH::ACHFile
Converts this AchBatch into the NACHA object representation provided by the ACH gem.
-
#send_batch ⇒ Array<String>
Sends the batch to SVB.
Methods inherited from Abstract::AchBatch
Constructor Details
This class inherits a constructor from AchClient::Abstract::AchBatch
Instance Method Details
#cook_some_nachas ⇒ ACH::ACHFile
Converts this AchBatch into the NACHA object representation provided by the ACH gem.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ach_client/providers/sftp/silicon_valley_bank/ach_batch.rb', line 20 def cook_some_nachas nacha = ACH::ACHFile.new nacha.instance_variable_set(:@header, nacha_file_header) # The NACHA can have multiple batches. # Transactions in the same batch must have the same originator and # sec_code, so we group by sec_code and originator when building batches @ach_transactions.group_by(&:sec_code).map do |sec_code, transactions| transactions.group_by(&:originator_name) .map do |originator_name, batch_transactions| nacha.batches << nacha_batch( sec_code, originator_name, batch_transactions ) end end nacha end |
#send_batch ⇒ Array<String>
Sends the batch to SVB
8 9 10 11 12 13 14 15 |
# File 'lib/ach_client/providers/sftp/silicon_valley_bank/ach_batch.rb', line 8 def send_batch AchClient::SiliconValleyBank.write_remote_file( file_path: AchClient::SiliconValleyBank::AchFilenameBuilder.next_file_name, file_body: cook_some_nachas.to_s ) @ach_transactions.map(&:external_ach_id) end |