Sha256: 1e73cf8b62d7ca4b406face54774efff8e8d1fe596dcc2b1507585ffafa576af

Contents?: true

Size: 947 Bytes

Versions: 3

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true

require 'bigdecimal'
require 'time'

module Tikkie
  module Api
    module Responses
      # Payment that is associated with a payment request.
      class Payment < Base
        def payment_token
          data[:paymentToken]
        end

        def counter_party_name
          data[:counterPartyName]
        end

        def amount
          decimal = BigDecimal(data[:amountInCents])
          decimal /= 100.0
          decimal
        end

        def currency
          data[:amountCurrency]
        end

        def description
          data[:description]
        end

        def created_at
          Time.parse(data[:created]) if data[:created]
        end

        # See PaymentStatus
        def online_payment_status
          data[:onlinePaymentStatus]
        end

        def paid?
          online_payment_status == Tikkie::Api::Types::PaymentStatus::PAID
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tikkie-api-0.2.2 lib/tikkie/api/responses/payment.rb
tikkie-api-0.2.1 lib/tikkie/api/responses/payment.rb
tikkie-api-0.2.0 lib/tikkie/api/responses/payment.rb