UNPKG

lightrail-client

Version:
99 lines (98 loc) 3.39 kB
import { Webhook, WebhookSecret } from "./model"; import { CreateWebhookParams, CreateWebhookResponse, CreateWebhookSecretResponse, GetWebhookResponse, GetWebhookSecretResponse, ListWebhooksResponse, UpdateWebhookParams, UpdateWebhookResponse } from "./params"; /** * Example: * ```js * const signature = "abcdefg"; // webhook signature * const payload = "{}"; // webhook payload JSON string * const secret = "the secret stored in your system"; * const verified = Lightrail.webhooks.verifySignature(signature, payload, secret); * ``` */ export declare function verifySignature(signatureHeader: string, payload: string, webhookSecret?: string): boolean; /** * See: https://apidocs.lightrail.com/#operation/CreateWebhook * * Example: * ```js * const webhook = await Lightrail.webhooks.createWebhook({ * id: "abcdefg", * url: "https://www.example.com/webhook", * events: ["*"] * }); * ``` */ export declare function createWebhook(params: CreateWebhookParams): Promise<CreateWebhookResponse>; /** * See: https://apidocs.lightrail.com/#operation/GetWebhook * * Example: * ```js * const webhook = await Lightrail.webhooks.getWebhook("abcdefg"); * ``` */ export declare function getWebhook(webhook: string | Webhook): Promise<GetWebhookResponse>; /** * See: https://apidocs.lightrail.com/#operation/ListWebhooks * * Example: * ```js * const webhooks = await Lightrail.webhooks.listWebhooks(); * ``` */ export declare function listWebhooks(): Promise<ListWebhooksResponse>; /** * See: https://apidocs.lightrail.com/#operation/UpdateWebhook * * Example: * ```js * const updatedWebhook = await Lightrail.webhooks.updateWebhook("abcdefg", {url: "https://www.example.com/webhookUpdated"}); * ``` */ export declare function updateWebhook(webhook: string | Webhook, params: UpdateWebhookParams): Promise<UpdateWebhookResponse>; /** * See: https://apidocs.lightrail.com/#operation/DeleteWebhook * * Example: * ```js * await Lightrail.webhooks.deleteWebhook("abcdefg"); * ``` */ export declare function deleteWebhook(webhook: string | Webhook): Promise<void>; /** * See: https://apidocs.lightrail.com/#operation/CreateSecret * * Example: * ```js * const webhookSecret = await Lightrail.webhooks.createWebhookSecret("abcdefg"); * ``` */ export declare function createWebhookSecret(webhook: string | Webhook): Promise<CreateWebhookSecretResponse>; /** * See: https://apidocs.lightrail.com/#operation/GetSecret * * Example: * ```js * const webhookSecret = await Lightrail.webhooks.getWebhookSecret("abcdefg", "hijklmnop"); * ``` */ export declare function getWebhookSecret(webhook: string | Webhook, webhookSecret: string | WebhookSecret): Promise<GetWebhookSecretResponse>; /** * See: https://apidocs.lightrail.com/#operation/DeleteSecret * * Example: * ```js * await Lightrail.webhooks.deleteWebhookSecret("abcdefg", "hijklmnop"); * ``` */ export declare function deleteWebhookSecret(webhook: string | Webhook, webhookSecret: string | WebhookSecret): Promise<void>; /** * @internal * Get webhookId from the string (as the ID itself) or Webhook object. */ export declare function getWebhookId(webhook: string | Webhook): string; /** * @internal * Get webhookSecretId from the string (as the ID itself) or WebhookSecret object. */ export declare function getWebhookSecretId(webhookSecret: string | WebhookSecret): string;