/**
 * 组件相关接口
 */


import {
  bluebookAiAgent,
} from '@/xiaolanbenlib/api/index'
import request from '@/xiaolanbenlib/module/axios.js'
import { TContactItem } from '@/types/contact'


// 置顶与取消置顶
export const setContactToTop = (data: {
  contactId: number|string,
  isTop: boolean
}) => {
  return request.put(`${bluebookAiAgent}api/v1/my/contact/top`, data)
}

// 搜索联系人列表--前端 需要根据已拉取的记录去重
export const getContactList = (data: {
  pageSize: number,
  startId: string,
  keyword?: string,
}) => {
  return request.get<{
    data?: TContactItem[]
    nextId?: string,
    totalCount?: number
  }>(`${bluebookAiAgent}api/v1/my/contacts`, {params: {
    ...data
  }})
}

// 删除联系人
export const delContact = (contactId: string|number) => {
  return request.delete(`${bluebookAiAgent}api/v1/my/contact/${contactId}`)
}