Class: Io::Flow::V0::Models::OrderForm

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

Overview

The order form is used to create an open 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 = {}) ⇒ OrderForm

Returns a new instance of OrderForm.



51906
51907
51908
51909
51910
51911
51912
51913
51914
51915
51916
51917
51918
51919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51906

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:items], 'OrderForm')
  @customer = (x = opts.delete(:customer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderCustomerForm) ? x : ::Io::Flow::V0::Models::OrderCustomerForm.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)) }
  @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)))
  @number = (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, 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)))
  @discounts = (x = opts.delete(:discounts); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DiscountsForm) ? x : ::Io::Flow::V0::Models::DiscountsForm.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) })
  @options = (x = opts.delete(:options); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderOptions) ? x : ::Io::Flow::V0::Models::OrderOptions.new(x)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def attributes
  @attributes
end

#authorization_keysObject (readonly)

Returns the value of attribute authorization_keys.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def authorization_keys
  @authorization_keys
end

#customerObject (readonly)

Returns the value of attribute customer.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def customer
  @customer
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def destination
  @destination
end

#discountObject (readonly)

Returns the value of attribute discount.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def discount
  @discount
end

#discountsObject (readonly)

Returns the value of attribute discounts.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def discounts
  @discounts
end

#itemsObject (readonly)

Returns the value of attribute items.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def items
  @items
end

#numberObject (readonly)

Returns the value of attribute number.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def number
  @number
end

#optionsObject (readonly)

Returns the value of attribute options.



51904
51905
51906
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51904

def options
  @options
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



51925
51926
51927
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51925

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

#to_hashObject



51929
51930
51931
51932
51933
51934
51935
51936
51937
51938
51939
51940
51941
51942
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51929

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

#to_jsonObject



51921
51922
51923
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51921

def to_json
  JSON.dump(to_hash)
end