class Io::Flow::V0::Models::TaxDutyQuoteLineItemForm

An ordered quantity of goods for tax and duty calculation. At least one of line_number, line_id, item_number or sku is required.

Attributes

attributes[R]
country_of_origin[R]
hs_code[R]
includes[R]
primary_identifier[R]
quantity[R]
ship_from[R]
unit_price[R]
unit_weight[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 70078
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:primary_identifier, :ship_from, :quantity, :unit_price], 'TaxDutyQuoteLineItemForm')
  @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_price = HttpClient::Preconditions.assert_class('unit_price', HttpClient::Helper.to_big_decimal(opts.delete(:unit_price)), BigDecimal)
  @unit_weight = (x = opts.delete(:unit_weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x)))
  @country_of_origin = (x = opts.delete(:country_of_origin); x.nil? ? nil : HttpClient::Preconditions.assert_class('country_of_origin', x, String))
  @hs_code = (x = opts.delete(:hs_code); x.nil? ? nil : HttpClient::Preconditions.assert_class('hs_code', x, String))
  @includes = HttpClient::Preconditions.assert_class('includes', (x = opts.delete(:includes); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LevyInclusion) ? x : ::Io::Flow::V0::Models::LevyInclusion.apply(x)) }
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 70096
def copy(incoming={})
  TaxDutyQuoteLineItemForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 70100
def to_hash
  {
    :primary_identifier => primary_identifier,
    :attributes => attributes,
    :ship_from => ship_from.to_hash,
    :quantity => quantity,
    :unit_price => unit_price.to_f.to_s,
    :unit_weight => unit_weight.nil? ? nil : unit_weight.to_hash,
    :country_of_origin => country_of_origin,
    :hs_code => hs_code,
    :includes => includes.map { |o| o.value }
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 70092
def to_json
  JSON.dump(to_hash)
end