import request from '@/utils/request'

export function getKdocsAuthUrl(state) {
  return request({
    url: '/jarvis/kdocs/authUrl',
    method: 'get',
    params: state ? { state } : {}
  })
}

export function getKdocsTokenStatus(userId) {
  return request({
    url: '/jarvis/kdocs/tokenStatus',
    method: 'get',
    params: { userId }
  })
}

export function refreshKdocsToken(data) {
  return request({
    url: '/jarvis/kdocs/refreshToken',
    method: 'post',
    data
  })
}

export function setKdocsToken(data) {
  return request({
    url: '/jarvis/kdocs/setToken',
    method: 'post',
    data
  })
}

export function getKdocsUserInfo(userId) {
  return request({
    url: '/jarvis/kdocs/userInfo',
    method: 'get',
    params: { userId }
  })
}

export function getKdocsFileList(params) {
  return request({
    url: '/jarvis/kdocs/files',
    method: 'get',
    params
  })
}

export function getKdocsFileInfo(userId, fileToken) {
  return request({
    url: '/jarvis/kdocs/fileInfo',
    method: 'get',
    params: { userId, fileToken }
  })
}

export function getKdocsSheetList(userId, fileToken) {
  return request({
    url: '/jarvis/kdocs/sheets',
    method: 'get',
    params: { userId, fileToken }
  })
}

export function createKdocsSheet(data) {
  return request({
    url: '/jarvis/kdocs/createSheet',
    method: 'post',
    data
  })
}

export function readKdocsCells(params) {
  return request({
    url: '/jarvis/kdocs/readCells',
    method: 'get',
    params
  })
}

export function updateKdocsCells(data) {
  return request({
    url: '/jarvis/kdocs/updateCells',
    method: 'post',
    data
  })
}

export function batchUpdateKdocsCells(data) {
  return request({
    url: '/jarvis/kdocs/batchUpdateCells',
    method: 'post',
    data
  })
}
