Class: UspsApi::LabelMetadata
- Defined in:
- lib/usps_api/models/label_metadata.rb
Overview
Label Metadata returned from label creation and label edit.
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.
-
#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.
-
#retail_distribution_code ⇒ String
Retail Description Code associated with 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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
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, additional_properties: nil) ⇒ LabelMetadata
constructor
A new instance of LabelMetadata.
-
#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, additional_properties: nil) ⇒ LabelMetadata
Returns a new instance of LabelMetadata.
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 219 220 221 222 223 224 225 226 |
# File 'lib/usps_api/models/label_metadata.rb', line 187 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, 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 @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_metadata.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_metadata.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_metadata.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_metadata.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_metadata.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_metadata.rb', line 92 def fees @fees end |
#induction_type ⇒ Object
The permit holder induction type.
100 101 102 |
# File 'lib/usps_api/models/label_metadata.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_metadata.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_metadata.rb', line 106 def label_broker_id @label_broker_id end |
#links ⇒ Array[AdjustmentsHypermediaLink]
Hypermedia links to related resources.
124 125 126 |
# File 'lib/usps_api/models/label_metadata.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_metadata.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_metadata.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_metadata.rb', line 46 def postage @postage end |
#retail_distribution_code ⇒ String
Retail Description Code associated with label.
114 115 116 |
# File 'lib/usps_api/models/label_metadata.rb', line 114 def retail_distribution_code @retail_distribution_code 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_metadata.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_metadata.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_metadata.rb', line 57 def service_type_code @service_type_code end |
#sku ⇒ String
Pricing SKU.
41 42 43 |
# File 'lib/usps_api/models/label_metadata.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_metadata.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_metadata.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_metadata.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_metadata.rb', line 63 def zone @zone end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/usps_api/models/label_metadata.rb', line 229 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') # 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. LabelMetadata.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, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
127 128 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/label_metadata.rb', line 127 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 end |
.nullables ⇒ Object
An array for nullable fields
183 184 185 |
# File 'lib/usps_api/models/label_metadata.rb', line 183 def self.nullables [] end |
.optionals ⇒ Object
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 179 180 |
# File 'lib/usps_api/models/label_metadata.rb', line 155 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 ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
335 336 337 338 339 340 341 |
# File 'lib/usps_api/models/label_metadata.rb', line 335 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/usps_api/models/label_metadata.rb', line 360 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}, additional_properties: #{@additional_properties}>" end |
#to_custom_mailing_date ⇒ Object
329 330 331 |
# File 'lib/usps_api/models/label_metadata.rb', line 329 def to_custom_mailing_date DateTimeHelper.to_rfc3339(mailing_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/usps_api/models/label_metadata.rb', line 344 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}, additional_properties:"\ " #{@additional_properties}>" end |