UNPKG

@lorenstuff/amazon-selling-partner-api

Version:

A package for interacting with the Amazon Selling Partner API.

108 lines 4.15 kB
// // Imports // import { AmazonSellingPartnerAPIError } from "./AmazonSellingPartnerAPIError.js"; // // Class // /** A client for v0 of the Merchant Fulfillment endpoints of the Amazon Selling Partner API. */ export class AmazonSellingPartnerMerchantFulfillmentAPIClient { amazonSellingPartnerApiClient; constructor(amazonSellingPartnerApiClient) { this.amazonSellingPartnerApiClient = amazonSellingPartnerApiClient; } async cancelShipment(shipmentId) { const response = await this.amazonSellingPartnerApiClient.request({ method: "DELETE", path: "/mfn/v0/shipments/" + shipmentId, }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } async cancelShipmentOld(shipmentId) { const response = await this.amazonSellingPartnerApiClient.request({ method: "POST", path: "/mfn/v0/shipments/" + shipmentId + "/cancel", }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } async createShipment(body) { const response = await this.amazonSellingPartnerApiClient.request({ method: "POST", path: "/mfn/v0/shipments", body: JSON.stringify(body), }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } async getAdditionalSellerInputs(body) { const response = await this.amazonSellingPartnerApiClient.request({ method: "POST", path: "/mfn/v0/additionalSellerInputs", body: JSON.stringify(body), }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } async getAdditionalSellerInputsOld(body) { const response = await this.amazonSellingPartnerApiClient.request({ method: "POST", path: "/mfn/v0/sellerInputs", body: JSON.stringify(body), }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } async getEligibleShipmentServices(body) { const response = await this.amazonSellingPartnerApiClient.request({ method: "POST", path: "/mfn/v0/eligibleShippingServices", body: JSON.stringify(body), }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } async getEligibleShipmentServicesOld(body) { const response = await this.amazonSellingPartnerApiClient.request({ method: "POST", path: "/mfn/v0/eligibleServices", body: JSON.stringify(body), }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } async getShipment(shipmentId) { const response = await this.amazonSellingPartnerApiClient.request({ method: "GET", path: "/mfn/v0/shipments/" + shipmentId, }); const responseData = await response.json(); if ("errors" in responseData) { throw new AmazonSellingPartnerAPIError(response, responseData.errors); } return responseData; } } //# sourceMappingURL=AmazonSellingPartnerMerchantFulfillmentAPIClient.js.map