import { ErrorMessageMode } from '#/axios';
import { defHttp } from '@/utils/http/axios';
import { BaseDataResp, BaseIDReq, BaseResp } from '@/api/model/baseModel'
import { LoginQRStatus, RefreshLoginQRReq } from '@/api/wechat/model/wxhookModel';

enum Api {
  refreshLoginQRApi = '/wechat-api/wxhook/refreshLoginQR',
  logoutApi = '/wechat-api/wxhook/logout',
  getFriendsAndGroupsApi = '/wechat-api/wxhook/getFriendsAndGroups',
}

export const refreshLoginQRApi = (params: RefreshLoginQRReq, mode: ErrorMessageMode = 'notice') => {
  return defHttp.post<BaseDataResp<LoginQRStatus>>(
    { url: Api.refreshLoginQRApi, params: params },
    {
      errorMessageMode: mode,
      successMessageMode: mode,
    },
  )
}

export const logoutApi = (params: BaseIDReq, mode: ErrorMessageMode = 'notice') => {
  return defHttp.post<BaseResp>(
    { url: Api.logoutApi, params: params },
    {
      errorMessageMode: mode,
      successMessageMode: mode,
    },
  )
}

export const getFriendsAndGroupsApi = (params: BaseIDReq, mode: ErrorMessageMode = 'notice') => {
  return defHttp.post<BaseResp>(
    { url: Api.getFriendsAndGroupsApi, params: params },
    {
      errorMessageMode: mode,
      successMessageMode: mode,
    },
  )
}
