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.
136 lines (135 loc) • 4.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Orders = void 0;
const infrastructure_1 = require("../infrastructure");
class Orders extends infrastructure_1.BaseService {
constructor(shopDomain, accessToken) {
super(shopDomain, accessToken, "orders");
}
/**
* Gets a count of all of the shop's orders.
* @param options Options for filtering the results.
*/
count(options) {
return this.createRequest("GET", "count.json", "count", options);
}
/**
* Gets a list of up to 250 of the shop's orders.
* @param options Options for filtering the results.
*/
list(options) {
return this.createRequest("GET", ".json", "orders", options);
}
/**
* Gets a list of up to 250 orders from the given customer.
* @param customerId The customer's id.
* @param options Options for filtering the results.
*/
listForCustomer(customerId, options) {
return this.createRequest("GET", ".json", "orders", Object.assign({ customer_id: customerId }, options));
}
/**
* Gets the order with the given id.
* @param orderId The order's id.
* @param options Options for filtering the results.
*/
get(orderId, options) {
return this.createRequest("GET", `${orderId}.json`, "order", options);
}
/**
* Creates an order.
* @param order The order being created.
* @param options Options for creating the order.
*/
create(order, transactions, options) {
return this.createRequest("POST", ".json", "order", { order: Object.assign({}, order, options, { transactions }) });
}
/**
* Updates an order with the given id.
* @param id The order's id.
* @param order The updated order.
*/
update(id, order) {
return this.createRequest("PUT", `${id}.json`, "order", { order });
}
/**
* Deletes an order with the given id.
* @param id The order's id.
*/
delete(id) {
return this.createRequest("DELETE", `${id}.json`);
}
/**
* Closes an order with the given id.
* @param id The order's id.
*/
close(id) {
return this.createRequest("POST", `${id}/close.json`, "order");
}
/**
* Opens an order with the given id.
* @param id The order's id.
*/
open(id) {
return this.createRequest("POST", `${id}/open.json`, "order");
}
/**
* Cancels an order with the given id.
* @param id The order's id.
* @param options Options for canceling the order.
*/
cancel(id, options) {
return this.createRequest("POST", `${id}/cancel.json`, 'order', options);
}
/**
* Gets a list of up to 250 metafields from the given order.
* @param id The order's id.
* @param options Options for filtering the results.
*/
listMetafields(orderId, options) {
return this.createRequest("GET", `${orderId}/metafields.json`, 'metafields', options);
}
/**
* Returns the number of metafields belonging to the given order.
* @param id The order's id.
*/
countMetafields(orderId) {
return this.createRequest("GET", `${orderId}/metafields/count.json`, 'count');
}
/**
* Gets the metafield with the given id from an order.
* @param orderId The order's id.
* @param id The metafield's id.
*/
getMetafield(orderId, id) {
return this.createRequest("GET", `${orderId}/metafields/${id}.json`, 'metafield');
}
/**
* Creates a metafield for the given order.
* @param orderId The order's id.
* @param id The metafield's id.
* @param metafield Options for the metafield
*/
createMetafield(orderId, metafield) {
return this.createRequest("POST", `${orderId}/metafields.json`, 'metafield', { metafield });
}
/**
* Updates a metafield for the given order
* @param orderId The order's id.
* @param id The metafield's id.
* @param metafield Options for the metafield
*/
updateMetafield(orderId, id, metafield) {
return this.createRequest("PUT", `${orderId}/metafields/${id}.json`, 'metafield', { metafield });
}
/**
* Deletes the metafield with the given id from an order.
* @param orderId The order's id.
* @param id The metafield's id.
*/
deleteMetafield(orderId, id) {
return this.createRequest("DELETE", `${orderId}/metafields/${id}.json`, 'metafield');
}
}
exports.Orders = Orders;
exports.default = Orders;