export type CreateApiV1AppointmentsArgs = {body: {date: string, time: string, provider: number, service: number, patient?: number | undefined, lead?: ({name?: string | undefined, phone?: string | undefined, ic?: string | undefined, email?: string | undefined, status?: string | undefined, remarks?: string | undefined}) | undefined, preliminary_questions?: (Array<{question_id?: number | undefined, answer?: string | undefined}>) | undefined, ignore_rules?: Array | undefined}}; export type CreateApiV1AppointmentsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an appointment (book) * * POST /v1/appointments */ export const createApiV1Appointments = async (args: CreateApiV1AppointmentsArgs, options?: CreateApiV1AppointmentsOptions) => { 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/appointments${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 };