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.



24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24747

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:items], 'OrderPutForm')
  @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)))
  @delivered_duty = (x = opts.delete(:delivered_duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(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) })
  @destination = (x = opts.delete(:destination); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x)))
  @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 })
  @authorization_keys = (x = opts.delete(:authorization_keys); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_keys', x, Array).map { |v| HttpClient::Preconditions.assert_class('authorization_keys', v, String) })
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def attributes
  @attributes
end

#authorization_keysObject (readonly)

Returns the value of attribute authorization_keys.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def authorization_keys
  @authorization_keys
end

#customerObject (readonly)

Returns the value of attribute customer.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def customer
  @customer
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def destination
  @destination
end

#discountObject (readonly)

Returns the value of attribute discount.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def discount
  @discount
end

#itemsObject (readonly)

Returns the value of attribute items.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def items
  @items
end

#selectionsObject (readonly)

Returns the value of attribute selections.



24745
24746
24747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24745

def selections
  @selections
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24764
24765
24766
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24764

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

#to_hashObject



24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24768

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

#to_jsonObject



24760
24761
24762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24760

def to_json
  JSON.dump(to_hash)
end