export type RecipientType = 'courier' | 'customer' | 'pickup_business'; export type MessageType = 'sms' | 'email'; export type SendMessageInput = {order_id: string, recipient_type: RecipientType, message_type: MessageType, message: string}; export type CreateApiV1MessagesSendArgs = {body: SendMessageInput}; export type CreateApiV1MessagesSendOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send Message * * POST /v1/messages/send */ export const createApiV1MessagesSend = async (args: CreateApiV1MessagesSendArgs, options?: CreateApiV1MessagesSendOptions) => { const {baseUrl = "https://api.sandbox.usenash.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/messages/send${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 };