Class: UspsApi::ReturnLabel
- Defined in:
- lib/usps_api/models/return_label.rb
Overview
Return label
Instance Attribute Summary collapse
-
#banner_text ⇒ String
Banner text printed on the label.
-
#dimensional_weight ⇒ Float
The dimensional weight of package, if greater than specified in weight, in ounces.
-
#extra_services ⇒ Array[LabelsExtraServiceResponse]
Extra services requested on the mailpiece.
-
#fees ⇒ Array[Fee2]
Fees associated to the package.
-
#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.
-
#links ⇒ Array[AdjustmentsHypermediaLink]
Hypermedia links to related resources.
-
#mailing_date ⇒ DateTime
The date and time when the request was processed, with a two-hour offset applied.
-
#postage ⇒ Float
Amount of Postage Required, does not include insurance or other extra service fees.
-
#retail_distribution_code ⇒ String
Retail Description Code associated with the label.
-
#return_label_image ⇒ String
Contains the Base64-encoded file contents of the return label image.
-
#return_receipt_image ⇒ String
Contains the Base64-encoded file contents of the return receipt image.
-
#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, sku: SKIP, postage: SKIP, extra_services: SKIP, service_type_code: SKIP, zone: SKIP, mailing_date: SKIP, weight_uom: SKIP, weight: SKIP, dimensional_weight: SKIP, fees: SKIP, label_broker_id: SKIP, banner_text: SKIP, retail_distribution_code: SKIP, links: SKIP, return_label_image: SKIP, return_receipt_image: SKIP, label_broker_qr: SKIP, additional_properties: nil) ⇒ ReturnLabel
constructor
A new instance of ReturnLabel.
-
#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, sku: SKIP, postage: SKIP, extra_services: SKIP, service_type_code: SKIP, zone: SKIP, mailing_date: SKIP, weight_uom: SKIP, weight: SKIP, dimensional_weight: SKIP, fees: SKIP, label_broker_id: SKIP, banner_text: SKIP, retail_distribution_code: SKIP, links: SKIP, return_label_image: SKIP, return_receipt_image: SKIP, label_broker_qr: SKIP, additional_properties: nil) ⇒ ReturnLabel
Returns a new instance of ReturnLabel.
182 183 184 185 186 187 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 |
# File 'lib/usps_api/models/return_label.rb', line 182 def initialize(label_address: SKIP, routing_information: SKIP, tracking_number: SKIP, sku: SKIP, postage: SKIP, extra_services: SKIP, service_type_code: SKIP, zone: SKIP, mailing_date: SKIP, weight_uom: SKIP, weight: SKIP, dimensional_weight: SKIP, fees: SKIP, label_broker_id: SKIP, banner_text: SKIP, retail_distribution_code: SKIP, links: SKIP, return_label_image: SKIP, return_receipt_image: SKIP, label_broker_qr: 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 @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 @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 @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 @links = links unless links == SKIP @return_label_image = return_label_image unless return_label_image == SKIP @return_receipt_image = return_receipt_image unless return_receipt_image == SKIP @label_broker_qr = label_broker_qr unless label_broker_qr == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#banner_text ⇒ String
Banner text printed on the label
93 94 95 |
# File 'lib/usps_api/models/return_label.rb', line 93 def @banner_text end |
#dimensional_weight ⇒ Float
The dimensional weight of package, if greater than specified in weight, in ounces.
79 80 81 |
# File 'lib/usps_api/models/return_label.rb', line 79 def dimensional_weight @dimensional_weight end |
#extra_services ⇒ Array[LabelsExtraServiceResponse]
Extra services requested on the mailpiece.
46 47 48 |
# File 'lib/usps_api/models/return_label.rb', line 46 def extra_services @extra_services end |
#fees ⇒ Array[Fee2]
Fees associated to the package.
83 84 85 |
# File 'lib/usps_api/models/return_label.rb', line 83 def fees @fees 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/return_label.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.
89 90 91 |
# File 'lib/usps_api/models/return_label.rb', line 89 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`.
123 124 125 |
# File 'lib/usps_api/models/return_label.rb', line 123 def label_broker_qr @label_broker_qr end |
#links ⇒ Array[AdjustmentsHypermediaLink]
Hypermedia links to related resources.
101 102 103 |
# File 'lib/usps_api/models/return_label.rb', line 101 def links @links end |
#mailing_date ⇒ DateTime
The date and time when the request was processed, with a two-hour offset applied.
64 65 66 |
# File 'lib/usps_api/models/return_label.rb', line 64 def mailing_date @mailing_date end |
#postage ⇒ Float
Amount of Postage Required, does not include insurance or other extra service fees.
42 43 44 |
# File 'lib/usps_api/models/return_label.rb', line 42 def postage @postage end |
#retail_distribution_code ⇒ String
Retail Description Code associated with the label
97 98 99 |
# File 'lib/usps_api/models/return_label.rb', line 97 def retail_distribution_code @retail_distribution_code end |
#return_label_image ⇒ String
Contains the Base64-encoded file contents of the return label image. Provided only when ‘imageInfo.returnLabel` is `true` and `imageInfo.imageType` is not `NONE`.
107 108 109 |
# File 'lib/usps_api/models/return_label.rb', line 107 def return_label_image @return_label_image end |
#return_receipt_image ⇒ String
Contains the Base64-encoded file contents of the return receipt image. Provided only when ‘imageInfo.returnLabel` is `true` and `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.
118 119 120 |
# File 'lib/usps_api/models/return_label.rb', line 118 def return_receipt_image @return_receipt_image 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/return_label.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)
53 54 55 |
# File 'lib/usps_api/models/return_label.rb', line 53 def service_type_code @service_type_code end |
#sku ⇒ String
Pricing SKU
37 38 39 |
# File 'lib/usps_api/models/return_label.rb', line 37 def sku @sku end |
#tracking_number ⇒ String
The human readable version of the package tracking number
33 34 35 |
# File 'lib/usps_api/models/return_label.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.
74 75 76 |
# File 'lib/usps_api/models/return_label.rb', line 74 def weight @weight end |
#weight_uom ⇒ String
Weight Unit of Measurement
* lb - Pounds
69 70 71 |
# File 'lib/usps_api/models/return_label.rb', line 69 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`.
59 60 61 |
# File 'lib/usps_api/models/return_label.rb', line 59 def zone @zone end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
218 219 220 221 222 223 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 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 305 306 307 308 309 310 311 312 313 |
# File 'lib/usps_api/models/return_label.rb', line 218 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 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 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') label_broker_id = hash.key?('labelBrokerID') ? hash['labelBrokerID'] : SKIP = hash.key?('bannerText') ? hash['bannerText'] : SKIP retail_distribution_code = hash.key?('retailDistributionCode') ? hash['retailDistributionCode'] : 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') return_label_image = hash.key?('returnLabelImage') ? hash['returnLabelImage'] : SKIP return_receipt_image = hash.key?('returnReceiptImage') ? hash['returnReceiptImage'] : SKIP label_broker_qr = hash.key?('labelBrokerQR') ? hash['labelBrokerQR'] : 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. ReturnLabel.new(label_address: label_address, routing_information: routing_information, tracking_number: tracking_number, sku: sku, postage: postage, extra_services: extra_services, service_type_code: service_type_code, zone: zone, mailing_date: mailing_date, weight_uom: weight_uom, weight: weight, dimensional_weight: dimensional_weight, fees: fees, label_broker_id: label_broker_id, banner_text: , retail_distribution_code: retail_distribution_code, links: links, return_label_image: return_label_image, return_receipt_image: return_receipt_image, label_broker_qr: label_broker_qr, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/usps_api/models/return_label.rb', line 126 def self.names @_hash = {} if @_hash.nil? @_hash['label_address'] = 'labelAddress' @_hash['routing_information'] = 'routingInformation' @_hash['tracking_number'] = 'trackingNumber' @_hash['sku'] = 'SKU' @_hash['postage'] = 'postage' @_hash['extra_services'] = 'extraServices' @_hash['service_type_code'] = 'serviceTypeCode' @_hash['zone'] = 'zone' @_hash['mailing_date'] = 'mailingDate' @_hash['weight_uom'] = 'weightUOM' @_hash['weight'] = 'weight' @_hash['dimensional_weight'] = 'dimensionalWeight' @_hash['fees'] = 'fees' @_hash['label_broker_id'] = 'labelBrokerID' @_hash['banner_text'] = 'bannerText' @_hash['retail_distribution_code'] = 'retailDistributionCode' @_hash['links'] = 'links' @_hash['return_label_image'] = 'returnLabelImage' @_hash['return_receipt_image'] = 'returnReceiptImage' @_hash['label_broker_qr'] = 'labelBrokerQR' @_hash end |
.nullables ⇒ Object
An array for nullable fields
178 179 180 |
# File 'lib/usps_api/models/return_label.rb', line 178 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/usps_api/models/return_label.rb', line 152 def self.optionals %w[ label_address routing_information tracking_number sku postage extra_services service_type_code zone mailing_date weight_uom weight dimensional_weight fees label_broker_id banner_text retail_distribution_code links return_label_image return_receipt_image label_broker_qr ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/usps_api/models/return_label.rb', line 334 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}, 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}, weight_uom: #{@weight_uom.inspect}, weight: #{@weight.inspect},"\ " dimensional_weight: #{@dimensional_weight.inspect}, fees: #{@fees.inspect},"\ " label_broker_id: #{@label_broker_id.inspect}, banner_text: #{@banner_text.inspect},"\ " retail_distribution_code: #{@retail_distribution_code.inspect}, links: #{@links.inspect},"\ " return_label_image: #{@return_label_image.inspect}, return_receipt_image:"\ " #{@return_receipt_image.inspect}, label_broker_qr: #{@label_broker_qr.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_custom_mailing_date ⇒ Object
315 316 317 |
# File 'lib/usps_api/models/return_label.rb', line 315 def to_custom_mailing_date DateTimeHelper.to_rfc3339(mailing_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/usps_api/models/return_label.rb', line 320 def to_s class_name = self.class.name.split('::').last "<#{class_name} label_address: #{@label_address}, routing_information:"\ " #{@routing_information}, tracking_number: #{@tracking_number}, sku: #{@sku}, postage:"\ " #{@postage}, extra_services: #{@extra_services}, service_type_code: #{@service_type_code},"\ " zone: #{@zone}, mailing_date: #{@mailing_date}, weight_uom: #{@weight_uom}, weight:"\ " #{@weight}, dimensional_weight: #{@dimensional_weight}, fees: #{@fees}, label_broker_id:"\ " #{@label_broker_id}, banner_text: #{@banner_text}, retail_distribution_code:"\ " #{@retail_distribution_code}, links: #{@links}, return_label_image:"\ " #{@return_label_image}, return_receipt_image: #{@return_receipt_image}, label_broker_qr:"\ " #{@label_broker_qr}, additional_properties: #{@additional_properties}>" end |