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.
51 lines (50 loc) • 1.47 kB
JavaScript
import { BaseService } from '../infrastructure';
/**
* A service for manipulating Shopify webhooks.
*/
export class Webhooks extends BaseService {
constructor(shopDomain, accessToken) {
super(shopDomain, accessToken, "webhooks");
}
/**
* Gets a count of all of the shop's webhooks.
* @param options Options for filtering the results.
*/
count(options) {
return this.createRequest("GET", "count.json", "count", options);
}
/**
* Gets a list of up to 250 of the shop's webhooks.
* @param options Options for filtering the results.
*/
list(options) {
return this.createRequest("GET", ".json", "webhooks", options);
}
/**
* Retrieves the webhook with the given id.
* @param options Options for filtering the results.
*/
get(id, options) {
return this.createRequest("GET", `${id}.json`, "webhook", options);
}
/**
* Creates a new webhook.
*/
create(webhook) {
return this.createRequest("POST", ".json", "webhook", { webhook });
}
/**
* Updates the webhook with the given id.
* @param webhook The updated webhook.
*/
update(id, webhook) {
return this.createRequest("PUT", `${id}.json`, "webhook", { webhook });
}
/**
* Deletes the webhook with the given id.
*/
delete(id) {
return this.createRequest("DELETE", `${id}.json`);
}
}
export default Webhooks;