/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as operations from "../models/operations/index.js"; import { APIPromise } from "../types/async.js"; import { unwrapAsync } from "../types/fp.js"; import { PageIterator, unwrapResultIterator } from "../types/operations.js"; let webhookWebhooksList$module: | Promise | undefined; const webhookWebhooksList = (( ...args: Parameters< typeof import("../funcs/webhookWebhooksList.js").webhookWebhooksList > ) => new APIPromise( (webhookWebhooksList$module ??= import("../funcs/webhookWebhooksList.js") .catch((error: unknown) => { webhookWebhooksList$module = undefined; throw error; })).then((module) => module.webhookWebhooksList(...args).$inspect()), )) as typeof import("../funcs/webhookWebhooksList.js").webhookWebhooksList; let webhookWebhooksCreate$module: | Promise | undefined; const webhookWebhooksCreate = (( ...args: Parameters< typeof import("../funcs/webhookWebhooksCreate.js").webhookWebhooksCreate > ) => new APIPromise( (webhookWebhooksCreate$module ??= import( "../funcs/webhookWebhooksCreate.js" ).catch((error: unknown) => { webhookWebhooksCreate$module = undefined; throw error; })).then((module) => module.webhookWebhooksCreate(...args).$inspect()), )) as typeof import("../funcs/webhookWebhooksCreate.js").webhookWebhooksCreate; let webhookWebhooksGet$module: | Promise | undefined; const webhookWebhooksGet = (( ...args: Parameters< typeof import("../funcs/webhookWebhooksGet.js").webhookWebhooksGet > ) => new APIPromise( (webhookWebhooksGet$module ??= import("../funcs/webhookWebhooksGet.js") .catch((error: unknown) => { webhookWebhooksGet$module = undefined; throw error; })).then((module) => module.webhookWebhooksGet(...args).$inspect()), )) as typeof import("../funcs/webhookWebhooksGet.js").webhookWebhooksGet; let webhookWebhooksUpdate$module: | Promise | undefined; const webhookWebhooksUpdate = (( ...args: Parameters< typeof import("../funcs/webhookWebhooksUpdate.js").webhookWebhooksUpdate > ) => new APIPromise( (webhookWebhooksUpdate$module ??= import( "../funcs/webhookWebhooksUpdate.js" ).catch((error: unknown) => { webhookWebhooksUpdate$module = undefined; throw error; })).then((module) => module.webhookWebhooksUpdate(...args).$inspect()), )) as typeof import("../funcs/webhookWebhooksUpdate.js").webhookWebhooksUpdate; let webhookWebhooksDelete$module: | Promise | undefined; const webhookWebhooksDelete = (( ...args: Parameters< typeof import("../funcs/webhookWebhooksDelete.js").webhookWebhooksDelete > ) => new APIPromise( (webhookWebhooksDelete$module ??= import( "../funcs/webhookWebhooksDelete.js" ).catch((error: unknown) => { webhookWebhooksDelete$module = undefined; throw error; })).then((module) => module.webhookWebhooksDelete(...args).$inspect()), )) as typeof import("../funcs/webhookWebhooksDelete.js").webhookWebhooksDelete; export class Webhooks extends ClientSDK { /** * List webhook subscriptions * * @remarks * List all webhook subscriptions */ async list( request: operations.WebhookWebhooksAllRequest, options?: RequestOptions, ): Promise< PageIterator > { return unwrapResultIterator(webhookWebhooksList( this, request, options, )); } /** * Create webhook subscription * * @remarks * Create a webhook subscription to receive events. * * **Delivery URL Validation**: The provided `delivery_url` will be validated synchronously by sending an HTTP POST request with an HMAC signature. If validation fails (network error, timeout, non-2xx response), the webhook will still be created but with `status: "disabled"` and `disabled_reason: "delivery_url_validation_failed"`. * * **Delivery Timeout**: Each delivery attempt has a hard 60-second timeout. Endpoints that do not respond within 60 seconds are recorded as failed deliveries (`success: false`, `status_code: 0` on the event log) and follow the standard retry policy. Endpoints should acknowledge requests quickly (HTTP 2xx) and defer work asynchronously. * * **Important**: Always check the `status` and `disabled_reason` fields in the response to ensure the webhook is active. */ async create( request: operations.WebhookWebhooksAddRequest, options?: RequestOptions, ): Promise { return unwrapAsync(webhookWebhooksCreate( this, request, options, )); } /** * Get webhook subscription * * @remarks * Get the webhook subscription details */ async get( request: operations.WebhookWebhooksOneRequest, options?: RequestOptions, ): Promise { return unwrapAsync(webhookWebhooksGet( this, request, options, )); } /** * Update webhook subscription * * @remarks * Update a webhook subscription. * * **Delivery URL Validation**: When updating the `delivery_url`, it will be validated synchronously by sending an HTTP POST request with an HMAC signature. If validation fails (network error, timeout, non-2xx response), the webhook will still be updated but with `status: "disabled"` and `disabled_reason: "delivery_url_validation_failed"`. Validation only occurs when the URL is changed. * * **Delivery Timeout**: Each delivery attempt has a hard 60-second timeout. Endpoints that do not respond within 60 seconds are recorded as failed deliveries (`success: false`, `status_code: 0` on the event log) and follow the standard retry policy. Endpoints should acknowledge requests quickly (HTTP 2xx) and defer work asynchronously. * * **Important**: Always check the `status` and `disabled_reason` fields in the response to ensure the webhook is active. */ async update( request: operations.WebhookWebhooksUpdateRequest, options?: RequestOptions, ): Promise { return unwrapAsync(webhookWebhooksUpdate( this, request, options, )); } /** * Delete webhook subscription * * @remarks * Delete a webhook subscription */ async delete( request: operations.WebhookWebhooksDeleteRequest, options?: RequestOptions, ): Promise { return unwrapAsync(webhookWebhooksDelete( this, request, options, )); } }