export type CreateApiCgmPatientIdConvertArgs = {patient_id: number, date_since: string, date_until: string, body: BodyInit}; export type CreateApiCgmPatientIdConvertOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * [DEPRECATED] load CGM data * * POST /cgm/{patient_id}/convert */ export const createApiCgmPatientIdConvert = async (args: CreateApiCgmPatientIdConvertArgs, options: CreateApiCgmPatientIdConvertOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.date_since != null) query.append("date_since", String(args.date_since)) if (args.date_until != null) query.append("date_until", String(args.date_until)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/cgm/${encodeURIComponent(String(args.patient_id))}/convert${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 res.text() };