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.43 kB
JavaScript
import { BaseService } from '../infrastructure';
/**
* A service for manipulating Shopify Gift Cards
*/
export class GiftCards extends BaseService {
constructor(shopDomain, accessToken) {
super(shopDomain, accessToken, "gift_cards");
}
/**
* Creates a new Gift Card.
*/
create(giftCard) {
return this.createRequest("POST", ".json", "gift_card", { gift_card: giftCard });
}
/**
* Deletes the Gift Card with the given id.
*/
count() {
return this.createRequest("GET", `count.json`, "count");
}
/**
* Gets a paged list of up to 250 of the shop's Gift Cards
* @param options Options for filtering the results.
*/
list(options) {
return this.createRequest("GET", ".json", "gift_cards", options);
}
/**
* Retrieves the Gift Card with the given id.
* @param options Options for filtering the results.
*/
get(id) {
return this.createRequest("GET", `${id}.json`, "gift_card");
}
/**
* Disable a Gift Card.
*/
disable(id) {
return this.createRequest("POST", `${id}/disable.json`, "gift_card");
}
/**
* Search for Giftcards matching the specified criteria
* @param options Options for filtering the results.
*/
search(options) {
return this.createRequest("GET", "search.json", "gift_cards", options);
}
}
export default GiftCards;