GetPackageLabel Method
Generates a shipping label for the first package in the shipment.
Syntax
uspsshipintl.getPackageLabel([callback])
Callback
The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).
The callback for this method is defined as:
function(err){ }
'err' is the error that occurred. If there was no error, then 'err' is 'null'.
'err' has 2 properties which hold detailed information:
err.code err.message
Remarks
When this method is called, the following properties are used to construct the request: properties:
- USPSUserId (required for API authentication)
- SenderFirstName (required unless SenderCompany is provided)
- SenderMiddleInitial (optional)
- SenderLastName (required unless SenderCompany is provided)
- SenderCompany (optional if SenderFirstName and SenderLastName are provided)
- SenderPhone (required)
- SenderAddress1 (optional)
- SenderAddress2 (required)
- SenderCity (required)
- SenderState (required)
- SenderZipCode (required)
- RecipientFirstName (you must send either a name or RecipientCompany (or both))
- RecipientLastName (you must send either a name or RecipientCompany (or both))
- RecipientCompany (optional if name is provided)
- RecipientAddress1 (at least one address line is required)
- RecipientAddress2
- RecipientAddress3
- RecipientCity (required)
- RecipientState (Province, optional)
- RecipientCountryCode (required)
- RecipientZipCode (Postal Code, optional)
- RecipientPhone (optional)
- RecipientFax (optional)
- RecipientEmail (optional)
- NonDeliveryOption (if this is set to "REDIRECT" provide the return address via Config)
- CommodityDescription (required)
- CommodityQuantity (required)
- CommodityManufacturer (optional)
- CommodityValue (required)
- CommodityHarmonizedCode (optional)
- CommodityWeight (required)
- PackageNetCharge (optional - if left blank the server will return the postage cost here)
- PackageWeight (required)
- Contents (required - if set to ctOther OtherContents must be set)
- Comments (optional)
- ShipDate (optional. If specified must be within 3 days)
- MailingLocation (optional)
- CustomerId (optional)
- LabelImageType (required)
- ImageLayout (required)
- PackageShippingLabelFile (optional if you wish to save the labels to disk)
- CertificateNumber (optional)
- InvoiceNumber (optional)
- LicenseNumber (optional)
This method fills the following properties:
- PackageNetCharge
- PackageTrackingNumber
- TotalValue
- SDRValue
- IndemnityCoverage (Priority Mail only)
- Prohibitions
- Observations
- Restrictions
- Regulations
- Notes
- PackageShippingLabel
If PackageShippingLabelFile was specified with a path and filename, all of the returned label images will also be saved to disk.