export type ZapierUnsubscribeRequest = {targetUrl?: (string | null) | undefined, event?: (string | null) | undefined}; export type CreateApiV4ZapierUnsubscribeArgs = {body: ZapierUnsubscribeRequest}; export type CreateApiV4ZapierUnsubscribeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Mark a Zapier Subscription as Deleted * * POST /v4/zapier/unsubscribe */ export const createApiV4ZapierUnsubscribe = async (args: CreateApiV4ZapierUnsubscribeArgs, options?: CreateApiV4ZapierUnsubscribeOptions) => { const {baseUrl = "https://submittable-api.submittable.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v4/zapier/unsubscribe${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };