export type PresentEstimateRequest = {notes?: (string | null) | undefined}; export type CreateApiEstimatesIdPresentArgs = {id: string, body: PresentEstimateRequest | null}; export type CreateApiEstimatesIdPresentOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Record that the plan was presented to the client (overlay opened). Logs a * PlanPresented event and bumps status to Presented. Idempotent if status * is already Presented — always logs the event. * * POST /Estimates/{id}/present */ export const createApiEstimatesIdPresent = async (args: CreateApiEstimatesIdPresentArgs, options?: CreateApiEstimatesIdPresentOptions) => { const {baseUrl = "https://api.clinicos.vet/backend/business", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/Estimates/${encodeURIComponent(String(args.id))}/present${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 };