Sha256: a1901e25033d5715a8b082c2b35827dee09d795069c24d33c701af3c0920f38d

Contents?: true

Size: 1.34 KB

Versions: 9

Compression:

Stored size: 1.34 KB

Contents

class TransactionReportFile
  def TransactionReportFileParser(file_to_parse)
    response = {}
    response['CreditCardTransaction'] = []
    response['OnlineDebitTransaction'] = []
    response['BoletoTransaction'] = []

    header_parser = HeaderParser.new
    credit_card_parser = CreditCardTransactionParser.new
    boleto_parser = BoletoTransactionParser.new
    online_debit_parser = OnlineDebitTransactionParser.new
    trailer_parser = TrailerParser.new

    begin
      response_splited = file_to_parse.split("\n")

      response_splited.each do |item|

        to_parse_item = item.split(',')
        if to_parse_item[0] == '01'
          response['Header'] = header_parser.Parse(to_parse_item)
        end

        if to_parse_item[0] == '20'
          response['CreditCardTransaction'] << credit_card_parser.Parse(to_parse_item)
        end

        if to_parse_item[0] == '40'
          response['OnlineDebitTransaction'] << online_debit_parser.Parse(to_parse_item)
        end

        if to_parse_item[0] == '30'
          response['BoletoTransaction'] << boleto_parser.Parse(to_parse_item)
        end

        if to_parse_item[0] == '99'
          response['Trailer'] = trailer_parser.Parse(to_parse_item)
        end
      end
    rescue Exception=>err
      return err
    end
    return response
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mundipagg_sdk-1.0.2 lib/gateway/transaction_report_file.rb
mundipagg_sdk-1.0.1 lib/gateway/transaction_report_file.rb
mundipagg_sdk-1.0.0 lib/gateway/transaction_report_file.rb
mundipagg_api-1.3.1 lib/mundipagg/transaction_report_file.rb
mundipagg_api-1.3.0 lib/mundipagg/transaction_report_file.rb
mundipagg_api-1.1.1 lib/mundipagg/transaction_report_file.rb
mundipagg_api-1.1.0 lib/mundipagg/transaction_report_file.rb
mundipagg_api-1.0.1 lib/mundipagg/transaction_report_file.rb
mundipagg_api-1.0.0 lib/mundipagg/transaction_report_file.rb