Class: UspsApi::InternationalLabelsInternationalPackageDescription

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

Overview

Physical and service characteristics of an international package including dimensions, weight, mail class, and processing requirements.

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(weight:, length:, height:, width:, mail_class:, processing_category:, destination_entry_facility_type:, mailing_date:, weight_uom: WeightUom::LB, dimensions_uom: DimensionsUom::ENUM_IN, girth: SKIP, destination_entry_facility_address: SKIP, rate_indicator: RateIndicator1::SP, packaging_type: SKIP, diameter: SKIP, shape: SKIP, package_options: SKIP, customer_reference: SKIP, extra_services: SKIP, induction_zip_code: SKIP, mail_owner_mid: SKIP, logistics_manager_mid: SKIP, prepay_duties_taxes_fees: false) ⇒ InternationalLabelsInternationalPackageDescription

Returns a new instance of InternationalLabelsInternationalPackageDescription.



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 268

def initialize(weight:, length:, height:, width:, mail_class:,
               processing_category:, destination_entry_facility_type:,
               mailing_date:, weight_uom: WeightUom::LB,
               dimensions_uom: DimensionsUom::ENUM_IN, girth: SKIP,
               destination_entry_facility_address: SKIP,
               rate_indicator: RateIndicator1::SP, packaging_type: SKIP,
               diameter: SKIP, shape: SKIP, package_options: SKIP,
               customer_reference: SKIP, extra_services: SKIP,
               induction_zip_code: SKIP, mail_owner_mid: SKIP,
               logistics_manager_mid: SKIP, prepay_duties_taxes_fees: false)
  @weight_uom = weight_uom unless weight_uom == SKIP
  @weight = weight
  @dimensions_uom = dimensions_uom unless dimensions_uom == SKIP
  @length = length
  @height = height
  @width = width
  @girth = girth unless girth == SKIP
  unless destination_entry_facility_address == SKIP
    @destination_entry_facility_address =
      destination_entry_facility_address
  end
  @mail_class = mail_class
  @rate_indicator = rate_indicator unless rate_indicator == SKIP
  @packaging_type = packaging_type unless packaging_type == SKIP
  @diameter = diameter unless diameter == SKIP
  @shape = shape unless shape == SKIP
  @processing_category = processing_category
  @destination_entry_facility_type = destination_entry_facility_type
  @mailing_date = mailing_date
  @package_options = package_options unless package_options == SKIP
  @customer_reference = customer_reference unless customer_reference == SKIP
  @extra_services = extra_services unless extra_services == SKIP
  @induction_zip_code = induction_zip_code unless induction_zip_code == SKIP
  @mail_owner_mid = mail_owner_mid unless mail_owner_mid == SKIP
  @logistics_manager_mid = logistics_manager_mid unless logistics_manager_mid == SKIP
  @prepay_duties_taxes_fees = prepay_duties_taxes_fees unless prepay_duties_taxes_fees == SKIP
end

Instance Attribute Details

#customer_referenceArray[InternationalLabelsCustomerReference]

Customer reference information for the package. Up to two customer references may be provided.



157
158
159
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 157

def customer_reference
  @customer_reference
end

#destination_entry_facility_addressInternationalLabelsDomesticAddress

Address fields for US locations



74
75
76
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 74

def destination_entry_facility_address
  @destination_entry_facility_address
end

#destination_entry_facility_typeDestinationEntryFacilityType2

Types of Facilities.

* NONE - Translate to Destination Rate Indicator of N in USPS® Pub

205

* INTERNATIONAL_SERVICE_CENTER - Translate to Destination Rate Indicator

of I in USPS® Pub 205



140
141
142
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 140

def destination_entry_facility_type
  @destination_entry_facility_type
end

#diameterFloat

Future Use - The diameter of the package, in dimensionsUOM.

Returns:

  • (Float)


115
116
117
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 115

def diameter
  @diameter
end

#dimensions_uomDimensionsUom

Dimensions unit of measurement.

* in - Inches

Returns:



26
27
28
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 26

def dimensions_uom
  @dimensions_uom
end

#extra_servicesArray[InternationalExtraServiceCodes]

Extra Service Code requested on the package.

  • 480 - Tracking Plus 6 Months

  • 481 - Tracking Plus 1 Year

  • 482 - Tracking Plus 3 Years

  • 483 - Tracking Plus 5 Years

  • 484 - Tracking Plus 7 Years

  • 486 - Tracking Plus Signature 3 Years

  • 487 - Tracking Plus Signature 5 Years

  • 488 - Tracking Plus Signature 7 Years

  • 813 - HAZMAT Class 7 - Radioactive Materials Package

  • 820 - HAZMAT Class 9 - Lithium batteries, unmarked package

  • 826 - HAZMAT Division 6.2 – Infectious Substances Package

  • 857 - Hazardous Material

  • 930 - Insurance <= $500

  • 931 - Insurance > $500

  • 955 - Return Receipt (Unsupported as of 01/19/2025)

Note:

  • Only one USPS Tracking Plus&#174; extra service and one Insurance extra

service may be selected per package

Returns:



179
180
181
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 179

def extra_services
  @extra_services
end

#girthFloat

The girth of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. ‘length`, `width`, and `height` are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. `girth` is required only for a non-rectangular package in addition to `length`, `width`, and `height` when any dimension of the package exceeds 12 inches. For rectangular packages, the `girth` dimension must be left blank as this dimension is to only be used for non-rectangular packages.

Returns:

  • (Float)


70
71
72
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 70

def girth
  @girth
end

#heightFloat

The height of the container, in ‘dimensionsUOM`. If partial dimensions are provided, an error response will return. `length`, `width`, and `height` are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. `girth` is required only for a non-rectangular package in addition to `length`, `width`, and `height` when any dimension of the package exceeds 12 inches. For rectangular packages, the `girth` dimension must be left blank as this dimension is to only be used for non-rectangular packages.

Returns:

  • (Float)


48
49
50
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 48

def height
  @height
end

#induction_zip_codeString

This is the 5-digit ZIP code where the package is being mailed from.

Returns:

  • (String)


183
184
185
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 183

def induction_zip_code
  @induction_zip_code
end

#lengthFloat

The length of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. ‘length`, `width`, and `height` are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. `girth` is required only for a non-rectangular package in addition to `length`, `width`, and `height` when any dimension of the package exceeds 12 inches. For rectangular packages, the `girth` dimension must be left blank as this dimension is to only be used for non-rectangular packages.

Returns:

  • (Float)


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

def length
  @length
end

#logistics_manager_midString

This is the mailer ID associated with the logistics manager for this label This provides an additional copy of the scan extract file to the MID’s outbound folder.

Returns:

  • (String)


195
196
197
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 195

def logistics_manager_mid
  @logistics_manager_mid
end

#mail_classInternationalMailClassOfTheLabel

International Mail classes for label The mail service requested.

* FIRST-CLASS_PACKAGE_INTERNATIONAL_SERVICE
* PRIORITY_MAIL_INTERNATIONAL
* PRIORITY_MAIL_EXPRESS_INTERNATIONAL


81
82
83
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 81

def mail_class
  @mail_class
end

#mail_owner_midString

This is the mailer ID associated with the mail owner for this label This provides an additional copy of the scan extract file to the MID’s outbound folder.

Returns:

  • (String)


189
190
191
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 189

def mail_owner_mid
  @mail_owner_mid
end

#mailing_dateDate

The date package will be mailed. The mailing date may be today plus 0 to 7 days in advance. Enter the date in the full-date notation as defined by [RFC 3339, section 5.6](datatracker.ietf.org/doc/html/rfc3339#section-5.6).

Returns:

  • (Date)


147
148
149
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 147

def mailing_date
  @mailing_date
end

#package_optionsInternationalPackageOptions

Additional options for international package shipments including redirect addresses, over-labeling information, and manifest preferences.



152
153
154
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 152

def package_options
  @package_options
end

#packaging_typePackagingType

Used to specify USPS&#174; packaging attributes that may affect postage. Can be used instead of a rate indicator. Either packagingType or rate indicator is required.

* FLAT_RATE_ENVELOPE
* LEGAL_FLAT_RATE_ENVELOPE
* PADDED_FLAT_RATE_ENVELOPE
* SM_FLAT_RATE_BOX
* MD_FLAT_RATE_BOX
* LG_FLAT_RATE_BOX
* VARIABLE

Returns:



111
112
113
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 111

def packaging_type
  @packaging_type
end

#prepay_duties_taxes_feesTrueClass | FalseClass

When set to ‘true`, duties, taxes, and import fees will be calculated and will be prepaid on behalf of the recipient if supported by the destination country. The resulting cost will be returned as `response.prepaidDutiesTaxesFees`. By continuing, you agree to the [terms and conditions](zonos.com/docs/legal/usps-terms-of-service) for paying international duties, taxes, and fees (DDP), and certify that you will use DDP to ship goods to customers. When set to `false`, duties, taxes, and import fees will not be calculated and you will not have the option to pay duties, taxes, and import fees in advance, on behalf of the recipient.

Returns:

  • (TrueClass | FalseClass)


209
210
211
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 209

def prepay_duties_taxes_fees
  @prepay_duties_taxes_fees
end

#processing_categoryProcessingCategory4

USPS&#174; categorizes international parcels into four processing categories. These categories are based on the physical dimensions of the piece and impact how the mail will be processed.

* `LETTERS`
* `FLATS`
* `MACHINABLE`
* `NONSTANDARD`
* `NON_MACHINABLE` is deprecated and will convert to `NONSTANDARD` as of

01/19/2025

Returns:



132
133
134
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 132

def processing_category
  @processing_category
end

#rate_indicatorRateIndicator1

Use to specify USPS&#174; containers/packaging or container attributes that may affect postage. A rate indicator value will be required if a value for ‘packagingType` is not provided.

* E4 - Priority Mail Express Flat Rate Envelope - Post Office To

Addressee

* E6 - Priority Mail Express Legal Flat Rate Envelope
* FA - Legal Flat Rate Envelope
* FB - Medium Flat Rate Box/Large Flat Rate Bag
* FE - Flat Rate Envelope
* FP - Padded Flat Rate Envelope
* FS - Small Flat Rate Box
* PA - Priority Mail Express International Single Piece
* PL - Large Flat Rate Box
* SP - Single Piece

Returns:



98
99
100
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 98

def rate_indicator
  @rate_indicator
end

#shapeShape

Indicates the mail piece shape.

* RECTANGLE

Returns:



120
121
122
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 120

def shape
  @shape
end

#weightFloat

The package weight, in ‘weightUOM` (Unit Of Measure). Items must weigh 70 pounds (1120 ounces) or less.

Returns:

  • (Float)


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

def weight
  @weight
end

#weight_uomWeightUom

Weight Unit of Measure

* lb - Pounds

Returns:



16
17
18
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 16

def weight_uom
  @weight_uom
end

#widthFloat

The width of the container, in ‘dimensionsUOM`. If partial dimensions are provided, an error response will return. `length`, `width`, and `height` are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. `girth` is required only for a non-rectangular package in addition to `length`, `width`, and `height` when any dimension of the package exceeds 12 inches. For rectangular packages, the `girth` dimension must be left blank as this dimension is to only be used for non-rectangular packages.

Returns:

  • (Float)


59
60
61
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 59

def width
  @width
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 307

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  weight = hash.key?('weight') ? hash['weight'] : nil
  length = hash.key?('length') ? hash['length'] : nil
  height = hash.key?('height') ? hash['height'] : nil
  width = hash.key?('width') ? hash['width'] : nil
  mail_class = hash.key?('mailClass') ? hash['mailClass'] : nil
  processing_category =
    hash.key?('processingCategory') ? hash['processingCategory'] : nil
  destination_entry_facility_type =
    hash.key?('destinationEntryFacilityType') ? hash['destinationEntryFacilityType'] : nil
  mailing_date = hash.key?('mailingDate') ? hash['mailingDate'] : nil
  weight_uom = hash['weightUOM'] ||= WeightUom::LB
  dimensions_uom = hash['dimensionsUOM'] ||= DimensionsUom::ENUM_IN
  girth = hash.key?('girth') ? hash['girth'] : SKIP
  if hash['destinationEntryFacilityAddress']
    destination_entry_facility_address = InternationalLabelsDomesticAddress.from_hash(hash['destinationEntryFacilityAddress'])
  end
  rate_indicator = hash['rateIndicator'] ||= RateIndicator1::SP
  packaging_type = hash.key?('packagingType') ? hash['packagingType'] : SKIP
  diameter = hash.key?('diameter') ? hash['diameter'] : SKIP
  shape = hash.key?('shape') ? hash['shape'] : SKIP
  package_options = InternationalPackageOptions.from_hash(hash['packageOptions']) if
    hash['packageOptions']
  # Parameter is an array, so we need to iterate through it
  customer_reference = nil
  unless hash['customerReference'].nil?
    customer_reference = []
    hash['customerReference'].each do |structure|
      customer_reference << (InternationalLabelsCustomerReference.from_hash(structure) if structure)
    end
  end

  customer_reference = SKIP unless hash.key?('customerReference')
  extra_services = hash.key?('extraServices') ? hash['extraServices'] : SKIP
  induction_zip_code =
    hash.key?('inductionZIPCode') ? hash['inductionZIPCode'] : SKIP
  mail_owner_mid = hash.key?('mailOwnerMID') ? hash['mailOwnerMID'] : SKIP
  logistics_manager_mid =
    hash.key?('logisticsManagerMID') ? hash['logisticsManagerMID'] : SKIP
  prepay_duties_taxes_fees = hash['prepayDutiesTaxesFees'] ||= false

  # Create object from extracted values.
  InternationalLabelsInternationalPackageDescription.new(weight: weight,
                                                         length: length,
                                                         height: height,
                                                         width: width,
                                                         mail_class: mail_class,
                                                         processing_category: processing_category,
                                                         destination_entry_facility_type: destination_entry_facility_type,
                                                         mailing_date: mailing_date,
                                                         weight_uom: weight_uom,
                                                         dimensions_uom: dimensions_uom,
                                                         girth: girth,
                                                         destination_entry_facility_address: destination_entry_facility_address,
                                                         rate_indicator: rate_indicator,
                                                         packaging_type: packaging_type,
                                                         diameter: diameter,
                                                         shape: shape,
                                                         package_options: package_options,
                                                         customer_reference: customer_reference,
                                                         extra_services: extra_services,
                                                         induction_zip_code: induction_zip_code,
                                                         mail_owner_mid: mail_owner_mid,
                                                         logistics_manager_mid: logistics_manager_mid,
                                                         prepay_duties_taxes_fees: prepay_duties_taxes_fees)
end

.namesObject

A mapping from model property names to API property names.



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 212

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['weight_uom'] = 'weightUOM'
  @_hash['weight'] = 'weight'
  @_hash['dimensions_uom'] = 'dimensionsUOM'
  @_hash['length'] = 'length'
  @_hash['height'] = 'height'
  @_hash['width'] = 'width'
  @_hash['girth'] = 'girth'
  @_hash['destination_entry_facility_address'] =
    'destinationEntryFacilityAddress'
  @_hash['mail_class'] = 'mailClass'
  @_hash['rate_indicator'] = 'rateIndicator'
  @_hash['packaging_type'] = 'packagingType'
  @_hash['diameter'] = 'diameter'
  @_hash['shape'] = 'shape'
  @_hash['processing_category'] = 'processingCategory'
  @_hash['destination_entry_facility_type'] =
    'destinationEntryFacilityType'
  @_hash['mailing_date'] = 'mailingDate'
  @_hash['package_options'] = 'packageOptions'
  @_hash['customer_reference'] = 'customerReference'
  @_hash['extra_services'] = 'extraServices'
  @_hash['induction_zip_code'] = 'inductionZIPCode'
  @_hash['mail_owner_mid'] = 'mailOwnerMID'
  @_hash['logistics_manager_mid'] = 'logisticsManagerMID'
  @_hash['prepay_duties_taxes_fees'] = 'prepayDutiesTaxesFees'
  @_hash
end

.nullablesObject

An array for nullable fields



264
265
266
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 264

def self.nullables
  []
end

.optionalsObject

An array for optional fields



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 243

def self.optionals
  %w[
    weight_uom
    dimensions_uom
    girth
    destination_entry_facility_address
    rate_indicator
    packaging_type
    diameter
    shape
    package_options
    customer_reference
    extra_services
    induction_zip_code
    mail_owner_mid
    logistics_manager_mid
    prepay_duties_taxes_fees
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 394

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} weight_uom: #{@weight_uom.inspect}, weight: #{@weight.inspect},"\
  " dimensions_uom: #{@dimensions_uom.inspect}, length: #{@length.inspect}, height:"\
  " #{@height.inspect}, width: #{@width.inspect}, girth: #{@girth.inspect},"\
  " destination_entry_facility_address: #{@destination_entry_facility_address.inspect},"\
  " mail_class: #{@mail_class.inspect}, rate_indicator: #{@rate_indicator.inspect},"\
  " packaging_type: #{@packaging_type.inspect}, diameter: #{@diameter.inspect}, shape:"\
  " #{@shape.inspect}, processing_category: #{@processing_category.inspect},"\
  " destination_entry_facility_type: #{@destination_entry_facility_type.inspect},"\
  " mailing_date: #{@mailing_date.inspect}, package_options: #{@package_options.inspect},"\
  " customer_reference: #{@customer_reference.inspect}, extra_services:"\
  " #{@extra_services.inspect}, induction_zip_code: #{@induction_zip_code.inspect},"\
  " mail_owner_mid: #{@mail_owner_mid.inspect}, logistics_manager_mid:"\
  " #{@logistics_manager_mid.inspect}, prepay_duties_taxes_fees:"\
  " #{@prepay_duties_taxes_fees.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/usps_api/models/international_labels_international_package_description.rb', line 378

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} weight_uom: #{@weight_uom}, weight: #{@weight}, dimensions_uom:"\
  " #{@dimensions_uom}, length: #{@length}, height: #{@height}, width: #{@width}, girth:"\
  " #{@girth}, destination_entry_facility_address: #{@destination_entry_facility_address},"\
  " mail_class: #{@mail_class}, rate_indicator: #{@rate_indicator}, packaging_type:"\
  " #{@packaging_type}, diameter: #{@diameter}, shape: #{@shape}, processing_category:"\
  " #{@processing_category}, destination_entry_facility_type:"\
  " #{@destination_entry_facility_type}, mailing_date: #{@mailing_date}, package_options:"\
  " #{@package_options}, customer_reference: #{@customer_reference}, extra_services:"\
  " #{@extra_services}, induction_zip_code: #{@induction_zip_code}, mail_owner_mid:"\
  " #{@mail_owner_mid}, logistics_manager_mid: #{@logistics_manager_mid},"\
  " prepay_duties_taxes_fees: #{@prepay_duties_taxes_fees}>"
end