import * as Options from '../options'; import { BaseService } from '../infrastructure'; import { Webhook } from '../interfaces'; /** * A service for manipulating Shopify webhooks. */ export class Webhooks extends BaseService { constructor(shopDomain: string, accessToken: string) { super(shopDomain, accessToken, "webhooks"); } /** * Gets a count of all of the shop's webhooks. * @param options Options for filtering the results. */ public count(options?: Options.WebhookCountOptions) { 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. */ public list(options?: Options.WebhookListOptions) { return this.createRequest("GET", ".json", "webhooks", options); } /** * Retrieves the webhook with the given id. * @param options Options for filtering the results. */ public get(id: number, options?: Options.WebhookGetOptions) { return this.createRequest("GET", `${id}.json`, "webhook", options); } /** * Creates a new webhook. */ public create(webhook: Partial) { return this.createRequest("POST", ".json", "webhook", { webhook }); } /** * Updates the webhook with the given id. * @param webhook The updated webhook. */ public update(id: number, webhook: Partial) { return this.createRequest("PUT", `${id}.json`, "webhook", { webhook }); } /** * Deletes the webhook with the given id. */ public delete(id: number) { return this.createRequest("DELETE", `${id}.json`); } } export default Webhooks;