Sha256: 573d5ba0c463c0a9a44c8167384d30e026c7844dd37c6f9604c23237e8f11be0

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

module RockRMS
  module Response
    class Transaction < Base
      MAP = {
        date: 'TransactionDateTime',
        person: 'AuthorizedPersonAlias',
        person_id: 'AuthorizedPersonAliasId',
        batch_id: 'BatchId',
        gateway_id: 'FinancialGatewayId',
        recurring_donation_id: 'ScheduledTransactionId',
        summary: 'Summary',
        transaction_code: 'TransactionCode',
        details: 'TransactionDetails',
        payment_details: 'FinancialPaymentDetail',
        payment_detail_id: 'FinancialPaymentDetailId',
        transaction_type_id: 'TransactionTypeValueId'
      }.freeze


      def format_single(data)
        response                   = to_h(MAP, data)
        response[:details]         = TransactionDetail.format(response[:details])
        response[:payment_details] = PaymentDetail.format(response[:payment_details])
        response[:person]          = format_person(response[:person])
        response[:amount]          = calculate_total(response[:details])
        response
      end

      def format_person(res)
        return res if res.nil?
        Person.format(res['Person'])
      end

      def calculate_total(details)
        details.reduce(0) { |sum, td| sum + td[:amount] }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rock_rms-8.2.1 lib/rock_rms/response/transaction.rb
rock_rms-8.2.0 lib/rock_rms/response/transaction.rb
rock_rms-8.1.0 lib/rock_rms/response/transaction.rb
rock_rms-8.0.0 lib/rock_rms/response/transaction.rb
rock_rms-7.4.0 lib/rock_rms/response/transaction.rb
rock_rms-7.3.0 lib/rock_rms/response/transaction.rb
rock_rms-7.2.0 lib/rock_rms/response/transaction.rb
rock_rms-7.1.2 lib/rock_rms/response/transaction.rb
rock_rms-7.1.1 lib/rock_rms/response/transaction.rb
rock_rms-7.1.0 lib/rock_rms/response/transaction.rb
rock_rms-7.0.3 lib/rock_rms/response/transaction.rb