Class: Io::Flow::V0::Models::CheckoutTokenOrderForm

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

Overview

Use this form to securly pass order and optional customer information to be created or updated.

Instance Attribute Summary collapse

Attributes inherited from CheckoutTokenForm

#discriminator

Instance Method Summary collapse

Methods inherited from CheckoutTokenForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ CheckoutTokenOrderForm

Returns a new instance of CheckoutTokenOrderForm.



36206
36207
36208
36209
36210
36211
36212
36213
36214
36215
36216
36217
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36206

def initialize(incoming={})
  super(:discriminator => CheckoutTokenForm::Types::CHECKOUT_TOKEN_ORDER_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:order_form, :session_id], 'CheckoutTokenOrderForm')
  @order_form = (x = opts.delete(:order_form); x.is_a?(::Io::Flow::V0::Models::OrderForm) ? x : ::Io::Flow::V0::Models::OrderForm.new(x))
  @customer = (x = opts.delete(:customer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CustomerForm) ? x : ::Io::Flow::V0::Models::CustomerForm.new(x)))
  @address_book = (x = opts.delete(:address_book); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CustomerAddressBookForm) ? x : ::Io::Flow::V0::Models::CustomerAddressBookForm.new(x)))
  @payment_sources = (x = opts.delete(:payment_sources); x.nil? ? nil : HttpClient::Preconditions.assert_class('payment_sources', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentSourceForm) ? x : ::Io::Flow::V0::Models::PaymentSourceForm.from_json(x)) })
  @session_id = HttpClient::Preconditions.assert_class('session_id', opts.delete(:session_id), String)
  @urls = (x = opts.delete(:urls); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CheckoutUrlsForm) ? x : ::Io::Flow::V0::Models::CheckoutUrlsForm.new(x)))
  @identifiers = (x = opts.delete(:identifiers); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifiers', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderSubmissionIdentifierForm) ? x : ::Io::Flow::V0::Models::OrderSubmissionIdentifierForm.new(x)) })
end

Instance Attribute Details

#address_bookObject (readonly)

Returns the value of attribute address_book.



36204
36205
36206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36204

def address_book
  @address_book
end

#customerObject (readonly)

Returns the value of attribute customer.



36204
36205
36206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36204

def customer
  @customer
end

#identifiersObject (readonly)

Returns the value of attribute identifiers.



36204
36205
36206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36204

def identifiers
  @identifiers
end

#order_formObject (readonly)

Returns the value of attribute order_form.



36204
36205
36206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36204

def order_form
  @order_form
end

#payment_sourcesObject (readonly)

Returns the value of attribute payment_sources.



36204
36205
36206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36204

def payment_sources
  @payment_sources
end

#session_idObject (readonly)

Returns the value of attribute session_id.



36204
36205
36206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36204

def session_id
  @session_id
end

#urlsObject (readonly)

Returns the value of attribute urls.



36204
36205
36206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36204

def urls
  @urls
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36223
36224
36225
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36223

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

#subtype_to_hashObject



36227
36228
36229
36230
36231
36232
36233
36234
36235
36236
36237
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36227

def subtype_to_hash
  {
    :order_form => order_form.to_hash,
    :customer => customer.nil? ? nil : customer.to_hash,
    :address_book => address_book.nil? ? nil : address_book.to_hash,
    :payment_sources => payment_sources.nil? ? nil : payment_sources.map { |o| o.to_hash },
    :session_id => session_id,
    :urls => urls.nil? ? nil : urls.to_hash,
    :identifiers => identifiers.nil? ? nil : identifiers.map { |o| o.to_hash }
  }
end

#to_jsonObject



36219
36220
36221
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36219

def to_json
  JSON.dump(to_hash)
end