export type CustomFieldInputModel = {field1?: (string | null) | undefined, field2?: (string | null) | undefined, field3?: (string | null) | undefined, field4?: (string | null) | undefined, field5?: (string | null) | undefined, field6?: (string | null) | undefined, field7?: (string | null) | undefined, field8?: (string | null) | undefined, field9?: (string | null) | undefined, field10?: (string | null) | undefined}; export type BookingFieldItem = {name?: (string | null) | undefined, value?: (string | null) | undefined}; export type AppointmentReserveModel = {email?: (string | null) | undefined, name?: (string | null) | undefined, phone?: (string | null) | undefined, phoneType?: (string | null) | undefined, phoneExt?: (string | null) | undefined, customerMessage?: (string | null) | undefined, notes?: (string | null) | undefined, customFields?: CustomFieldInputModel | undefined, appointmentBookingFields?: (Array | null) | undefined, customerBookingFields?: (Array | null) | undefined}; export type UpdateApiConsumerV1AppointmentsIdReserveArgs = {id: string, sendNotifications?: boolean | undefined, body: AppointmentReserveModel}; export type UpdateApiConsumerV1AppointmentsIdReserveOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reserve Appointment * * PUT /consumer/v1/appointments/{id}/reserve */ export const updateApiConsumerV1AppointmentsIdReserve = async (args: UpdateApiConsumerV1AppointmentsIdReserveArgs, options?: UpdateApiConsumerV1AppointmentsIdReserveOptions) => { const {baseUrl = "https://sandbox-api.onsched.com", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.sendNotifications != null) query.append("sendNotifications", String(args.sendNotifications)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/consumer/v1/appointments/${encodeURIComponent(String(args.id))}/reserve${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };