export type AppointmentConfirmation = {start: string, end: string, timezone: string, confirmationId?: string | undefined}; export type AppointmentUpdateRouteStop = {sequence: number, appointmentConfirmation: AppointmentConfirmation, externalId?: string | undefined}; export type AppointmentUpdateData = {route: Array}; export type AppointmentUpdateEvent = {id: string, workflow: 'TRACK_AND_TRACE' | 'CARRIER_SUPPORT' | 'POD_COLLECTION' | 'LOAD_BUILDING' | 'CARRIER_SELECTION' | 'SCHEDULING' | 'CUSTOMER_SUPPORT' | 'null' | null, occurredAt: string, loadNumber: string | null, customerLoadInternalId: string | null, eventType: 'APPOINTMENT_UPDATE', data: AppointmentUpdateData}; export type CreateApiAPPOINTMENTUPDATEArgs = {body: AppointmentUpdateEvent}; export type CreateApiAPPOINTMENTUPDATEOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Appointment Update * * POST /APPOINTMENT_UPDATE */ export const createApiAPPOINTMENTUPDATE = async (args: CreateApiAPPOINTMENTUPDATEArgs, options: CreateApiAPPOINTMENTUPDATEOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/APPOINTMENT_UPDATE${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 };