Class: Io::Flow::V0::Models::PaymentCryptopay

Inherits:
Payment
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents an online payment processed through CryptoPay.

Instance Attribute Summary collapse

Attributes inherited from Payment

#discriminator

Instance Method Summary collapse

Methods inherited from Payment

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PaymentCryptopay

Returns a new instance of PaymentCryptopay.



43912
43913
43914
43915
43916
43917
43918
43919
43920
43921
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43912

def initialize(incoming={})
  super(:discriminator => Payment::Types::PAYMENT_CRYPTOPAY)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :amount, :currency, :cryptopay], 'PaymentCryptopay')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AuthorizationOrderReference) ? x : ::Io::Flow::V0::Models::AuthorizationOrderReference.new(x)))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @cryptopay = (x = opts.delete(:cryptopay); x.is_a?(::Io::Flow::V0::Models::OnlineAuthorizationDetails) ? x : ::Io::Flow::V0::Models::OnlineAuthorizationDetails.from_json(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



43910
43911
43912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43910

def amount
  @amount
end

#cryptopayObject (readonly)

Returns the value of attribute cryptopay.



43910
43911
43912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43910

def cryptopay
  @cryptopay
end

#currencyObject (readonly)

Returns the value of attribute currency.



43910
43911
43912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43910

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



43910
43911
43912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43910

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



43910
43911
43912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43910

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



43927
43928
43929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43927

def copy(incoming={})
  PaymentCryptopay.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



43931
43932
43933
43934
43935
43936
43937
43938
43939
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43931

def subtype_to_hash
  {
    :id => id,
    :order => order.nil? ? nil : order.to_hash,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :cryptopay => cryptopay.to_hash
  }
end

#to_jsonObject



43923
43924
43925
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43923

def to_json
  JSON.dump(to_hash)
end