Class: Io::Flow::V0::Models::HarmonizedLandedCost

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

Overview

Summary of landed cost data (taxes and duties) for 1 or more items going to a single destination country. Records are unique based on (item.number, country of origin).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizedLandedCost

Returns a new instance of HarmonizedLandedCost.



30059
30060
30061
30062
30063
30064
30065
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30059

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:address, :items], 'HarmonizedLandedCost')
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::HarmonizedLandedCostItem) ? x : ::Io::Flow::V0::Models::HarmonizedLandedCostItem.new(x)) }
  @tax_registration = (x = opts.delete(:tax_registration); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::TaxRegistration) ? x : ::Io::Flow::V0::Models::TaxRegistration.new(x)))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



30057
30058
30059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30057

def address
  @address
end

#itemsObject (readonly)

Returns the value of attribute items.



30057
30058
30059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30057

def items
  @items
end

#tax_registrationObject (readonly)

Returns the value of attribute tax_registration.



30057
30058
30059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30057

def tax_registration
  @tax_registration
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30071
30072
30073
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30071

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

#to_hashObject



30075
30076
30077
30078
30079
30080
30081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30075

def to_hash
  {
    :address => address.to_hash,
    :items => items.map { |o| o.to_hash },
    :tax_registration => tax_registration.nil? ? nil : tax_registration.to_hash
  }
end

#to_jsonObject



30067
30068
30069
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30067

def to_json
  JSON.dump(to_hash)
end