Sha256: 6c147ea6a8e2924f35ed01462b2bbb9b2b39d75674352e5314b96b6a376dbea6
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'securerandom' require 'date' module Bambora::BatchUpload class CreateBatchFile attr_accessor :txn_array def initialize(txn_array) @txn_array = txn_array end def call create_file end private def create_file string = file_content begin path = "#{Bambora::BatchUpload.get_batch_file_path}/#{batch_file_name}" file = File.open(path, "w") file.write(string) rescue IOError => e puts "Write Fail" ensure file.close unless file.nil? end path end def batch_file_name file_name = "#{SecureRandom.hex(4)}_#{DateTime.now.strftime("%b_%d_%Y_%H:%M:%S:%L")}.txt" end def file_content string = "" txn_array.each do |txn| string << "E," string << "#{txn.txn_type}," #C for Credit, D for Debit string << "#{txn.transit}," string << "#{txn.institution}," string << "#{txn.account}," string << "#{txn.amount}," string << "#{txn.ref}," string << "#{txn.recipient}," string << "#{txn.customer_code}" string << "\r\n" end string end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bambora-batch_upload-0.1.0 | lib/bambora/batch_upload/create_batch_file.rb |