UNPKG

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.

94 lines (93 loc) 3.09 kB
"use strict"; 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)); } /** * Retrieves a list of fulfillment orders for a specific order. * @param orderId The ID of the order that is associated with the fulfillment orders. */ listFulfillmentOrders(orderId) { return this.createRequest("GET", `${orderId}/fulfillment_orders.json`, "fulfillment_orders"); } /** * 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); } } exports.Orders = Orders; exports.default = Orders;