2023-01-25 11:27:47 +01:00
|
|
|
import type { ChatReply, SendMessageInput } from 'models'
|
2023-01-16 12:13:21 +01:00
|
|
|
import { getViewerUrl, isEmpty, sendRequest } from 'utils'
|
2022-12-22 17:02:34 +01:00
|
|
|
|
|
|
|
export async function sendMessageQuery({
|
|
|
|
apiHost,
|
|
|
|
...body
|
|
|
|
}: SendMessageInput & { apiHost?: string }) {
|
|
|
|
const response = await sendRequest<ChatReply>({
|
|
|
|
method: 'POST',
|
2023-01-16 12:13:21 +01:00
|
|
|
url: `${isEmpty(apiHost) ? getViewerUrl() : apiHost}/api/v1/sendMessage`,
|
2022-12-22 17:02:34 +01:00
|
|
|
body,
|
|
|
|
})
|
|
|
|
|
|
|
|
return response.data
|
|
|
|
}
|