export type NewWebhookEndpointSubscription = {eventTypeId: string}; export type WebhookEndpointPatch = {description?: string | undefined, publicKey?: string | undefined, subscriptions?: Array | undefined, url?: string | undefined}; export type PatchApiWebhookEndpointsEndpointIdArgs = {endpointId: string, body: WebhookEndpointPatch}; export type PatchApiWebhookEndpointsEndpointIdOptions = {baseUrl?: string | undefined, ApiAccessKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update webhook endpoint * * PATCH /webhook/endpoints/{endpointId} */ export const patchApiWebhookEndpointsEndpointId = async (args: PatchApiWebhookEndpointsEndpointIdArgs, options?: PatchApiWebhookEndpointsEndpointIdOptions) => { const {baseUrl = "https://api.anchorage-staging.com/v2", fetch: fetchFn = fetch, ApiAccessKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiAccessKey !== undefined) headers.set("Api-Access-Key", ApiAccessKey) const url = `${baseUrl.replace(/\/+$/, '')}/webhook/endpoints/${encodeURIComponent(String(args.endpointId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };