import { useMyRequest } from '~/composables/useFetchRequest'

enum Api {
  ContactList = '/client/im/session/list',
  BrandConversation = '/client/im/session/get',
  MessagesHistory = '/client/im/message/list/history',
  UnReadMessageNum = '/client/im/message/clearUnreadQuantity',
  NewMessageList = '/client/im/message/list/new',
  SendOutMessage = '/client/im/message/send',
  CreateNewChat = '/client/im/session/create',
  DeleteContact = '/client/im/session/remove',
}

/**
 * 获取会话列表
 * @param params
 * @returns
 */
export async function getContactListApi(params?: any) {
  return await useMyRequest().get(Api.ContactList, params)
}
/**
 * 获取当前会话聊天记录列表
 * @param params
 * @returns
 */
export async function getContactMessagesApi(params?: any) {
  return await useMyRequest().get(Api.MessagesHistory, params)
}
/**
 * 清除当前会话的消息数量
 * @param params
 * @returns
 */
export async function clearUnReadMessageNumApi(params?: any) {
  return await useMyRequest().post(Api.UnReadMessageNum, params)
}
/**
 * 删除（隐藏）会话
 * @param params
 * @returns
 */
export async function deleteContactApi(params?: any) {
  return await useMyRequest().post(Api.DeleteContact, params)
}
/**
 * 获取当前会话的消息（交流消息）  （5s钟轮询一次）
 * @param params
 * @returns
 */
export async function getNewMessageListApi(params?: any) {
  return await useMyRequest().get(Api.NewMessageList, params)
}
/**
 * 发送当前输入的消息内容 （文本content和图片imageUrl分开两个参数）
 * @param params
 * @returns
 */
export async function sendMessageApi(params?: any) {
  return await useMyRequest().post(Api.SendOutMessage, params)
}
// ------- 品牌 新打开沟通 ---------

/**
 * 创建聊天会话
 * @param params
 * @returns
 */
export async function createNewChatApi(params?: any) {
  return await useMyRequest().post(Api.CreateNewChat, params)
}

/**
 * 获取当前品牌会话信息
 * @param params
 * @returns
 */
export async function getBrandConversationApi(params?: any) {
  return await useMyRequest().get(Api.BrandConversation, params)
}
