Class: UspsApi::LabelPackageResponse
- Defined in:
- lib/usps_api/models/label_package_response.rb
Overview
LabelPackageResponse Model.
Instance Attribute Summary collapse
-
#banner_text ⇒ String
Banner text printed on the label.
-
#commitment ⇒ LabelsCommitment
The commitment and scheduled delivery date of the package.
-
#construct_code ⇒ String
The barcode construct code associated with the tracking number.
-
#dimensional_weight ⇒ Float
The dimensional weight of the package, if greater than specified in weight, in ounces.
-
#extra_services ⇒ Array[LabelsExtraServiceResponse]
Extra services requested on the mailpiece.
-
#fees ⇒ Array[Fee2]
Fees associated with the package.
-
#induction_type ⇒ Object
The permit holder induction type.
-
#label_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the package is being shipped from.
-
#label_broker_id ⇒ String
Unique Label Broker ID that can be used as an alternative to the Label Broker QR Code to retrieve the label at a Post Office.
-
#label_broker_qr ⇒ String
The Label Broker QR Code image, Base64 encoded file contents.
-
#label_image ⇒ String
Contains the Base64-encoded file contents of the label image.
-
#links ⇒ Array[AdjustmentsHypermediaLink]
Hypermedia links to related resources.
-
#mailing_date ⇒ DateTime
The date on which the package will be mailed as provided in the request.
-
#permit_holder_name ⇒ String
The permit holder name.
-
#postage ⇒ Float
Amount of Postage Required, does not include insurance or other extra service fees.
-
#receipt_image ⇒ String
Contains the Base64-encoded file contents of the label receipt image.
-
#retail_distribution_code ⇒ String
Retail Description Code associated with label.
-
#return_label ⇒ ReturnLabel
Return label.
-
#return_receipt_tracking_number ⇒ String
The human-readable version of the return Receipt tracking number.
-
#routing_information ⇒ String
The “420” 3-digit GS1 Application Identifier and the 5 or 9 digit Destination ZIP Code™.
-
#service_type_code ⇒ String
The Service Type Code associated with the package.
-
#sku ⇒ String
Pricing SKU.
-
#tracking_number ⇒ String
The human-readable version of the package tracking number.
-
#weight ⇒ Float
The package weight, in weightUOM.
-
#weight_uom ⇒ String
Weight Unit of Measurement * lb - Pounds.
-
#zone ⇒ String
Indicates the calculated zone used for pricing between the provided ‘originZIPCode` and `destinationZIPCode` for a given `mailClass`, `mailingDate`, `rateIndicator`, and `weight`.
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.
Instance Method Summary collapse
-
#initialize(label_address: SKIP, routing_information: SKIP, tracking_number: SKIP, construct_code: SKIP, sku: SKIP, postage: SKIP, extra_services: SKIP, service_type_code: SKIP, zone: SKIP, mailing_date: SKIP, commitment: SKIP, weight_uom: SKIP, weight: SKIP, dimensional_weight: SKIP, fees: SKIP, permit_holder_name: SKIP, induction_type: SKIP, label_broker_id: SKIP, banner_text: SKIP, retail_distribution_code: SKIP, return_receipt_tracking_number: SKIP, links: SKIP, label_image: SKIP, receipt_image: SKIP, label_broker_qr: SKIP, return_label: SKIP, additional_properties: nil) ⇒ LabelPackageResponse
constructor
A new instance of LabelPackageResponse.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_mailing_date ⇒ Object
-
#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(label_address: SKIP, routing_information: SKIP, tracking_number: SKIP, construct_code: SKIP, sku: SKIP, postage: SKIP, extra_services: SKIP, service_type_code: SKIP, zone: SKIP, mailing_date: SKIP, commitment: SKIP, weight_uom: SKIP, weight: SKIP, dimensional_weight: SKIP, fees: SKIP, permit_holder_name: SKIP, induction_type: SKIP, label_broker_id: SKIP, banner_text: SKIP, retail_distribution_code: SKIP, return_receipt_tracking_number: SKIP, links: SKIP, label_image: SKIP, receipt_image: SKIP, label_broker_qr: SKIP, return_label: SKIP, additional_properties: nil) ⇒ LabelPackageResponse
Returns a new instance of LabelPackageResponse.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/usps_api/models/label_package_response.rb', line 224 def initialize(label_address: SKIP, routing_information: SKIP, tracking_number: SKIP, construct_code: SKIP, sku: SKIP, postage: SKIP, extra_services: SKIP, service_type_code: SKIP, zone: SKIP, mailing_date: SKIP, commitment: SKIP, weight_uom: SKIP, weight: SKIP, dimensional_weight: SKIP, fees: SKIP, permit_holder_name: SKIP, induction_type: SKIP, label_broker_id: SKIP, banner_text: SKIP, retail_distribution_code: SKIP, return_receipt_tracking_number: SKIP, links: SKIP, label_image: SKIP, receipt_image: SKIP, label_broker_qr: SKIP, return_label: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @label_address = label_address unless label_address == SKIP @routing_information = routing_information unless routing_information == SKIP @tracking_number = tracking_number unless tracking_number == SKIP @construct_code = construct_code unless construct_code == SKIP @sku = sku unless sku == SKIP @postage = postage unless postage == SKIP @extra_services = extra_services unless extra_services == SKIP @service_type_code = service_type_code unless service_type_code == SKIP @zone = zone unless zone == SKIP @mailing_date = mailing_date unless mailing_date == SKIP @commitment = commitment unless commitment == SKIP @weight_uom = weight_uom unless weight_uom == SKIP @weight = weight unless weight == SKIP @dimensional_weight = dimensional_weight unless dimensional_weight == SKIP @fees = fees unless fees == SKIP @permit_holder_name = permit_holder_name unless permit_holder_name == SKIP @induction_type = induction_type unless induction_type == SKIP @label_broker_id = label_broker_id unless label_broker_id == SKIP @banner_text = unless == SKIP @retail_distribution_code = retail_distribution_code unless retail_distribution_code == SKIP unless return_receipt_tracking_number == SKIP @return_receipt_tracking_number = return_receipt_tracking_number end @links = links unless links == SKIP @label_image = label_image unless label_image == SKIP @receipt_image = receipt_image unless receipt_image == SKIP @label_broker_qr = label_broker_qr unless label_broker_qr == SKIP @return_label = return_label unless return_label == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#banner_text ⇒ String
Banner text printed on the label.
110 111 112 |
# File 'lib/usps_api/models/label_package_response.rb', line 110 def @banner_text end |
#commitment ⇒ LabelsCommitment
The commitment and scheduled delivery date of the package.
73 74 75 |
# File 'lib/usps_api/models/label_package_response.rb', line 73 def commitment @commitment end |
#construct_code ⇒ String
The barcode construct code associated with the tracking number.
37 38 39 |
# File 'lib/usps_api/models/label_package_response.rb', line 37 def construct_code @construct_code end |
#dimensional_weight ⇒ Float
The dimensional weight of the package, if greater than specified in weight, in ounces.
88 89 90 |
# File 'lib/usps_api/models/label_package_response.rb', line 88 def dimensional_weight @dimensional_weight end |
#extra_services ⇒ Array[LabelsExtraServiceResponse]
Extra services requested on the mailpiece.
50 51 52 |
# File 'lib/usps_api/models/label_package_response.rb', line 50 def extra_services @extra_services end |
#fees ⇒ Array[Fee2]
Fees associated with the package.
92 93 94 |
# File 'lib/usps_api/models/label_package_response.rb', line 92 def fees @fees end |
#induction_type ⇒ Object
The permit holder induction type.
100 101 102 |
# File 'lib/usps_api/models/label_package_response.rb', line 100 def induction_type @induction_type end |
#label_address ⇒ InternationalLabelsDomesticLabelAddress
The address where the package is being shipped from. The ZIP Code™ in the ‘fromAddress` object is used to calculate pricing. Notes:
-
The First and Last Name or Firm Name are always required.
-
If the ‘returnAddress` is not provided, the `fromAddress` will be used
as the ‘returnAddress`.
-
If the ‘returnLabel` field is set to “true”, then the `fromAddress` ZIP
Plus 4 is looked up by the API, unless the ‘ignoreBadAddress` field is set to true or the address cannot be found. If `ignoreBadAddress` field is true then ZIP Plus 4 is required.
24 25 26 |
# File 'lib/usps_api/models/label_package_response.rb', line 24 def label_address @label_address end |
#label_broker_id ⇒ String
Unique Label Broker ID that can be used as an alternative to the Label Broker QR Code to retrieve the label at a Post Office. Will only be provided when an imageType of LABEL_BROKER is requested.
106 107 108 |
# File 'lib/usps_api/models/label_package_response.rb', line 106 def label_broker_id @label_broker_id end |
#label_broker_qr ⇒ String
The Label Broker QR Code image, Base64 encoded file contents. Only provided if ‘imageType` in the `imageInfo` is set to `LABEL_BROKER`.
149 150 151 |
# File 'lib/usps_api/models/label_package_response.rb', line 149 def label_broker_qr @label_broker_qr end |
#label_image ⇒ String
Contains the Base64-encoded file contents of the label image. Provided only when ‘imageInfo.imageType` is not `NONE`. Note:
-
Not provided when Extra Service Code ‘415 - USPS Label Delivery` is
requested, as no images are returned for this service.
132 133 134 |
# File 'lib/usps_api/models/label_package_response.rb', line 132 def label_image @label_image end |
#links ⇒ Array[AdjustmentsHypermediaLink]
Hypermedia links to related resources.
124 125 126 |
# File 'lib/usps_api/models/label_package_response.rb', line 124 def links @links end |
#mailing_date ⇒ DateTime
The date on which the package will be mailed as provided in the request. If the time was not provided, it will be defaulted to 10:00 p.m. local time.
69 70 71 |
# File 'lib/usps_api/models/label_package_response.rb', line 69 def mailing_date @mailing_date end |
#permit_holder_name ⇒ String
The permit holder name.
96 97 98 |
# File 'lib/usps_api/models/label_package_response.rb', line 96 def permit_holder_name @permit_holder_name end |
#postage ⇒ Float
Amount of Postage Required, does not include insurance or other extra service fees.
46 47 48 |
# File 'lib/usps_api/models/label_package_response.rb', line 46 def postage @postage end |
#receipt_image ⇒ String
Contains the Base64-encoded file contents of the label receipt image. Provided only when ‘imageInfo.receiptOption` is `SEPARATE_PAGE`. Note:
-
When ‘imageInfo.imageType` is `ZPL203DPI` or `ZPL300DPI` and
‘imageInfo.receiptOption` is `SEPARATE_PAGE`, the receipt will be returned as an additional label segment within the single ZPL payload in `labelImage`. In this case, `receiptImage` will not be populated.
-
Not provided when Extra Service Code ‘415 - USPS Label Delivery` is
requested, as no images are returned for this service.
144 145 146 |
# File 'lib/usps_api/models/label_package_response.rb', line 144 def receipt_image @receipt_image end |
#retail_distribution_code ⇒ String
Retail Description Code associated with label.
114 115 116 |
# File 'lib/usps_api/models/label_package_response.rb', line 114 def retail_distribution_code @retail_distribution_code end |
#return_label ⇒ ReturnLabel
Return label
153 154 155 |
# File 'lib/usps_api/models/label_package_response.rb', line 153 def return_label @return_label end |
#return_receipt_tracking_number ⇒ String
The human-readable version of the return Receipt tracking number.
-
Note: This will be included in the response when
‘packageOptions.returnReceiptTracking` is set to true in the request.
120 121 122 |
# File 'lib/usps_api/models/label_package_response.rb', line 120 def return_receipt_tracking_number @return_receipt_tracking_number end |
#routing_information ⇒ String
The “420” 3-digit GS1 Application Identifier and the 5 or 9 digit Destination ZIP Code™.
29 30 31 |
# File 'lib/usps_api/models/label_package_response.rb', line 29 def routing_information @routing_information end |
#service_type_code ⇒ String
The Service Type Code associated with the package. A list of Service Type Codes can be found at: [postalpro.usps.com/IMPB_Service_Type_Codes](https://postalpro.usp s.com/IMPB_Service_Type_Codes).
57 58 59 |
# File 'lib/usps_api/models/label_package_response.rb', line 57 def service_type_code @service_type_code end |
#sku ⇒ String
Pricing SKU.
41 42 43 |
# File 'lib/usps_api/models/label_package_response.rb', line 41 def sku @sku end |
#tracking_number ⇒ String
The human-readable version of the package tracking number.
33 34 35 |
# File 'lib/usps_api/models/label_package_response.rb', line 33 def tracking_number @tracking_number end |
#weight ⇒ Float
The package weight, in weightUOM. Items must weigh 70 pounds (1120 ounces) or less.
83 84 85 |
# File 'lib/usps_api/models/label_package_response.rb', line 83 def weight @weight end |
#weight_uom ⇒ String
Weight Unit of Measurement
* lb - Pounds
78 79 80 |
# File 'lib/usps_api/models/label_package_response.rb', line 78 def weight_uom @weight_uom end |
#zone ⇒ String
Indicates the calculated zone used for pricing between the provided ‘originZIPCode` and `destinationZIPCode` for a given `mailClass`, `mailingDate`, `rateIndicator`, and `weight`.
63 64 65 |
# File 'lib/usps_api/models/label_package_response.rb', line 63 def zone @zone end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 305 306 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 376 377 378 379 |
# File 'lib/usps_api/models/label_package_response.rb', line 272 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. label_address = InternationalLabelsDomesticLabelAddress.from_hash(hash['labelAddress']) if hash['labelAddress'] routing_information = hash.key?('routingInformation') ? hash['routingInformation'] : SKIP tracking_number = hash.key?('trackingNumber') ? hash['trackingNumber'] : SKIP construct_code = hash.key?('constructCode') ? hash['constructCode'] : SKIP sku = hash.key?('SKU') ? hash['SKU'] : SKIP postage = hash.key?('postage') ? hash['postage'] : SKIP # Parameter is an array, so we need to iterate through it extra_services = nil unless hash['extraServices'].nil? extra_services = [] hash['extraServices'].each do |structure| extra_services << (LabelsExtraServiceResponse.from_hash(structure) if structure) end end extra_services = SKIP unless hash.key?('extraServices') service_type_code = hash.key?('serviceTypeCode') ? hash['serviceTypeCode'] : SKIP zone = hash.key?('zone') ? hash['zone'] : SKIP mailing_date = if hash.key?('mailingDate') (DateTimeHelper.from_rfc3339(hash['mailingDate']) if hash['mailingDate']) else SKIP end commitment = LabelsCommitment.from_hash(hash['commitment']) if hash['commitment'] weight_uom = hash.key?('weightUOM') ? hash['weightUOM'] : SKIP weight = hash.key?('weight') ? hash['weight'] : SKIP dimensional_weight = hash.key?('dimensionalWeight') ? hash['dimensionalWeight'] : SKIP # Parameter is an array, so we need to iterate through it fees = nil unless hash['fees'].nil? fees = [] hash['fees'].each do |structure| fees << (Fee2.from_hash(structure) if structure) end end fees = SKIP unless hash.key?('fees') permit_holder_name = hash.key?('permitHolderName') ? hash['permitHolderName'] : SKIP induction_type = hash.key?('inductionType') ? hash['inductionType'] : SKIP label_broker_id = hash.key?('labelBrokerID') ? hash['labelBrokerID'] : SKIP = hash.key?('bannerText') ? hash['bannerText'] : SKIP retail_distribution_code = hash.key?('retailDistributionCode') ? hash['retailDistributionCode'] : SKIP return_receipt_tracking_number = hash.key?('returnReceiptTrackingNumber') ? hash['returnReceiptTrackingNumber'] : SKIP # Parameter is an array, so we need to iterate through it links = nil unless hash['links'].nil? links = [] hash['links'].each do |structure| links << (AdjustmentsHypermediaLink.from_hash(structure) if structure) end end links = SKIP unless hash.key?('links') label_image = hash.key?('labelImage') ? hash['labelImage'] : SKIP receipt_image = hash.key?('receiptImage') ? hash['receiptImage'] : SKIP label_broker_qr = hash.key?('labelBrokerQR') ? hash['labelBrokerQR'] : SKIP return_label = ReturnLabel.from_hash(hash['returnLabel']) if hash['returnLabel'] # 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. LabelPackageResponse.new(label_address: label_address, routing_information: routing_information, tracking_number: tracking_number, construct_code: construct_code, sku: sku, postage: postage, extra_services: extra_services, service_type_code: service_type_code, zone: zone, mailing_date: mailing_date, commitment: commitment, weight_uom: weight_uom, weight: weight, dimensional_weight: dimensional_weight, fees: fees, permit_holder_name: permit_holder_name, induction_type: induction_type, label_broker_id: label_broker_id, banner_text: , retail_distribution_code: retail_distribution_code, return_receipt_tracking_number: return_receipt_tracking_number, links: links, label_image: label_image, receipt_image: receipt_image, label_broker_qr: label_broker_qr, return_label: return_label, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
156 157 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 |
# File 'lib/usps_api/models/label_package_response.rb', line 156 def self.names @_hash = {} if @_hash.nil? @_hash['label_address'] = 'labelAddress' @_hash['routing_information'] = 'routingInformation' @_hash['tracking_number'] = 'trackingNumber' @_hash['construct_code'] = 'constructCode' @_hash['sku'] = 'SKU' @_hash['postage'] = 'postage' @_hash['extra_services'] = 'extraServices' @_hash['service_type_code'] = 'serviceTypeCode' @_hash['zone'] = 'zone' @_hash['mailing_date'] = 'mailingDate' @_hash['commitment'] = 'commitment' @_hash['weight_uom'] = 'weightUOM' @_hash['weight'] = 'weight' @_hash['dimensional_weight'] = 'dimensionalWeight' @_hash['fees'] = 'fees' @_hash['permit_holder_name'] = 'permitHolderName' @_hash['induction_type'] = 'inductionType' @_hash['label_broker_id'] = 'labelBrokerID' @_hash['banner_text'] = 'bannerText' @_hash['retail_distribution_code'] = 'retailDistributionCode' @_hash['return_receipt_tracking_number'] = 'returnReceiptTrackingNumber' @_hash['links'] = 'links' @_hash['label_image'] = 'labelImage' @_hash['receipt_image'] = 'receiptImage' @_hash['label_broker_qr'] = 'labelBrokerQR' @_hash['return_label'] = 'returnLabel' @_hash end |
.nullables ⇒ Object
An array for nullable fields
220 221 222 |
# File 'lib/usps_api/models/label_package_response.rb', line 220 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/usps_api/models/label_package_response.rb', line 188 def self.optionals %w[ label_address routing_information tracking_number construct_code sku postage extra_services service_type_code zone mailing_date commitment weight_uom weight dimensional_weight fees permit_holder_name induction_type label_broker_id banner_text retail_distribution_code return_receipt_tracking_number links label_image receipt_image label_broker_qr return_label ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/usps_api/models/label_package_response.rb', line 403 def inspect class_name = self.class.name.split('::').last "<#{class_name} label_address: #{@label_address.inspect}, routing_information:"\ " #{@routing_information.inspect}, tracking_number: #{@tracking_number.inspect},"\ " construct_code: #{@construct_code.inspect}, sku: #{@sku.inspect}, postage:"\ " #{@postage.inspect}, extra_services: #{@extra_services.inspect}, service_type_code:"\ " #{@service_type_code.inspect}, zone: #{@zone.inspect}, mailing_date:"\ " #{@mailing_date.inspect}, commitment: #{@commitment.inspect}, weight_uom:"\ " #{@weight_uom.inspect}, weight: #{@weight.inspect}, dimensional_weight:"\ " #{@dimensional_weight.inspect}, fees: #{@fees.inspect}, permit_holder_name:"\ " #{@permit_holder_name.inspect}, induction_type: #{@induction_type.inspect},"\ " label_broker_id: #{@label_broker_id.inspect}, banner_text: #{@banner_text.inspect},"\ " retail_distribution_code: #{@retail_distribution_code.inspect},"\ " return_receipt_tracking_number: #{@return_receipt_tracking_number.inspect}, links:"\ " #{@links.inspect}, label_image: #{@label_image.inspect}, receipt_image:"\ " #{@receipt_image.inspect}, label_broker_qr: #{@label_broker_qr.inspect}, return_label:"\ " #{@return_label.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_mailing_date ⇒ Object
381 382 383 |
# File 'lib/usps_api/models/label_package_response.rb', line 381 def to_custom_mailing_date DateTimeHelper.to_rfc3339(mailing_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/usps_api/models/label_package_response.rb', line 386 def to_s class_name = self.class.name.split('::').last "<#{class_name} label_address: #{@label_address}, routing_information:"\ " #{@routing_information}, tracking_number: #{@tracking_number}, construct_code:"\ " #{@construct_code}, sku: #{@sku}, postage: #{@postage}, extra_services:"\ " #{@extra_services}, service_type_code: #{@service_type_code}, zone: #{@zone},"\ " mailing_date: #{@mailing_date}, commitment: #{@commitment}, weight_uom: #{@weight_uom},"\ " weight: #{@weight}, dimensional_weight: #{@dimensional_weight}, fees: #{@fees},"\ " permit_holder_name: #{@permit_holder_name}, induction_type: #{@induction_type},"\ " label_broker_id: #{@label_broker_id}, banner_text: #{@banner_text},"\ " retail_distribution_code: #{@retail_distribution_code}, return_receipt_tracking_number:"\ " #{@return_receipt_tracking_number}, links: #{@links}, label_image: #{@label_image},"\ " receipt_image: #{@receipt_image}, label_broker_qr: #{@label_broker_qr}, return_label:"\ " #{@return_label}, additional_properties: #{@additional_properties}>" end |