Class: WireClient::Sftp::WireBatch

Inherits:
Abstract::WireBatch show all
Defined in:
lib/wire_client/providers/sftp/wire_batch.rb

Overview

NACHA representation of an AchBatch

Instance Method Summary collapse

Methods inherited from Abstract::WireBatch

#add_transaction, arguments, #initiator_account_number, #initiator_address_line, #initiator_bic, #initiator_city, #initiator_country, #initiator_country_subdivision, #initiator_iban, #initiator_identifier, #initiator_name, #initiator_postal_code, #initiator_wire_routing_number, #send_batch

Constructor Details

#initialize(transaction_type:, batch_number: nil) ⇒ WireBatch

Returns a new instance of WireBatch.



7
8
9
10
# 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

Instance Method Details

#batch_file_nameString

The filename used for the batch

Returns:

  • (String)

    filename to use



14
15
16
# 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_batchObject

Sends the batch to SFTP provider



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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