export type CreateApiMailSendArgs = {body: BodyInit}; export type CreateApiMailSendOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send email with metadata tracking (optional attachments) * * POST /mail/send */ export const createApiMailSend = async (args: CreateApiMailSendArgs, options?: CreateApiMailSendOptions) => { const {baseUrl = "https://api.findmydocument.net", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/mail/send${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };