export type GetApiV1EmailReadArgs = {token?: string | undefined}; export type GetApiV1EmailReadOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/email/read * * Also accepts auth: API Key */ export const getApiV1EmailRead = async (args: GetApiV1EmailReadArgs, options: GetApiV1EmailReadOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.token != null) query.append("token", String(args.token)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/email/read${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 undefined };