Class: Io::Flow::V0::Models::TaxDutyQuoteLineItemForm

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. At least one of line_number, line_id, item_number or sku is required.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TaxDutyQuoteLineItemForm

Returns a new instance of TaxDutyQuoteLineItemForm.



70078
70079
70080
70081
70082
70083
70084
70085
70086
70087
70088
70089
70090
# 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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def attributes
  @attributes
end

#country_of_originObject (readonly)

Returns the value of attribute country_of_origin.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def country_of_origin
  @country_of_origin
end

#hs_codeObject (readonly)

Returns the value of attribute hs_code.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def hs_code
  @hs_code
end

#includesObject (readonly)

Returns the value of attribute includes.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def includes
  @includes
end

#primary_identifierObject (readonly)

Returns the value of attribute primary_identifier.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def primary_identifier
  @primary_identifier
end

#quantityObject (readonly)

Returns the value of attribute quantity.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def quantity
  @quantity
end

#ship_fromObject (readonly)

Returns the value of attribute ship_from.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def ship_from
  @ship_from
end

#unit_priceObject (readonly)

Returns the value of attribute unit_price.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def unit_price
  @unit_price
end

#unit_weightObject (readonly)

Returns the value of attribute unit_weight.



70076
70077
70078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70076

def unit_weight
  @unit_weight
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



70096
70097
70098
# 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_hashObject



70100
70101
70102
70103
70104
70105
70106
70107
70108
70109
70110
70111
70112
# 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_jsonObject



70092
70093
70094
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70092

def to_json
  JSON.dump(to_hash)
end