Class: Io::Flow::V0::Models::HarmonizedItemDuty

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

Overview

Used to specifically set an item’s duty rate for a given trade lane.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizedItemDuty

Returns a new instance of HarmonizedItemDuty.



19914
19915
19916
19917
19918
19919
19920
19921
19922
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19914

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :item, :origin, :destination, :rate], 'HarmonizedItemDuty')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::HarmonizedItemReference) ? x : ::Io::Flow::V0::Models::HarmonizedItemReference.new(x))
  @origin = HttpClient::Preconditions.assert_class('origin', opts.delete(:origin), String)
  @destination = HttpClient::Preconditions.assert_class('destination', opts.delete(:destination), String)
  @rate = HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(opts.delete(:rate)), BigDecimal)
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



19912
19913
19914
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19912

def destination
  @destination
end

#idObject (readonly)

Returns the value of attribute id.



19912
19913
19914
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19912

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item.



19912
19913
19914
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19912

def item
  @item
end

#originObject (readonly)

Returns the value of attribute origin.



19912
19913
19914
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19912

def origin
  @origin
end

#rateObject (readonly)

Returns the value of attribute rate.



19912
19913
19914
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19912

def rate
  @rate
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19928
19929
19930
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19928

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

#to_hashObject



19932
19933
19934
19935
19936
19937
19938
19939
19940
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19932

def to_hash
  {
    :id => id,
    :item => item.to_hash,
    :origin => origin,
    :destination => destination,
    :rate => rate
  }
end

#to_jsonObject



19924
19925
19926
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19924

def to_json
  JSON.dump(to_hash)
end