UNPKG

inventora-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.

60 lines (52 loc) 1.81 kB
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<number>("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<Webhook[]>("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<Webhook>("GET", `${id}.json`, "webhook", options); } /** * Creates a new webhook. */ public create(webhook: Partial<Webhook>) { return this.createRequest<Webhook>("POST", ".json", "webhook", { webhook }); } /** * Updates the webhook with the given id. * @param webhook The updated webhook. */ public update(id: number, webhook: Partial<Webhook>) { return this.createRequest<Webhook>("PUT", `${id}.json`, "webhook", { webhook }); } /** * Deletes the webhook with the given id. */ public delete(id: number) { return this.createRequest<void>("DELETE", `${id}.json`); } } export default Webhooks;