Class: Io::Flow::V0::Models::CustomerOrder

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

Overview

Order details pertaining to a customer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CustomerOrder

Returns a new instance of CustomerOrder.



28467
28468
28469
28470
28471
28472
28473
28474
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28467

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :destination], 'CustomerOrder')
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x))
  @payments = (x = opts.delete(:payments); x.nil? ? nil : HttpClient::Preconditions.assert_class('payments', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderPayment) ? x : ::Io::Flow::V0::Models::OrderPayment.new(x)) })
  @submitted_at = (x = opts.delete(:submitted_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('submitted_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



28465
28466
28467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28465

def destination
  @destination
end

#numberObject (readonly)

Returns the value of attribute number.



28465
28466
28467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28465

def number
  @number
end

#paymentsObject (readonly)

Returns the value of attribute payments.



28465
28466
28467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28465

def payments
  @payments
end

#submitted_atObject (readonly)

Returns the value of attribute submitted_at.



28465
28466
28467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28465

def 
  @submitted_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28480
28481
28482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28480

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

#to_hashObject



28484
28485
28486
28487
28488
28489
28490
28491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28484

def to_hash
  {
    :number => number,
    :destination => destination.to_hash,
    :payments => payments.nil? ? nil : payments.map { |o| o.to_hash },
    :submitted_at => 
  }
end

#to_jsonObject



28476
28477
28478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28476

def to_json
  JSON.dump(to_hash)
end