UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

160 lines • 5.83 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseWebhooks = /* @__PURE__ */ (() => { class BaseWebhooks extends APIResource { /** * Adds a new webhook to an App. * * @example * ```ts * const response = * await client.realtimeKit.webhooks.createWebhook( * '14a396e7-ca44-4937-bf1f-050a69118543', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * events: [ * 'meeting.started', * 'meeting.ended', * 'meeting.participantJoined', * 'meeting.participantLeft', * 'meeting.chatSynced', * 'recording.statusUpdate', * 'livestreaming.statusUpdate', * 'meeting.transcript', * 'meeting.summary', * ], * name: 'All events webhook', * url: 'https://webhook.site/b23a5bbd-c7b0-4ced-a9e2-78ae7889897e', * }, * ); * ``` */ createWebhook(appID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/realtime/kit/${appID}/webhooks`, { body, ...options, }); } /** * Removes a webhook for the given webhook ID. * * @example * ```ts * const response = * await client.realtimeKit.webhooks.deleteWebhook( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * app_id: '14a396e7-ca44-4937-bf1f-050a69118543', * }, * ); * ``` */ deleteWebhook(webhookID, params, options) { const { account_id, app_id } = params; return this._client.delete(path `/accounts/${account_id}/realtime/kit/${app_id}/webhooks/${webhookID}`, options); } /** * Edits the webhook details for the given webhook ID. * * @example * ```ts * const response = * await client.realtimeKit.webhooks.editWebhook( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * app_id: '14a396e7-ca44-4937-bf1f-050a69118543', * }, * ); * ``` */ editWebhook(webhookID, params, options) { const { account_id, app_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/realtime/kit/${app_id}/webhooks/${webhookID}`, { body, ...options, }); } /** * Returns webhook details for the given webhook ID. * * @example * ```ts * const response = * await client.realtimeKit.webhooks.getWebhookByID( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * app_id: '14a396e7-ca44-4937-bf1f-050a69118543', * }, * ); * ``` */ getWebhookByID(webhookID, params, options) { const { account_id, app_id } = params; return this._client.get(path `/accounts/${account_id}/realtime/kit/${app_id}/webhooks/${webhookID}`, options); } /** * Returns details of all webhooks for an App. * * @example * ```ts * const response = * await client.realtimeKit.webhooks.getWebhooks( * '14a396e7-ca44-4937-bf1f-050a69118543', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ getWebhooks(appID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/realtime/kit/${appID}/webhooks`, options); } /** * Replace all details for the given webhook ID. * * @example * ```ts * const response = * await client.realtimeKit.webhooks.replaceWebhook( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * app_id: '14a396e7-ca44-4937-bf1f-050a69118543', * events: [ * 'meeting.started', * 'meeting.ended', * 'meeting.participantJoined', * 'meeting.participantLeft', * 'meeting.chatSynced', * 'recording.statusUpdate', * 'livestreaming.statusUpdate', * 'meeting.transcript', * 'meeting.summary', * ], * name: 'All events webhook', * url: 'https://webhook.site/b23a5bbd-c7b0-4ced-a9e2-78ae7889897e', * }, * ); * ``` */ replaceWebhook(webhookID, params, options) { const { account_id, app_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/realtime/kit/${app_id}/webhooks/${webhookID}`, { body, ...options, }); } } BaseWebhooks._key = Object.freeze([ 'realtimeKit', 'webhooks', ]); return BaseWebhooks; })(); export class Webhooks extends BaseWebhooks { } //# sourceMappingURL=webhooks.mjs.map