export type CommunicationDirection = 'INBOUND' | 'OUTBOUND'; export type AgentContact = {name: string | null, externalId: string | null, email: string | null, phone: string | null, phoneExtension: string | null, role?: string | undefined}; export type CallLoadDetail = {loadNumber?: (string | null) | undefined, loadStatus?: (string | null) | undefined, driverLocationCity?: (string | null) | undefined, driverLocationState?: (string | null) | undefined, driverLocationCountry?: (string | null) | undefined, driverLocationLatitude?: (number | null) | undefined, driverLocationLongitude?: (number | null) | undefined, driverEta?: (string | null) | undefined}; export type CallData = {callId: string, direction: CommunicationDirection, contact: AgentContact, summary?: string | undefined, callStatus?: string | undefined, callType?: string | undefined, outcome?: string | undefined, actionItems?: Array | undefined, analysisStatus?: string | undefined, timestamp?: string | undefined, loadDetails?: Array | undefined}; export type CompletedInboundCallEvent = {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: 'COMPLETED_INBOUND_CALL', data: CallData}; export type CreateApiCOMPLETEDINBOUNDCALLArgs = {body: CompletedInboundCallEvent}; export type CreateApiCOMPLETEDINBOUNDCALLOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Completed Inbound Call * * POST /COMPLETED_INBOUND_CALL */ export const createApiCOMPLETEDINBOUNDCALL = async (args: CreateApiCOMPLETEDINBOUNDCALLArgs, options: CreateApiCOMPLETEDINBOUNDCALLOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/COMPLETED_INBOUND_CALL${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 };