Skip to content

Commit

Permalink
feat: change shipment API
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-conde committed Nov 7, 2023
1 parent 360f0e0 commit 8404b03
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions js/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ export const ShipmentAPI = superclass =>
* @see https://www.ups.com/upsdeveloperkit?loc=en_US
*/
async createShipment(payload, options = {}) {
const url = this.shippingBaseUrl + "shipments";
const url = `${this.baseUrl}shipments/${this.version}/ship`;
const response = await this.post(url, {
kwargs: { auth: "headers" },
...options,
dataJ: { ShipmentRequest: payload }
});
Expand All @@ -144,30 +143,8 @@ export const ShipmentAPI = superclass =>
* @see https://www.ups.com/upsdeveloperkit?loc=en_US
*/
async cancelShipment(trackingNumber, options = {}) {
const url = `${this.shippingBaseUrl}shipments/cancel/${trackingNumber}`;
const response = await this.delete(url, {
kwargs: { auth: "headers" },
...options
});
return response;
}

/**
* Adds the already uploaded documents in the UPS servers to an
* existing shipment.
*
* @param {Object} payload The payload object according to the UPS API standards.
* @param {Object} options An object of options to configure the request.
* @returns {Object} The HTTP response object.
* @see https://www.ups.com/upsdeveloperkit?loc=en_US
*/
async addDocumentShipment(payload, options = {}) {
const url = this._getDocumentBaseUrl();
const response = await this.post(url, {
kwargs: { auth: "dataJ" },
...options,
dataJ: { PushToImageRepositoryRequest: payload }
});
const url = `${this.baseUrl}shipments/${this.version}/void/cancel/${trackingNumber}`;
const response = await this.delete(url, options);
return response;
}

Expand All @@ -180,9 +157,8 @@ export const ShipmentAPI = superclass =>
* @see https://www.ups.com/upsdeveloperkit?loc=en_US
*/
async getWaybill(trackingNumber, { format = "pdf", ...options } = {}) {
const url = this.shippingBaseUrl + "shipments/labels";
const url = `${this.baseUrl}labels/${this.version}/recovery`;
const response = await this.post(url, {
kwargs: { auth: "headers" },
...options,
dataJ: {
LabelRecoveryRequest: {
Expand Down

0 comments on commit 8404b03

Please sign in to comment.