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

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

Overview

Represents an online payment processed through PayPal.

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 = {}) ⇒ PaymentPaypal

Returns a new instance of PaymentPaypal.



58293
58294
58295
58296
58297
58298
58299
58300
58301
58302
58303
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58293

def initialize(incoming={})
  super(:discriminator => Payment::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)
  @created_at = (x = opts.delete(:created_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @paypal = (x = opts.delete(:paypal); 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.



58291
58292
58293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58291

def amount
  @amount
end

#created_atObject (readonly)

Returns the value of attribute created_at.



58291
58292
58293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58291

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



58291
58292
58293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58291

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



58291
58292
58293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58291

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



58291
58292
58293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58291

def order
  @order
end

#paypalObject (readonly)

Returns the value of attribute paypal.



58291
58292
58293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58291

def paypal
  @paypal
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



58309
58310
58311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58309

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

#subtype_to_hashObject



58313
58314
58315
58316
58317
58318
58319
58320
58321
58322
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58313

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

#to_jsonObject



58305
58306
58307
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58305

def to_json
  JSON.dump(to_hash)
end