Class: UspsApi::ShipmentsDeliveryDutiesTaxesAndFeesItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::ShipmentsDeliveryDutiesTaxesAndFeesItem
- Defined in:
- lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb
Overview
When ‘requestDutiesTaxesFees` is true at least one item is required.
Instance Attribute Summary collapse
-
#country_of_origin ⇒ String
A two digit Alpha Country Code defined by ISO representing where the item is from.
-
#hs_tariff_number ⇒ String
The HS tariff number is based on the Harmonized Commodity Description and Coding System developed by the World Customs Organization.
-
#item_id ⇒ String
A user-provided item identifier.
-
#item_quantity ⇒ Float
The quantity of the item.
-
#item_value ⇒ Float
The value of the item.
-
#item_weight ⇒ Float
The calculated weight for each individual item within a quantity based on user input.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(item_id:, item_value:, item_quantity:, item_weight: SKIP, country_of_origin: SKIP, hs_tariff_number: SKIP, additional_properties: nil) ⇒ ShipmentsDeliveryDutiesTaxesAndFeesItem
constructor
A new instance of ShipmentsDeliveryDutiesTaxesAndFeesItem.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(item_id:, item_value:, item_quantity:, item_weight: SKIP, country_of_origin: SKIP, hs_tariff_number: SKIP, additional_properties: nil) ⇒ ShipmentsDeliveryDutiesTaxesAndFeesItem
Returns a new instance of ShipmentsDeliveryDutiesTaxesAndFeesItem.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 69 def initialize(item_id:, item_value:, item_quantity:, item_weight: SKIP, country_of_origin: SKIP, hs_tariff_number: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @item_id = item_id @item_value = item_value @item_quantity = item_quantity @item_weight = item_weight unless item_weight == SKIP @country_of_origin = country_of_origin unless country_of_origin == SKIP @hs_tariff_number = hs_tariff_number unless hs_tariff_number == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#country_of_origin ⇒ String
A two digit Alpha Country Code defined by ISO representing where the item is from.
33 34 35 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 33 def country_of_origin @country_of_origin end |
#hs_tariff_number ⇒ String
The HS tariff number is based on the Harmonized Commodity Description and Coding System developed by the World Customs Organization. The value should follow the regular expression pattern: ‘^.*(?:[A-Za-zd].*)6,14$`. For more information, see: [hts.usitc.gov/current](https://hts.usitc.gov/current).
41 42 43 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 41 def hs_tariff_number @hs_tariff_number end |
#item_id ⇒ String
A user-provided item identifier. The itemId is echoed in the response to correlate duties and taxes to this item.
15 16 17 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 15 def item_id @item_id end |
#item_quantity ⇒ Float
The quantity of the item.
23 24 25 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 23 def item_quantity @item_quantity end |
#item_value ⇒ Float
The value of the item.
19 20 21 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 19 def item_value @item_value end |
#item_weight ⇒ Float
The calculated weight for each individual item within a quantity based on user input.
28 29 30 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 28 def item_weight @item_weight end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 85 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. item_id = hash.key?('itemId') ? hash['itemId'] : nil item_value = hash.key?('itemValue') ? hash['itemValue'] : nil item_quantity = hash.key?('itemQuantity') ? hash['itemQuantity'] : nil item_weight = hash.key?('itemWeight') ? hash['itemWeight'] : SKIP country_of_origin = hash.key?('countryOfOrigin') ? hash['countryOfOrigin'] : SKIP hs_tariff_number = hash.key?('HSTariffNumber') ? hash['HSTariffNumber'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. ShipmentsDeliveryDutiesTaxesAndFeesItem.new(item_id: item_id, item_value: item_value, item_quantity: item_quantity, item_weight: item_weight, country_of_origin: country_of_origin, hs_tariff_number: hs_tariff_number, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 44 def self.names @_hash = {} if @_hash.nil? @_hash['item_id'] = 'itemId' @_hash['item_value'] = 'itemValue' @_hash['item_quantity'] = 'itemQuantity' @_hash['item_weight'] = 'itemWeight' @_hash['country_of_origin'] = 'countryOfOrigin' @_hash['hs_tariff_number'] = 'HSTariffNumber' @_hash end |
.nullables ⇒ Object
An array for nullable fields
65 66 67 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 65 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
56 57 58 59 60 61 62 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 56 def self.optionals %w[ item_weight country_of_origin hs_tariff_number ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 117 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.item_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.item_value, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.item_quantity, ->(val) { val.instance_of? Float }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['itemId'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['itemValue'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['itemQuantity'], ->(val) { val.instance_of? Float }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
150 151 152 153 154 155 156 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 150 def inspect class_name = self.class.name.split('::').last "<#{class_name} item_id: #{@item_id.inspect}, item_value: #{@item_value.inspect},"\ " item_quantity: #{@item_quantity.inspect}, item_weight: #{@item_weight.inspect},"\ " country_of_origin: #{@country_of_origin.inspect}, hs_tariff_number:"\ " #{@hs_tariff_number.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
142 143 144 145 146 147 |
# File 'lib/usps_api/models/shipments_delivery_duties_taxes_and_fees_item.rb', line 142 def to_s class_name = self.class.name.split('::').last "<#{class_name} item_id: #{@item_id}, item_value: #{@item_value}, item_quantity:"\ " #{@item_quantity}, item_weight: #{@item_weight}, country_of_origin: #{@country_of_origin},"\ " hs_tariff_number: #{@hs_tariff_number}, additional_properties: #{@additional_properties}>" end |