Class: Io::Flow::V0::Models::HarmonizedLandedCostForm

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

Overview

Allows calculation of duty and tax for multiple items in one API call for items going to a specific destination country

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizedLandedCostForm

Returns a new instance of HarmonizedLandedCostForm.



34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34295

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:address, :item_numbers], 'HarmonizedLandedCostForm')
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @item_numbers = HttpClient::Preconditions.assert_class('item_numbers', opts.delete(:item_numbers), Array).map { |v| HttpClient::Preconditions.assert_class('item_numbers', v, String) }
  @source_address = (x = opts.delete(:source_address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)))
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
  @line_items = (x = opts.delete(:line_items); x.nil? ? nil : HttpClient::Preconditions.assert_class('line_items', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItem) ? x : ::Io::Flow::V0::Models::LineItem.new(x)) })
  @tax_registration_id = (x = opts.delete(:tax_registration_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('tax_registration_id', x, String))
  @billing_address = (x = opts.delete(:billing_address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingAddress) ? x : ::Io::Flow::V0::Models::BillingAddress.new(x)))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def address
  @address
end

#billing_addressObject (readonly)

Returns the value of attribute billing_address.



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def billing_address
  @billing_address
end

#item_numbersObject (readonly)

Returns the value of attribute item_numbers.



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def item_numbers
  @item_numbers
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def line_items
  @line_items
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def order_number
  @order_number
end

#source_addressObject (readonly)

Returns the value of attribute source_address.



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def source_address
  @source_address
end

#tax_registration_idObject (readonly)

Returns the value of attribute tax_registration_id.



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def tax_registration_id
  @tax_registration_id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34311
34312
34313
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34311

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

#to_hashObject



34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34315

def to_hash
  {
    :address => address.to_hash,
    :item_numbers => item_numbers,
    :source_address => source_address.nil? ? nil : source_address.to_hash,
    :order_number => order_number,
    :line_items => line_items.nil? ? nil : line_items.map { |o| o.to_hash },
    :tax_registration_id => tax_registration_id,
    :billing_address => billing_address.nil? ? nil : billing_address.to_hash
  }
end

#to_jsonObject



34307
34308
34309
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34307

def to_json
  JSON.dump(to_hash)
end