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.

53 lines (52 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Discounts = void 0; const infrastructure_1 = require("../infrastructure"); /** * A service for manipulating Shopify discounts. */ class Discounts extends infrastructure_1.BaseService { constructor(shopDomain, accessToken) { super(shopDomain, accessToken, "discounts"); } /** * Creates a new discount. */ create(discount) { return this.createRequest("POST", ".json", "discount", { discount: discount }); } /** * Gets a list of up to 250 of the shop's discounts. * @param options Options for filtering the results. */ list(options) { return this.createRequest("GET", ".json", "discounts", options); } /** * Retrieves the discount with the given id. * @param options Options for filtering the results. */ get(id) { return this.createRequest("GET", `${id}.json`, "discount"); } /** * Enables a discount. */ enable(id) { return this.createRequest("POST", `${id}/enable.json`, "discount"); } /** * Disable a discount. */ disable(id) { return this.createRequest("POST", `${id}/disable.json`, "discount"); } /** * Deletes the discount with the given id. */ delete(id) { return this.createRequest("DELETE", `${id}.json`); } } exports.Discounts = Discounts; exports.default = Discounts;