export type EventKindId = 0 | 1 | 2 | 4; export type DeleteApiSubscriptionsArgs = {packageID: string, event_kind: EventKindId}; export type DeleteApiSubscriptionsOptions = {baseUrl: string, ApiKeyId?: string | undefined, ApiKeySecret?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete subscription * * DELETE /subscriptions */ export const deleteApiSubscriptions = async (args: DeleteApiSubscriptionsArgs, options: DeleteApiSubscriptionsOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyId, ApiKeySecret} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.packageID != null) query.append("packageID", String(args.packageID)) if (args.event_kind != null) query.append("event_kind", String(args.event_kind)) if (ApiKeyId !== undefined) headers.set("X-API-KEY-ID", ApiKeyId) if (ApiKeySecret !== undefined) headers.set("X-API-KEY-SECRET", ApiKeySecret) const url = `${baseUrl.replace(/\/+$/, '')}/subscriptions${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 };