export type CreateApiV1PatientsIdCustomDataArgs = {id: number, body: {custom_data: Array<{id?: number | undefined, datatype?: ('string' | 'number' | 'date' | 'time' | 'text' | 'selection' | 'phone' | 'email' | 'address') | undefined, value: unknown}>}}; export type CreateApiV1PatientsIdCustomDataOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upsert custom data * * POST /v1/patients/{id}/custom_data */ export const createApiV1PatientsIdCustomData = async (args: CreateApiV1PatientsIdCustomDataArgs, options?: CreateApiV1PatientsIdCustomDataOptions) => { const {baseUrl = "https://developer.yezza.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/patients/${encodeURIComponent(String(args.id))}/custom_data${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 };