Class: Io::Flow::V0::Models::PaymentPaypal

Inherits:
ExpandablePayment show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents on line payment

Instance Attribute Summary collapse

Attributes inherited from ExpandablePayment

#discriminator

Instance Method Summary collapse

Methods inherited from ExpandablePayment

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PaymentPaypal

Returns a new instance of PaymentPaypal.



21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21919

def initialize(incoming={})
  super(:discriminator => ExpandablePayment::Types::PAYMENT_PAYPAL)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :amount, :currency, :paypal], 'PaymentPaypal')
  @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)
  @paypal = (x = opts.delete(:paypal); x.is_a?(::Io::Flow::V0::Models::PaymentPaypalData) ? x : ::Io::Flow::V0::Models::PaymentPaypalData.new(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



21917
21918
21919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21917

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



21917
21918
21919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21917

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



21917
21918
21919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21917

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



21917
21918
21919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21917

def order
  @order
end

#paypalObject (readonly)

Returns the value of attribute paypal.



21917
21918
21919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21917

def paypal
  @paypal
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21934
21935
21936
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21934

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

#subtype_to_hashObject



21938
21939
21940
21941
21942
21943
21944
21945
21946
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21938

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

#to_jsonObject



21930
21931
21932
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21930

def to_json
  JSON.dump(to_hash)
end