export type GetApiHdUnsubscribeArgs = {d: string, t: string}; export type GetApiHdUnsubscribeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Ask to mute a request's update emails * * GET /hd/unsubscribe */ export const getApiHdUnsubscribe = async (args: GetApiHdUnsubscribeArgs, options?: GetApiHdUnsubscribeOptions) => { 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: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };