export type PublicHandoutViewedRequest = {token: string}; export type CreateApiPublicQuestionnairesViewedArgs = {body: PublicHandoutViewedRequest}; export type CreateApiPublicQuestionnairesViewedOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * The public page's "viewed" beacon for a read-only handout (ITE-1712): the only thing that * marks one read. The page sends it once the handout has been on screen a moment or the reader * scrolls or taps, which mail scanners and link previewers never do. The token is in the body, * not the path, so it stays out of logs and falls under the form-submit limit. Idempotent: a * repeat is 204 and changes nothing. Anything the token can't mark (unknown, expired, taken * back, unpublished, not a read-only handout) is the same 404. * * POST /public/questionnaires/viewed */ export const createApiPublicQuestionnairesViewed = async (args: CreateApiPublicQuestionnairesViewedArgs, options?: CreateApiPublicQuestionnairesViewedOptions) => { 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(/\/+$/, '')}/public/questionnaires/viewed${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 };