export type PutApiWebhookEndpointsId = {name: string, url: string, event_form?: ('all_events' | 'selected_events') | undefined, event_ids?: Array | undefined, request_format?: ('x_www_form_urlencoded' | 'json') | undefined}; export type UpdateApiApiWebhookEndpointsIdArgs = {id: number, body: PutApiWebhookEndpointsId}; export type UpdateApiApiWebhookEndpointsIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update webhook endpoint * * PUT /api/webhook_endpoints/{id} */ export const updateApiApiWebhookEndpointsId = async (args: UpdateApiApiWebhookEndpointsIdArgs, options: UpdateApiApiWebhookEndpointsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/webhook_endpoints/${encodeURIComponent(String(args.id))}${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 };