Class: Io::Flow::V0::Models::OrderDetails

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderDetails

Returns a new instance of OrderDetails.



51719
51720
51721
51722
51723
51724
51725
51726
51727
51728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51719

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:line_items], 'OrderDetails')
  @line_items = HttpClient::Preconditions.assert_class('line_items', opts.delete(:line_items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentOrderDetailsLineItem) ? x : ::Io::Flow::V0::Models::PaymentOrderDetailsLineItem.new(x)) }
  @shipping = (x = opts.delete(:shipping); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Shipping) ? x : ::Io::Flow::V0::Models::Shipping.new(x)))
  @discounts = (x = opts.delete(:discounts); x.nil? ? nil : HttpClient::Preconditions.assert_class('discounts', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentDiscount) ? x : ::Io::Flow::V0::Models::PaymentDiscount.new(x)) })
  @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentTax) ? x : ::Io::Flow::V0::Models::PaymentTax.new(x)))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentDuty) ? x : ::Io::Flow::V0::Models::PaymentDuty.new(x)))
  @reference = (x = opts.delete(:reference); x.nil? ? nil : HttpClient::Preconditions.assert_class('reference', x, String))
end

Instance Attribute Details

#discountsObject (readonly)

Returns the value of attribute discounts.



51717
51718
51719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51717

def discounts
  @discounts
end

#dutyObject (readonly)

Returns the value of attribute duty.



51717
51718
51719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51717

def duty
  @duty
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



51717
51718
51719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51717

def line_items
  @line_items
end

#referenceObject (readonly)

Returns the value of attribute reference.



51717
51718
51719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51717

def reference
  @reference
end

#shippingObject (readonly)

Returns the value of attribute shipping.



51717
51718
51719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51717

def shipping
  @shipping
end

#taxObject (readonly)

Returns the value of attribute tax.



51717
51718
51719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51717

def tax
  @tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



51734
51735
51736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51734

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

#to_hashObject



51738
51739
51740
51741
51742
51743
51744
51745
51746
51747
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51738

def to_hash
  {
    :line_items => line_items.map { |o| o.to_hash },
    :shipping => shipping.nil? ? nil : shipping.to_hash,
    :discounts => discounts.nil? ? nil : discounts.map { |o| o.to_hash },
    :tax => tax.nil? ? nil : tax.to_hash,
    :duty => duty.nil? ? nil : duty.to_hash,
    :reference => reference
  }
end

#to_jsonObject



51730
51731
51732
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51730

def to_json
  JSON.dump(to_hash)
end