Sha256: 17e995805d7010a9ddca26a16607adfd1d37aff92bab69ffff77fb5668dd8a44

Contents?: true

Size: 849 Bytes

Versions: 5

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

require 'time'
require 'credit_gateway/base_model'
require 'credit_gateway/transaction'
require 'credit_gateway/balance'
require 'credit_gateway/bank_account'

module CreditGateway
  class BankData < BaseModel
    attributes :transactions, :balances, :account, :last_booking_date_time

    def self.build(json:)
      super.tap do |record|
        record.transactions = (record.transactions || []).compact.map do |t|
          Transaction.build(json: t)
        end
        record.balances = (record.balances || []).compact.map do |b|
          Balance.build(json: b)
        end
        record.account = BankAccount.build(json: (record.account || {}))
        if record.last_booking_date_time
          record.last_booking_date_time = Time.parse(record.last_booking_date_time)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
credit_gateway-0.3.2 lib/credit_gateway/bank_data.rb
credit_gateway-0.3.1 lib/credit_gateway/bank_data.rb
credit_gateway-0.3.0 lib/credit_gateway/bank_data.rb
credit_gateway-0.1.1 lib/credit_gateway/bank_data.rb
credit_gateway-0.1.0 lib/credit_gateway/bank_data.rb