shopify-admin-api
Version:
Shopify Admin API is a NodeJS library built to help developers easily authenticate and make calls against the Shopify API. It was inspired by and borrows heavily from ShopifySharp.
84 lines (83 loc) • 3.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Fulfillments = void 0;
const infrastructure_1 = require("../infrastructure");
/**
* A service for manipulating an order's fulfillments.
*/
class Fulfillments extends infrastructure_1.BaseService {
constructor(shopDomain, accessToken) {
super(shopDomain, accessToken, "orders");
}
getPath(orderId, path) {
return this.joinUriPaths(`${orderId}/fulfillments`, path);
}
/**
* Creates a new fulfillment.
* @param orderId Id of the order that the fulfillment will belong to.
* @param fulfillment The fulfillment being created.
*/
create(orderId, fulfillment) {
return this.createRequest("POST", this.getPath(orderId, ".json"), "fulfillment", { fulfillment });
}
/**
* Updates an fulfillment with the given id.
* @param orderId Id of the order that the fulfillment belongs to.
* @param fulfillmentId Id of the fulfillment to update.
* @param fulfillment The updated fulfillment.
*/
update(orderId, fulfillmentId, fulfillment) {
return this.createRequest("PUT", this.getPath(orderId, ".json"), "fulfillment", { fulfillment });
}
/**
* Gets an fulfillment with the given id.
* @param orderId Id of the order that the fulfillment belongs to.
* @param fulfillmentId Id of the fulfillment being retrieved.
* @param options Options for filtering the result.
*/
get(orderId, fulfillmentId, options) {
return this.createRequest("GET", this.getPath(orderId, `${fulfillmentId}.json`), "fulfillment", options);
}
/**
* Lists up to 250 fulfillments for the given order.
* @param orderId Id of the order that the fulfillments belong to.
* @param options Options for filtering the results.
*/
list(orderId, options) {
return this.createRequest("GET", this.getPath(orderId, ".json"), "fulfillments", options);
}
/**
* Counts the fulfillments on the given order.
* @param orderId Id of the order that the fulfillments belong to.
* @param options Options for filtering the results.
*/
count(orderId, options) {
return this.createRequest("GET", this.getPath(orderId, "count.json"), "count", options);
}
/**
* Opens a fulfillment with the given fulfillmentId.
* @param orderId Id of the order that the fulfillments belong to.
* @param fulfillmentId The fulfillment's id.
*/
open(orderId, fulfillmentId) {
return this.createRequest("POST", this.getPath(orderId, `${fulfillmentId}/open.json`), 'fulfillment');
}
/**
* Cancels a fulfillment with the given fulfillmentId.
* @param fulfillmentId The fulfillment's id.
* @param options Options for canceling the fulfillment.
*/
cancel(orderId, fulfillmentId) {
return this.createRequest("POST", this.getPath(orderId, `${fulfillmentId}/cancel.json`), 'fulfillment');
}
/**
* Complete a fulfillment with the given id.
* @param fulfillmentId The fulfillment's id.
* @param options Options for canceling the fulfillment.
*/
complete(orderId, fulfillmentId) {
return this.createRequest("POST", this.getPath(orderId, `${fulfillmentId}/complete.json`), 'fulfillment');
}
}
exports.Fulfillments = Fulfillments;
exports.default = Fulfillments;