Class: UspsApi::ReturnLabelPackageResponse

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

Overview

ReturnLabelPackageResponse Model.

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(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) ⇒ ReturnLabelPackageResponse

Returns a new instance of ReturnLabelPackageResponse.



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
216
217
218
# File 'lib/usps_api/models/return_label_package_response.rb', line 185

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 = banner_text unless banner_text == 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 printed on the label

Returns:

  • (String)


93
94
95
# File 'lib/usps_api/models/return_label_package_response.rb', line 93

def banner_text
  @banner_text
end

#dimensional_weightFloat

The dimensional weight of package, if greater than specified in weight, in ounces.

Returns:

  • (Float)


79
80
81
# File 'lib/usps_api/models/return_label_package_response.rb', line 79

def dimensional_weight
  @dimensional_weight
end

#extra_servicesArray[LabelsExtraServiceResponse]

Extra services requested on the mailpiece.

Returns:



46
47
48
# File 'lib/usps_api/models/return_label_package_response.rb', line 46

def extra_services
  @extra_services
end

#feesArray[Fee2]

Fees associated to the package.

Returns:



83
84
85
# File 'lib/usps_api/models/return_label_package_response.rb', line 83

def fees
  @fees
end

#label_addressInternationalLabelsDomesticLabelAddress

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_package_response.rb', line 24

def label_address
  @label_address
end

#label_broker_idString

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.

Returns:

  • (String)


89
90
91
# File 'lib/usps_api/models/return_label_package_response.rb', line 89

def label_broker_id
  @label_broker_id
end

#label_broker_qrString

The Label Broker QR Code image, Base64 encoded file contents. Only provided if ‘imageType` in the `imageInfo` is set to `LABEL_BROKER`.

Returns:

  • (String)


126
127
128
# File 'lib/usps_api/models/return_label_package_response.rb', line 126

def label_broker_qr
  @label_broker_qr
end

Hypermedia links to related resources.

Returns:



101
102
103
# File 'lib/usps_api/models/return_label_package_response.rb', line 101

def links
  @links
end

#mailing_dateDateTime

The date and time when the request was processed, with a two-hour offset applied.

Returns:

  • (DateTime)


64
65
66
# File 'lib/usps_api/models/return_label_package_response.rb', line 64

def mailing_date
  @mailing_date
end

#postageFloat

Amount of Postage Required, does not include insurance or other extra service fees.

Returns:

  • (Float)


42
43
44
# File 'lib/usps_api/models/return_label_package_response.rb', line 42

def postage
  @postage
end

#retail_distribution_codeString

Retail Description Code associated with the label

Returns:

  • (String)


97
98
99
# File 'lib/usps_api/models/return_label_package_response.rb', line 97

def retail_distribution_code
  @retail_distribution_code
end

#return_label_imageString

Contains the Base64-encoded file contents of the return 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.

Returns:

  • (String)


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

def return_label_image
  @return_label_image
end

#return_receipt_imageString

Contains the Base64-encoded file contents of the return 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.

Returns:

  • (String)


121
122
123
# File 'lib/usps_api/models/return_label_package_response.rb', line 121

def return_receipt_image
  @return_receipt_image
end

#routing_informationString

The “420” 3-digit GS1 Application Identifier and the 5 or 9 digit Destination ZIP Code™

Returns:

  • (String)


29
30
31
# File 'lib/usps_api/models/return_label_package_response.rb', line 29

def routing_information
  @routing_information
end

#service_type_codeString

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)

Returns:

  • (String)


53
54
55
# File 'lib/usps_api/models/return_label_package_response.rb', line 53

def service_type_code
  @service_type_code
end

#skuString

Pricing SKU

Returns:

  • (String)


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

def sku
  @sku
end

#tracking_numberString

The human readable version of the package tracking number

Returns:

  • (String)


33
34
35
# File 'lib/usps_api/models/return_label_package_response.rb', line 33

def tracking_number
  @tracking_number
end

#weightFloat

The package weight, in weightUOM. Items must weigh 70 pounds (1120 ounces) or less.

Returns:

  • (Float)


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

def weight
  @weight
end

#weight_uomString

Weight Unit of Measurement

* lb - Pounds

Returns:

  • (String)


69
70
71
# File 'lib/usps_api/models/return_label_package_response.rb', line 69

def weight_uom
  @weight_uom
end

#zoneString

Indicates the calculated zone used for pricing between the provided ‘originZIPCode` and `destinationZIPCode` for a given `mailClass`, `mailingDate`, `rateIndicator`, and `weight`.

Returns:

  • (String)


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

def zone
  @zone
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
314
315
316
# File 'lib/usps_api/models/return_label_package_response.rb', line 221

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
  banner_text = 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.
  ReturnLabelPackageResponse.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: 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

.namesObject

A mapping from model property names to API property names.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/usps_api/models/return_label_package_response.rb', line 129

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

.nullablesObject

An array for nullable fields



181
182
183
# File 'lib/usps_api/models/return_label_package_response.rb', line 181

def self.nullables
  []
end

.optionalsObject

An array for optional fields



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/usps_api/models/return_label_package_response.rb', line 155

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

#inspectObject

Provides a debugging-friendly string with detailed object information.



337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/usps_api/models/return_label_package_response.rb', line 337

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_dateObject



318
319
320
# File 'lib/usps_api/models/return_label_package_response.rb', line 318

def to_custom_mailing_date
  DateTimeHelper.to_rfc3339(mailing_date)
end

#to_sObject

Provides a human-readable string representation of the object.



323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/usps_api/models/return_label_package_response.rb', line 323

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