// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class WebhookSubscriptions extends APIResource { /** * Create a new webhook subscription */ create( body: WebhookSubscriptionCreateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post('/webhook-subscriptions', { body, ...options }); } /** * Get all webhook subscriptions for the authenticated user */ list(options?: RequestOptions): APIPromise { return this._client.get('/webhook-subscriptions', options); } /** * Delete a webhook subscription */ delete( webhookSubscriptionID: string, options?: RequestOptions, ): APIPromise { return this._client.delete(path`/webhook-subscriptions/${webhookSubscriptionID}`, options); } /** * Test a webhook subscription by sending a test event */ test( webhookSubscriptionID: string, body: WebhookSubscriptionTestParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post(path`/webhook-subscriptions/${webhookSubscriptionID}/test`, { body, ...options, }); } } export interface WebhookSubscriptionCreateResponse { data?: WebhookSubscriptionCreateResponse.Data; message?: string; status?: string; } export namespace WebhookSubscriptionCreateResponse { export interface Data { id?: string; created_at?: string; event_types?: Array; is_active?: boolean; secret_key?: string; updated_at?: string; user_id?: string; webhook_url?: string; } } export interface WebhookSubscriptionListResponse { data?: Array; message?: string; status?: string; } export namespace WebhookSubscriptionListResponse { export interface Data { id?: string; created_at?: string; event_types?: Array; is_active?: boolean; updated_at?: string; webhook_url?: string; } } export interface WebhookSubscriptionDeleteResponse { data?: Array; message?: string; request_id?: string; status?: string; } export interface WebhookSubscriptionTestResponse { data?: WebhookSubscriptionTestResponse.Data; message?: string; status?: string; } export namespace WebhookSubscriptionTestResponse { export interface Data { event_sent?: boolean; response_body?: string; response_status?: number; } } export interface WebhookSubscriptionCreateParams { /** * Array of event types to subscribe to */ event_types?: Array; /** * URL where webhook events will be sent */ webhook_url?: string; } export interface WebhookSubscriptionTestParams { /** * Type of event to test */ event_type?: string; } export declare namespace WebhookSubscriptions { export { type WebhookSubscriptionCreateResponse as WebhookSubscriptionCreateResponse, type WebhookSubscriptionListResponse as WebhookSubscriptionListResponse, type WebhookSubscriptionDeleteResponse as WebhookSubscriptionDeleteResponse, type WebhookSubscriptionTestResponse as WebhookSubscriptionTestResponse, type WebhookSubscriptionCreateParams as WebhookSubscriptionCreateParams, type WebhookSubscriptionTestParams as WebhookSubscriptionTestParams, }; }