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.
49 lines (48 loc) • 1.32 kB
JavaScript
import { BaseService } from '../infrastructure';
/**
* A service for manipulating Shopify discounts.
*/
export class Discounts extends 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`);
}
}
export default Discounts;