export type DeleteApiSubscriptionsExternalIdAlertsArgs = {subscription_status?: ('pending' | 'active' | 'terminated' | 'canceled' | 'incomplete') | undefined}; export type DeleteApiSubscriptionsExternalIdAlertsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete all subscription alerts * * DELETE /subscriptions/{external_id}/alerts */ export const deleteApiSubscriptionsExternalIdAlerts = async (args: DeleteApiSubscriptionsExternalIdAlertsArgs, options?: DeleteApiSubscriptionsExternalIdAlertsOptions) => { const {baseUrl = "https://api.getlago.com/api/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.subscription_status != null) query.append("subscription_status", String(args.subscription_status)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/subscriptions/${encodeURIComponent(String(args.external_id))}/alerts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };