Class: UspsApi::ShipmentsInternationalPackageDescription
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::ShipmentsInternationalPackageDescription
- Defined in:
- lib/usps_api/models/shipments_international_package_description.rb
Overview
Details of package being shipped
Instance Attribute Summary collapse
-
#extra_services ⇒ Array[ExtraServiceCodes]
Extra Services requested on the package.
-
#girth ⇒ Float
The girth of the container, in dimensionsUOM.
-
#has_nonstandard_characteristics ⇒ TrueClass | FalseClass
Package is nonstandard.
-
#height ⇒ Float
The height of the container, in dimensionsUOM.
-
#length ⇒ Float
The length of the container, in dimensionsUOM.
-
#mail_class ⇒ MailClass21
International Mail classes for the label.
-
#mailing_date ⇒ Object
Supports either a date or date-time entry, if using a date the time will be defaulted to 6:00 pm local time for the purpose of Service Delivery Standard estimates.
-
#package_value ⇒ Float
The merchandise value of the package, in US dollars.
-
#weight ⇒ Float
The package weight, in weightUOM (Unit Of Measure).
-
#width ⇒ Float
The width of the container, in dimensionsUOM.
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(weight:, length:, height:, width:, mail_class:, girth: SKIP, has_nonstandard_characteristics: false, extra_services: SKIP, package_value: SKIP, mailing_date: SKIP, additional_properties: nil) ⇒ ShipmentsInternationalPackageDescription
constructor
A new instance of ShipmentsInternationalPackageDescription.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_union_type_mailing_date ⇒ 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(weight:, length:, height:, width:, mail_class:, girth: SKIP, has_nonstandard_characteristics: false, extra_services: SKIP, package_value: SKIP, mailing_date: SKIP, additional_properties: nil) ⇒ ShipmentsInternationalPackageDescription
Returns a new instance of ShipmentsInternationalPackageDescription.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 134 def initialize(weight:, length:, height:, width:, mail_class:, girth: SKIP, has_nonstandard_characteristics: false, extra_services: SKIP, package_value: SKIP, mailing_date: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @weight = weight @length = length @height = height @width = width @girth = girth unless girth == SKIP unless has_nonstandard_characteristics == SKIP @has_nonstandard_characteristics = has_nonstandard_characteristics end @mail_class = mail_class @extra_services = extra_services unless extra_services == SKIP @package_value = package_value unless package_value == SKIP @mailing_date = mailing_date unless mailing_date == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#extra_services ⇒ Array[ExtraServiceCodes]
Extra Services requested on the package. The available options are:
-
370 - USPS Delivery Duties Paid Fee
-
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)
86 87 88 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 86 def extra_services @extra_services end |
#girth ⇒ Float
The girth of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non- rectangular package in addition to Length, Width, 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.
59 60 61 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 59 def girth @girth end |
#has_nonstandard_characteristics ⇒ TrueClass | FalseClass
Package is nonstandard. Nonstandard packages include cylindrical tubes and rolls, certain high-density items, cartons containing more than 24 ounces of liquids in one or more glass containers, cartons containing 1 gallon or more of liquid in metal or plastic containers, and items in [201.7.6.2](pe.usps.com/text/dmm300/201.htm#7.6.2).
67 68 69 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 67 def has_nonstandard_characteristics @has_nonstandard_characteristics end |
#height ⇒ Float
The height of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non- rectangular package in addition to Length, Width, 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.
37 38 39 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 37 def height @height end |
#length ⇒ Float
The length of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non- rectangular package in addition to Length, Width, 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.
26 27 28 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 26 def length @length end |
#mail_class ⇒ MailClass21
International Mail classes for the label. ‘GLOBAL_EXPRESS_GUARANTEED` is supported by shipping options, but is not supported by labels. Global Express Guaranteed Service is suspended as of September 29, 2024.
74 75 76 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 74 def mail_class @mail_class end |
#mailing_date ⇒ Object
Supports either a date or date-time entry, if using a date the time will be defaulted to 6:00 pm local time for the purpose of Service Delivery Standard estimates. A mailing date of 0-30 days in advance can be requested.
99 100 101 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 99 def mailing_date @mailing_date end |
#package_value ⇒ Float
The merchandise value of the package, in US dollars. Required to receive prices for Insurance. The price of the Insurance extra service will vary based on the ‘packageValue` requested.
92 93 94 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 92 def package_value @package_value end |
#weight ⇒ Float
The package weight, in weightUOM (Unit Of Measure). Items must weigh 70 pounds (1120 ounces) or less.
15 16 17 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 15 def weight @weight end |
#width ⇒ Float
The width of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non- rectangular package in addition to Length, Width, 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.
48 49 50 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 48 def width @width end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 158 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 girth = hash.key?('girth') ? hash['girth'] : SKIP has_nonstandard_characteristics = hash['hasNonstandardCharacteristics'] ||= false extra_services = hash.key?('extraServices') ? hash['extraServices'] : SKIP package_value = hash.key?('packageValue') ? hash['packageValue'] : SKIP mailing_date = hash.key?('mailingDate') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:ShipmentsInternationalPackageDescriptionMailingDate), hash['mailingDate'] ) : 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. ShipmentsInternationalPackageDescription.new(weight: weight, length: length, height: height, width: width, mail_class: mail_class, girth: girth, has_nonstandard_characteristics: has_nonstandard_characteristics, extra_services: extra_services, package_value: package_value, mailing_date: mailing_date, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 102 def self.names @_hash = {} if @_hash.nil? @_hash['weight'] = 'weight' @_hash['length'] = 'length' @_hash['height'] = 'height' @_hash['width'] = 'width' @_hash['girth'] = 'girth' @_hash['has_nonstandard_characteristics'] = 'hasNonstandardCharacteristics' @_hash['mail_class'] = 'mailClass' @_hash['extra_services'] = 'extraServices' @_hash['package_value'] = 'packageValue' @_hash['mailing_date'] = 'mailingDate' @_hash end |
.nullables ⇒ Object
An array for nullable fields
130 131 132 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 130 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
119 120 121 122 123 124 125 126 127 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 119 def self.optionals %w[ girth has_nonstandard_characteristics extra_services package_value mailing_date ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 205 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.weight, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.length, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.height, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.width, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.mail_class, ->(val) { MailClass21.validate(val) }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['weight'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['length'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['height'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['width'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['mailClass'], ->(val) { MailClass21.validate(val) }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
248 249 250 251 252 253 254 255 256 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 248 def inspect class_name = self.class.name.split('::').last "<#{class_name} weight: #{@weight.inspect}, length: #{@length.inspect}, height:"\ " #{@height.inspect}, width: #{@width.inspect}, girth: #{@girth.inspect},"\ " has_nonstandard_characteristics: #{@has_nonstandard_characteristics.inspect}, mail_class:"\ " #{@mail_class.inspect}, extra_services: #{@extra_services.inspect}, package_value:"\ " #{@package_value.inspect}, mailing_date: #{@mailing_date.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
238 239 240 241 242 243 244 245 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 238 def to_s class_name = self.class.name.split('::').last "<#{class_name} weight: #{@weight}, length: #{@length}, height: #{@height}, width:"\ " #{@width}, girth: #{@girth}, has_nonstandard_characteristics:"\ " #{@has_nonstandard_characteristics}, mail_class: #{@mail_class}, extra_services:"\ " #{@extra_services}, package_value: #{@package_value}, mailing_date: #{@mailing_date},"\ " additional_properties: #{@additional_properties}>" end |
#to_union_type_mailing_date ⇒ Object
197 198 199 200 201 |
# File 'lib/usps_api/models/shipments_international_package_description.rb', line 197 def to_union_type_mailing_date UnionTypeLookUp.get(:ShipmentsInternationalPackageDescriptionMailingDate) .validate(mailing_date) .serialize(mailing_date) end |