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.

50 lines (49 loc) 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PriceRules = void 0; const infrastructure_1 = require("../infrastructure"); /** * A service for manipulating Shopify Price Rules. */ class PriceRules extends infrastructure_1.BaseService { constructor(shopDomain, accessToken) { super(shopDomain, accessToken, "price_rules"); } /** * Gets a list of up to 250 of the shop's Price Rules. * @param options Options for filtering the results. */ list(options) { return this.createRequest("GET", ".json", "price_rules", options); } /** * The API is currently restricted to what the Shopify Discounts admin section offers. Note that for * a price rule to be accessible via the admin section of Shopify, you will need to create a * discount code as well. */ create(priceRule) { return this.createRequest("POST", ".json", "price_rule", { price_rule: priceRule }); } /** * Retrieves the Price Rule with the given id. * @param options Options for filtering the results. */ get(id) { return this.createRequest("GET", `${id}.json`, "price_rule"); } /** * Updates the Price Rule with the given id. * @param tag The updated Price Rule. */ update(id, PriceRule) { return this.createRequest("PUT", `${id}.json`, "price_rule", { price_rule: PriceRule }); } /** * Deletes the Price Rule with the given id. */ delete(id) { return this.createRequest("DELETE", `${id}.json`); } } exports.PriceRules = PriceRules; exports.default = PriceRules;