Sha256: c93bcb7e7c59bbd5dab206d810fcc1009d03e0c059515f731f58513bd56858d9

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

module WireClient
  # Namespace for all things Sftp
  class Sftp
    # NACHA representation of an AchBatch
    class WireBatch < WireClient::Abstract::WireBatch

      def initialize(transaction_type:, batch_number: nil)
        super(transaction_type: transaction_type)
        @batch_number = batch_number
      end

      # The filename used for the batch
      # @return [String] filename to use
      def batch_file_name
        self.class.module_parent.file_naming_strategy.(@batch_number)
      end

      # Sends the batch to SFTP provider
      def do_send_batch
        file_path = File.join(
          self.class.module_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.module_parent.write_remote_file(
          file_path: file_path,
          file_body: file_body
        )
        [file_path, file_body]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wire_client-0.4.1 lib/wire_client/providers/sftp/wire_batch.rb
wire_client-0.4.0 lib/wire_client/providers/sftp/wire_batch.rb