export type CreateApiHdUnsubscribeArgs = {d?: string | undefined, t?: string | undefined}; export type CreateApiHdUnsubscribeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Mute a request's update emails * * POST /hd/unsubscribe */ export const createApiHdUnsubscribe = async (args: CreateApiHdUnsubscribeArgs, options?: CreateApiHdUnsubscribeOptions) => { const {baseUrl = "https://api.sparkvault.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.d != null) query.append("d", String(args.d)) if (args.t != null) query.append("t", String(args.t)) const url = `${baseUrl.replace(/\/+$/, '')}/hd/unsubscribe${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };