Class: Io::Flow::V0::Models::OrderPutForm

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

Overview

The order put form is used to upsert an order, providing the details on pricing and delivery options for destination and items/quantities specified.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderPutForm

Returns a new instance of OrderPutForm.



14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14762

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:destination, :items], 'OrderPutForm')
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }
  @customer = (x = opts.delete(:customer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Customer) ? x : ::Io::Flow::V0::Models::Customer.new(x)))
  @selections = (x = opts.delete(:selections); x.nil? ? nil : HttpClient::Preconditions.assert_class('selections', x, Array).map { |v| HttpClient::Preconditions.assert_class('selections', v, String) })
  @discount = (x = opts.delete(:discount); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x)))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



14760
14761
14762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14760

def attributes
  @attributes
end

#customerObject (readonly)

Returns the value of attribute customer.



14760
14761
14762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14760

def customer
  @customer
end

#destinationObject (readonly)

Returns the value of attribute destination.



14760
14761
14762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14760

def destination
  @destination
end

#discountObject (readonly)

Returns the value of attribute discount.



14760
14761
14762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14760

def discount
  @discount
end

#itemsObject (readonly)

Returns the value of attribute items.



14760
14761
14762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14760

def items
  @items
end

#selectionsObject (readonly)

Returns the value of attribute selections.



14760
14761
14762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14760

def selections
  @selections
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14777
14778
14779
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14777

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

#to_hashObject



14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14781

def to_hash
  {
    :destination => destination.to_hash,
    :items => items.map { |o| o.to_hash },
    :customer => customer.nil? ? nil : customer.to_hash,
    :selections => selections.nil? ? nil : selections,
    :discount => discount.nil? ? nil : discount.to_hash,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



14773
14774
14775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14773

def to_json
  JSON.dump(to_hash)
end