UNPKG

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.

65 lines (64 loc) 2.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InventoryLevels = void 0; const infrastructure_1 = require("../infrastructure"); /** * A service for manipulating Shopify's InventoryLevels API. */ class InventoryLevels extends infrastructure_1.BaseService { constructor(shopDomain, accessToken) { super(shopDomain, accessToken, "inventory_levels"); } /** * Gets a list of up to 250 of the shop's inventory levels. * @param options Options for filtering the result. */ list(options) { return this.createRequest("GET", ".json", "inventory_levels", options); } /** * Adjusts the inventory level of an inventory item at a single location. * @param options Options for adjusting an inventory level. */ adjust(inventoryItemId, locationId, availableAdjustment) { return this.createRequest("POST", `adjust.json`, "inventory_level", { location_id: locationId, inventory_item_id: inventoryItemId, available_adjustment: availableAdjustment }); } /** * Deletes an inventory level of an inventory item at a location. * @param inventoryItemId Id of the inventory item. * @param locationId Id of the location being retrieved. */ delete(inventoryItemId, locationId) { return this.createRequest("DELETE", `.json?inventory_item_id=${inventoryItemId}&location_id=${locationId}`, "inventory_level"); } /** * Connects an inventory item to a location by creating an inventory level at that location. * @param inventoryItemId Id of the inventory item. * @param locationId Id of the location being retrieved. * @param options Options for connecting an inventory level. */ connect(inventoryItemId, locationId, options) { return this.createRequest("POST", `connect.json`, "inventory_level", { location_id: locationId, inventory_item_id: inventoryItemId, ...options }); } /** * Sets the inventory level for an inventory item at a location. * @param inventoryLevel Inventory level being set. * @param options Options for adjusting an inventory level. */ set(inventoryLevel, options) { return this.createRequest("POST", `set.json`, "inventory_level", { ...inventoryLevel, ...options }); } } exports.InventoryLevels = InventoryLevels; exports.default = InventoryLevels;