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.



26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26498

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.



26496
26497
26498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26496

def address_book
  @address_book
end

#customerObject (readonly)

Returns the value of attribute customer.



26496
26497
26498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26496

def customer
  @customer
end

#identifiersObject (readonly)

Returns the value of attribute identifiers.



26496
26497
26498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26496

def identifiers
  @identifiers
end

#order_formObject (readonly)

Returns the value of attribute order_form.



26496
26497
26498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26496

def order_form
  @order_form
end

#payment_sourcesObject (readonly)

Returns the value of attribute payment_sources.



26496
26497
26498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26496

def payment_sources
  @payment_sources
end

#session_idObject (readonly)

Returns the value of attribute session_id.



26496
26497
26498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26496

def session_id
  @session_id
end

#urlsObject (readonly)

Returns the value of attribute urls.



26496
26497
26498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26496

def urls
  @urls
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26515
26516
26517
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26515

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

#subtype_to_hashObject



26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26519

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



26511
26512
26513
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26511

def to_json
  JSON.dump(to_hash)
end