class WireClient::Sftp::WireBatch

NACHA representation of an AchBatch

Public Class Methods

new(transaction_type:, batch_number: nil) click to toggle source
Calls superclass method WireClient::Abstract::WireBatch::new
# File lib/wire_client/providers/sftp/wire_batch.rb, line 7
def initialize(transaction_type:, batch_number: nil)
  super(transaction_type: transaction_type)
  @batch_number = batch_number
end

Public Instance Methods

batch_file_name() click to toggle source

The filename used for the batch @return [String] filename to use

# File lib/wire_client/providers/sftp/wire_batch.rb, line 14
def batch_file_name
  self.class.parent.file_naming_strategy.(@batch_number)
end
do_send_batch() click to toggle source

Sends the batch to SFTP provider

# File lib/wire_client/providers/sftp/wire_batch.rb, line 19
def do_send_batch
  file_path = File.join(
    self.class.parent.outgoing_path,
    batch_file_name
  )
  file_body = begin
    if @transaction_type == WireClient::TransactionTypes::Credit
      @payment_initiation.to_xml('pain.001.001.03').to_s
    else
      @payment_initiation.to_xml('pain.008.001.02').to_s
    end
  end
  self.class.parent.write_remote_file(
    file_path: file_path,
    file_body: file_body
  )
  [file_path, file_body]
end