Sha256: 6f500cf3f83e6c5ff5ea14ff6e289f1408d88a13fb8de7a2af54bad21a14bf8d

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

class BoletoTransactionParser
  def Parse(elements)
    @@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'

    if elements.length < 18
      throw('The expected parameter count is 18')
    end

    boleto_transaction = BoletoTransactionReportFile.new
    boleto_transaction.Order.OrderKey = elements[1]
    boleto_transaction.Order.OrderReference = elements[2]
    boleto_transaction.Order.MerchantKey = elements[3]
    boleto_transaction.Order.MerchantName = elements[4]

    boleto_transaction.TransactionKey = elements[5]
    boleto_transaction.TransactionReference = elements[6]
    boleto_transaction.Status = elements[7]
    boleto_transaction.NossoNumero = elements[8]
    boleto_transaction.BankNumber = elements[9]
    boleto_transaction.Agency = elements[10]
    boleto_transaction.Account = elements[11]
    boleto_transaction.BarCode = elements[12]
    boleto_transaction.ExpirationDate = DateTime.strptime(elements[13],'%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT)
    boleto_transaction.AmountInCents = elements[14].to_i
    boleto_transaction.AmountPaidInCents = (elements[15].to_s == '') == false ? elements[15].to_i : 0
    boleto_transaction.PaymentDate = (elements[16].to_s == '') == false ? DateTime.strptime(elements[16], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
    boleto_transaction.CreditDate = (elements[17].chomp.to_s == '') == false ? DateTime.strptime(elements[17], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil

    return boleto_transaction
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

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