import request from '@/utils/request';

function base(module) {
  return `/platform/accountPool/${module}`;
}

export function getAccountPoolList(module, params) {
  return request({
    url: `${base(module)}/list`,
    method: 'get',
    params,
  });
}

export function addAccountPool(module, data) {
  return request({
    url: `${base(module)}/add`,
    method: 'post',
    data,
  });
}

export function batchAddAccountPool(module, rows) {
  return request({
    url: `${base(module)}/batchAdd`,
    method: 'post',
    data: { rows },
  });
}

export function getAccountPoolDetail(module, id) {
  return request({
    url: `${base(module)}/detail/${id}`,
    method: 'get',
  });
}

export function extractAccountPool(module, data) {
  return request({
    url: `${base(module)}/extract`,
    method: 'post',
    data,
  });
}

export function updateAccountPoolRemark(module, data) {
  return request({
    url: `${base(module)}/updateRemark`,
    method: 'post',
    data,
  });
}

export function replenishAccountPool(module, data) {
  return request({
    url: `${base(module)}/replenish`,
    method: 'post',
    data,
  });
}

/** 使用厂商 Token 探测是否可用（服务端转发）。Cursor 传 { id, accessToken }（会话 JWT）以便回写 is_used；仅传 accessToken 也可探测但不更新库；Windsurf/Kiro 传 { id } */
export function probeAccountPoolToken(module, data) {
  return request({
    url: `${base(module)}/probeToken`,
    method: 'post',
    data,
  });
}
