### Get Basic Canada Post Shipment Information Source: https://github.com/t3rminus/canada-post/blob/master/API.md Obtains basic information for a specific shipment using its `id` (String) from the Canada Post API. This function returns a Promise that resolves to an Object. The resolved object includes `shipmentId`, `trackingPin`, and links to the shipment's receipt and shipping label. ```JavaScript .getShipment(id) ``` -------------------------------- ### Getting Shipping Rates with Canada Post API in JavaScript Source: https://github.com/t3rminus/canada-post/blob/master/API.md The `.getRates(scenario)` function retrieves available shipping services and their prices for a given mailing scenario from the Canada Post API. It takes a `scenario` object detailing `parcelCharacteristics` (weight, dimensions), `originPostalCode`, and `destination` (domestic, US, or international). The function returns a Promise that resolves to an array of available services and their prices. ```JavaScript .getRates(scenario) ``` -------------------------------- ### Get Canada Post Tracking Detail Source: https://github.com/t3rminus/canada-post/blob/master/API.md Fetches detailed tracking information for a shipment via the Canada Post API. Parameters include `pin` (String: PIN or DNC number) and an optional `type` (String: 'pin' or 'dnc', default 'pin'). This asynchronous function returns a Promise that resolves to an Object containing `expectedDeliveryDate` and an array of `significantEvents`. ```JavaScript .getTrackingDetail(pin, type) ``` -------------------------------- ### Instantiating CanadaPostClient in JavaScript Source: https://github.com/t3rminus/canada-post/blob/master/API.md Creates a new instance of the CanadaPostClient class for interacting with the Canada Post API. It requires `userId` (String) and `password` (String) for authentication. Optional arguments include `customer` (String, customer ID), `lang` (String, 'en-CA' or 'fr-CA' for response language), and `useTestEndpoint` (Boolean, to force test/live endpoint; if omitted, NODE_ENV determines usage). The example demonstrates client creation and a subsequent call to `discoverServices`. Returns a `CanadaPostClient` instance. ```javascript const cpClient = new CanadaPostClient('b4c32...', 'c0009a...'); let result = cpClient.discoverServices('P0ST4L','US'); ``` -------------------------------- ### Get Canada Post Tracking Summary Source: https://github.com/t3rminus/canada-post/blob/master/API.md Retrieves basic tracking information for a shipment using the Canada Post API. It accepts a `pin` (String: Parcel Identification Number or Delivery Notice Card number) and an optional `type` (String: 'pin' or 'dnc', default 'pin'). The function returns a Promise resolving to an Object with `expectedDeliveryDate` and the latest shipping event. ```JavaScript .getTrackingSummary(pin, type) ``` -------------------------------- ### Get Detailed Canada Post Shipment Information Source: https://github.com/t3rminus/canada-post/blob/master/API.md Retrieves comprehensive details for a specific shipment by its `id` (String) using the Canada Post API. It returns a Promise resolving to an Object with extensive shipping data, typically including a `nonContractShipmentDetails` object. This object details sender/recipient information, `finalShippingPoint`, `trackingPin`, `refundRequestInfo`, `deliverySpec` (including `serviceCode`), parcel characteristics (weight in kilograms, dimensions in centimeters), and `preferences` (like `showPackingInstructions`). ```JavaScript .getShipmentDetails(id) ``` -------------------------------- ### List Canada Post Shipments by Date Range Source: https://github.com/t3rminus/canada-post/blob/master/API.md Retrieves a list of shipments from the Canada Post API recorded within a specified date range. It requires a `from` (Date: start date) and an optional `to` (Date: end date, defaults to current date). The function returns a Promise resolving to an Array of shipment objects, each including `shipmentId`. Note: Canada Post discards time zone info, assuming Eastern time. ```JavaScript .getShipments(from, to) ``` -------------------------------- ### Creating Non-Contract Shipments with Canada Post API in JavaScript Source: https://github.com/t3rminus/canada-post/blob/master/API.md The `.createNonContractShipment(shipment)` function creates a non-contract shipment via the Canada Post API. It requires a `shipment` object containing details like `requestedShippingPoint`, `deliverySpec` (including `serviceCode`, `sender` and `destination` addresses, `parcelCharacteristics`), and `preferences`. The function returns a Promise that resolves to an object with shipment details, including `shipmentId` and `trackingPin`. ```JavaScript .createNonContractShipment(shipment) ``` -------------------------------- ### Refunding Non-Contract Shipments with Canada Post API in JavaScript Source: https://github.com/t3rminus/canada-post/blob/master/API.md The `.refundNonContractShipment(id, email)` function initiates a refund request for a non-contract shipment using the Canada Post API. It takes the `id` (shipment ID) and the account holder's `email` as arguments. The function returns a Promise that resolves to an object containing a `serviceTicketId` for tracking the refund request; successful resolution means the request is submitted, not that the refund is processed. ```JavaScript .refundNonContractShipment(id, email) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.