Class: Io::Flow::V0::Models::OrderPlacedDetails

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

Overview

Order is submitted, allocations are generated and the total value of the order is accounted for by discounts, subsidies, credits and authorized payments – but may not ready to fulfill (e.g. pending assignment of a DC or fraud review).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderPlacedDetails

Returns a new instance of OrderPlacedDetails.



39627
39628
39629
39630
39631
39632
39633
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39627

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :order, :allocation], 'OrderPlacedDetails')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::Order) ? x : ::Io::Flow::V0::Models::Order.new(x))
  @allocation = (x = opts.delete(:allocation); x.is_a?(::Io::Flow::V0::Models::AllocationV2) ? x : ::Io::Flow::V0::Models::AllocationV2.new(x))
end

Instance Attribute Details

#allocationObject (readonly)

Returns the value of attribute allocation.



39625
39626
39627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39625

def allocation
  @allocation
end

#idObject (readonly)

Returns the value of attribute id.



39625
39626
39627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39625

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



39625
39626
39627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39625

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



39639
39640
39641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39639

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

#to_hashObject



39643
39644
39645
39646
39647
39648
39649
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39643

def to_hash
  {
    :id => id,
    :order => order.to_hash,
    :allocation => allocation.to_hash
  }
end

#to_jsonObject



39635
39636
39637
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39635

def to_json
  JSON.dump(to_hash)
end