import * as Options from '../options'; import { BaseService } from '../infrastructure'; import { InventoryItem } from '../interfaces'; /** * A service for manipulating Shopify's InventoryItems API. */ export class InventoryItems extends BaseService { constructor(shopDomain: string, accessToken: string) { super(shopDomain, accessToken, "inventory_items"); } /** * Gets a inventory item with the given id. * @param id Id of the inventory item being retrieved. * @param options Options for filtering the result. */ public get(id: number, options?: Options.FieldOptions) { return this.createRequest("GET", `${id}.json`, "inventory_item", options); } /** * Gets a list of up to 250 of the shop's inventory items. * @param options Options for filtering the result. */ public list(options: Options.InventoryItemListOptions) { return this.createRequest("GET", ".json", "inventory_items", options); } /** * Updates an inventory item with the given id. * @param id The inventory items's id. * @param inventoryItem The updated inventory item. */ public update(id: number, inventoryItem: Partial) { return this.createRequest("PUT", `${id}.json`, "inventory_item", { inventory_item: inventoryItem }); } } export default InventoryItems;