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 SentTextMessageData = {direction: CommunicationDirection, message: string, contactType: 'CarrierContact', contact: AgentContact, attachmentCount: number}; export type SentExternalTextMessageEvent = {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: 'SENT_EXTERNAL_TEXT_MESSAGE', data: SentTextMessageData}; export type CreateApiSENTEXTERNALTEXTMESSAGEArgs = {body: SentExternalTextMessageEvent}; export type CreateApiSENTEXTERNALTEXTMESSAGEOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Sent Text Message * * POST /SENT_EXTERNAL_TEXT_MESSAGE */ export const createApiSENTEXTERNALTEXTMESSAGE = async (args: CreateApiSENTEXTERNALTEXTMESSAGEArgs, options: CreateApiSENTEXTERNALTEXTMESSAGEOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/SENT_EXTERNAL_TEXT_MESSAGE${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 };