Class: UspsApi::InternationalCustomsFormPackageContents

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/international_customs_form_package_contents.rb

Overview

Detailed information about items included in an international shipment for customs documentation purposes.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_description:, item_quantity:, countryof_origin:, item_value: SKIP, item_total_value: SKIP, weight_uom: WeightUom1::LB, item_weight: SKIP, item_total_weight: SKIP, hs_tariff_number: SKIP, item_category: SKIP, item_subcategory: SKIP) ⇒ InternationalCustomsFormPackageContents

Returns a new instance of InternationalCustomsFormPackageContents.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 113

def initialize(item_description:, item_quantity:, countryof_origin:,
               item_value: SKIP, item_total_value: SKIP,
               weight_uom: WeightUom1::LB, item_weight: SKIP,
               item_total_weight: SKIP, hs_tariff_number: SKIP,
               item_category: SKIP, item_subcategory: SKIP)
  @item_description = item_description
  @item_quantity = item_quantity
  @item_value = item_value unless item_value == SKIP
  @item_total_value = item_total_value unless item_total_value == SKIP
  @weight_uom = weight_uom unless weight_uom == SKIP
  @item_weight = item_weight unless item_weight == SKIP
  @item_total_weight = item_total_weight unless item_total_weight == SKIP
  @hs_tariff_number = hs_tariff_number unless hs_tariff_number == SKIP
  @countryof_origin = countryof_origin
  @item_category = item_category unless item_category == SKIP
  @item_subcategory = item_subcategory unless item_subcategory == SKIP
end

Instance Attribute Details

#countryof_originString

2 digit Alpha Country Code defined by ISO is required for an international address.

Returns:

  • (String)


67
68
69
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 67

def countryof_origin
  @countryof_origin
end

#hs_tariff_numberString

For commercial items only. The HS tariff number is based on the Harmonized Commodity Description and Coding System developed by the World Customs Organization. Providing this value is strongly recommended for faster processing. If not supplied, USPS will attempt to look up the HS tariff number, which may result in longer response times. The value should follow the pattern: ‘^.*(?:[A-Za-zd].*)6,14$`. For more information, see: [hts.usitc.gov/current](https://hts.usitc.gov/current).

Returns:

  • (String)


62
63
64
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 62

def hs_tariff_number
  @hs_tariff_number
end

#item_categoryString

Category of the item being shipped.

Returns:

  • (String)


71
72
73
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 71

def item_category
  @item_category
end

#item_descriptionString

Description of the item. It is important to note that the following descriptions, regardless of case sensitivity, are not considered valid: None, Not Applicable, N/A, Null, Gift, and Merchandise.

Returns:

  • (String)


17
18
19
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 17

def item_description
  @item_description
end

#item_quantityInteger

Quantity of the item. Integer value required.

Returns:

  • (Integer)


21
22
23
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 21

def item_quantity
  @item_quantity
end

#item_subcategoryString

Subcategory of the item being shipped.

Returns:

  • (String)


75
76
77
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 75

def item_subcategory
  @item_subcategory
end

#item_total_valueFloat

The total item value, in USD, of the items matching the ‘[itemDescription]`.

Returns:

  • (Float)


32
33
34
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 32

def item_total_value
  @item_total_value
end

#item_total_weightFloat

Provide the total weight in weightUOM for the all the items matching the ‘[itemDescription]`.

Returns:

  • (Float)


50
51
52
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 50

def item_total_weight
  @item_total_weight
end

#item_valueFloat

Value of the individual item in USD. Note: This field has been deprecated in favor of itemTotalValue and will be removed in a future release. Please transition to using itemTotalValue.

Returns:

  • (Float)


27
28
29
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 27

def item_value
  @item_value
end

#item_weightFloat

Provide the weight in weightUOM for the individual item listed with ‘[itemDescription]`. Note: This field has been deprecated in favor of itemTotalWeight and will be removed in a future release. Please transition to using itemTotalWeight.

Returns:

  • (Float)


45
46
47
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 45

def item_weight
  @item_weight
end

#weight_uomWeightUom1

Weight Unit of Measurement.

* lb - Pounds

Returns:



37
38
39
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 37

def weight_uom
  @weight_uom
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 132

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_description =
    hash.key?('itemDescription') ? hash['itemDescription'] : nil
  item_quantity = hash.key?('itemQuantity') ? hash['itemQuantity'] : nil
  countryof_origin =
    hash.key?('countryofOrigin') ? hash['countryofOrigin'] : nil
  item_value = hash.key?('itemValue') ? hash['itemValue'] : SKIP
  item_total_value =
    hash.key?('itemTotalValue') ? hash['itemTotalValue'] : SKIP
  weight_uom = hash['weightUOM'] ||= WeightUom1::LB
  item_weight = hash.key?('itemWeight') ? hash['itemWeight'] : SKIP
  item_total_weight =
    hash.key?('itemTotalWeight') ? hash['itemTotalWeight'] : SKIP
  hs_tariff_number =
    hash.key?('HSTariffNumber') ? hash['HSTariffNumber'] : SKIP
  item_category = hash.key?('itemCategory') ? hash['itemCategory'] : SKIP
  item_subcategory =
    hash.key?('itemSubcategory') ? hash['itemSubcategory'] : SKIP

  # Create object from extracted values.
  InternationalCustomsFormPackageContents.new(item_description: item_description,
                                              item_quantity: item_quantity,
                                              countryof_origin: countryof_origin,
                                              item_value: item_value,
                                              item_total_value: item_total_value,
                                              weight_uom: weight_uom,
                                              item_weight: item_weight,
                                              item_total_weight: item_total_weight,
                                              hs_tariff_number: hs_tariff_number,
                                              item_category: item_category,
                                              item_subcategory: item_subcategory)
end

.namesObject

A mapping from model property names to API property names.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 78

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_description'] = 'itemDescription'
  @_hash['item_quantity'] = 'itemQuantity'
  @_hash['item_value'] = 'itemValue'
  @_hash['item_total_value'] = 'itemTotalValue'
  @_hash['weight_uom'] = 'weightUOM'
  @_hash['item_weight'] = 'itemWeight'
  @_hash['item_total_weight'] = 'itemTotalWeight'
  @_hash['hs_tariff_number'] = 'HSTariffNumber'
  @_hash['countryof_origin'] = 'countryofOrigin'
  @_hash['item_category'] = 'itemCategory'
  @_hash['item_subcategory'] = 'itemSubcategory'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 109

def self.nullables
  []
end

.optionalsObject

An array for optional fields



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 95

def self.optionals
  %w[
    item_value
    item_total_value
    weight_uom
    item_weight
    item_total_weight
    hs_tariff_number
    item_category
    item_subcategory
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



179
180
181
182
183
184
185
186
187
188
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 179

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} item_description: #{@item_description.inspect}, item_quantity:"\
  " #{@item_quantity.inspect}, item_value: #{@item_value.inspect}, item_total_value:"\
  " #{@item_total_value.inspect}, weight_uom: #{@weight_uom.inspect}, item_weight:"\
  " #{@item_weight.inspect}, item_total_weight: #{@item_total_weight.inspect},"\
  " hs_tariff_number: #{@hs_tariff_number.inspect}, countryof_origin:"\
  " #{@countryof_origin.inspect}, item_category: #{@item_category.inspect}, item_subcategory:"\
  " #{@item_subcategory.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



169
170
171
172
173
174
175
176
# File 'lib/usps_api/models/international_customs_form_package_contents.rb', line 169

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} item_description: #{@item_description}, item_quantity: #{@item_quantity},"\
  " item_value: #{@item_value}, item_total_value: #{@item_total_value}, weight_uom:"\
  " #{@weight_uom}, item_weight: #{@item_weight}, item_total_weight: #{@item_total_weight},"\
  " hs_tariff_number: #{@hs_tariff_number}, countryof_origin: #{@countryof_origin},"\
  " item_category: #{@item_category}, item_subcategory: #{@item_subcategory}>"
end