Class: Io::Flow::V0::Models::TaxDutyQuoteLineItem

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

Overview

An ordered quantity of goods for tax and duty calculation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TaxDutyQuoteLineItem

Returns a new instance of TaxDutyQuoteLineItem.



70038
70039
70040
70041
70042
70043
70044
70045
70046
70047
70048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70038

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:primary_identifier, :ship_from, :quantity, :unit_values, :country_of_origin, :hs_code], 'TaxDutyQuoteLineItem')
  @primary_identifier = HttpClient::Preconditions.assert_class('primary_identifier', opts.delete(:primary_identifier), String)
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @ship_from = (x = opts.delete(:ship_from); x.is_a?(::Io::Flow::V0::Models::StreetAddress) ? x : ::Io::Flow::V0::Models::StreetAddress.new(x))
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @unit_values = (x = opts.delete(:unit_values); x.is_a?(::Io::Flow::V0::Models::TaxDutyQuoteValues) ? x : ::Io::Flow::V0::Models::TaxDutyQuoteValues.new(x))
  @country_of_origin = HttpClient::Preconditions.assert_class('country_of_origin', opts.delete(:country_of_origin), String)
  @hs_code = HttpClient::Preconditions.assert_class('hs_code', opts.delete(:hs_code), String)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



70036
70037
70038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70036

def attributes
  @attributes
end

#country_of_originObject (readonly)

Returns the value of attribute country_of_origin.



70036
70037
70038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70036

def country_of_origin
  @country_of_origin
end

#hs_codeObject (readonly)

Returns the value of attribute hs_code.



70036
70037
70038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70036

def hs_code
  @hs_code
end

#primary_identifierObject (readonly)

Returns the value of attribute primary_identifier.



70036
70037
70038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70036

def primary_identifier
  @primary_identifier
end

#quantityObject (readonly)

Returns the value of attribute quantity.



70036
70037
70038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70036

def quantity
  @quantity
end

#ship_fromObject (readonly)

Returns the value of attribute ship_from.



70036
70037
70038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70036

def ship_from
  @ship_from
end

#unit_valuesObject (readonly)

Returns the value of attribute unit_values.



70036
70037
70038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70036

def unit_values
  @unit_values
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



70054
70055
70056
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70054

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

#to_hashObject



70058
70059
70060
70061
70062
70063
70064
70065
70066
70067
70068
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70058

def to_hash
  {
    :primary_identifier => primary_identifier,
    :attributes => attributes,
    :ship_from => ship_from.to_hash,
    :quantity => quantity,
    :unit_values => unit_values.to_hash,
    :country_of_origin => country_of_origin,
    :hs_code => hs_code
  }
end

#to_jsonObject



70050
70051
70052
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70050

def to_json
  JSON.dump(to_hash)
end