export type EventKindId = 0 | 1 | 2 | 4; export type WebhookSummaryWithPackages = {name: string, description?: string | undefined, url: string, secret?: string | undefined, content_type?: string | undefined, template?: string | undefined, active: boolean, event_kinds: Array, packages: Array<{package_id: string}>}; export type UpdateApiWebhooksUserWebhookIDArgs = {webhookID: string, body: WebhookSummaryWithPackages}; export type UpdateApiWebhooksUserWebhookIDOptions = {baseUrl: string, ApiKeyId?: string | undefined, ApiKeySecret?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update user's webhook * * PUT /webhooks/user/{webhookID} */ export const updateApiWebhooksUserWebhookID = async (args: UpdateApiWebhooksUserWebhookIDArgs, options: UpdateApiWebhooksUserWebhookIDOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyId, ApiKeySecret} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyId !== undefined) headers.set("X-API-KEY-ID", ApiKeyId) if (ApiKeySecret !== undefined) headers.set("X-API-KEY-SECRET", ApiKeySecret) const url = `${baseUrl.replace(/\/+$/, '')}/webhooks/user/${encodeURIComponent(String(args.webhookID))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };