inventora-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.
59 lines (58 loc) • 1.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DraftOrders = void 0;
const infrastructure_1 = require("../infrastructure");
/**
* A service for manipulating Shopify draft orders.
*/
class DraftOrders extends infrastructure_1.BaseService {
constructor(shopDomain, accessToken) {
super(shopDomain, accessToken, "draft_orders");
}
/**
* Creates a new draft order.
*/
create(order, useCustomerDefaultAddress = false) {
const body = Object.assign(Object.assign({}, order), { use_customer_default_address: useCustomerDefaultAddress });
return this.createRequest("POST", ".json", "draft_order", { draft_order: body });
}
/**
* Updates the draft order with the given id.
*/
update(id, order) {
return this.createRequest("PUT", `${id}.json`, "draft_order", { draft_order: order });
}
/**
* Gets a list of up to 250 of the shop's draft orders.
* @param options Options for filtering the results.
*/
list(options) {
return this.createRequest("GET", ".json", "draft_orders", options);
}
/**
* Counts the draft orders on the shop.
*/
count(options) {
return this.createRequest("GET", "count.json", "count");
}
/**
* Retrieves the draft order with the given id.
*/
get(id) {
return this.createRequest("GET", `${id}.json`, "draft_order");
}
/**
* Deletes the draft order with the given id.
*/
delete(id) {
return this.createRequest("DELETE", `${id}.json`);
}
/**
* Completes the draft order, transitioning it to a full order.
*/
complete(id, paymentPending = false) {
return this.createRequest("POST", `${id}/complete.json?paymentPending=${paymentPending}`, "draft_order");
}
}
exports.DraftOrders = DraftOrders;
exports.default = DraftOrders;