import { publicApi } from './http'

export async function fetchAccounts(params = {}) {
  const { data } = await publicApi.get('/accounts', { params })
  return data
}

export async function addAccount(payload) {
  const { data } = await publicApi.post('/accounts', payload)
  return data
}

export async function updateAccount(accountId, payload) {
  const { data } = await publicApi.put(`/accounts/${accountId}`, payload)
  return data
}

export async function deleteAccount(accountId) {
  const { data } = await publicApi.delete(`/accounts/${accountId}`)
  return data
}

export async function updateAccountRemark(accountId, payload) {
  const { data } = await publicApi.put(`/accounts/${accountId}/remark`, payload)
  return data
}

export async function startAccount(accountId, payload) {
  const { data } = await publicApi.post(`/accounts/${accountId}/start`, payload)
  return data
}

export async function stopAccount(accountId) {
  const { data } = await publicApi.post(`/accounts/${accountId}/stop`, {})
  return data
}

export async function batchStartAccounts(payload) {
  const { data } = await publicApi.post('/accounts/batch/start', payload)
  return data
}

export async function batchStopAccounts(payload) {
  const { data } = await publicApi.post('/accounts/batch/stop', payload)
  return data
}

export async function clearAccounts() {
  const { data } = await publicApi.post('/accounts/clear', {})
  return data
}

export async function takeScreenshot(accountId, payload = {}) {
  const { data } = await publicApi.post(`/accounts/${accountId}/screenshot`, payload)
  return data
}

