Sha256: 180d0f19f1c4d6aa6c227d7de3c0eb27917477792575e5c8efbf0544e3aa2a2e

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 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.parent.file_naming_strategy.(@batch_number)
      end

      # Sends the batch to SFTP provider
      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wire_client-0.2.0 lib/wire_client/providers/sftp/wire_batch.rb
wire_client-0.1.4 lib/wire_client/providers/sftp/wire_batch.rb
wire_client-0.1.3 lib/wire_client/providers/sftp/wire_batch.rb
wire_client-0.1.2 lib/wire_client/providers/sftp/wire_batch.rb
wire_client-0.1.1 lib/wire_client/providers/sftp/wire_batch.rb
wire_client-0.1.0 lib/wire_client/providers/sftp/wire_batch.rb