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.



35336
35337
35338
35339
35340
35341
35342
35343
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35336

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.



35334
35335
35336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35334

def destination
  @destination
end

#numberObject (readonly)

Returns the value of attribute number.



35334
35335
35336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35334

def number
  @number
end

#paymentsObject (readonly)

Returns the value of attribute payments.



35334
35335
35336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35334

def payments
  @payments
end

#submitted_atObject (readonly)

Returns the value of attribute submitted_at.



35334
35335
35336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35334

def 
  @submitted_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35349
35350
35351
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35349

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

#to_hashObject



35353
35354
35355
35356
35357
35358
35359
35360
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35353

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

#to_jsonObject



35345
35346
35347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35345

def to_json
  JSON.dump(to_hash)
end