import type { AxiosResponse } from 'axios'
import type { Result } from '@cacp/ui'
import request from '@/utils/request'
import type { CacpCounter } from '@/types/counter'
const contextPath = '/counter'

export async function getList(appCode: string): Promise<Result<CacpCounter[]>> {
  const res: AxiosResponse<Result<CacpCounter[]>> = await request.get(`${contextPath}/get-list`, {
    params: {
      appCode
    }
  })
  return res.data
}

export async function del(appCode: string, counterPrefix: string): Promise<Result<number>> {
  const res: AxiosResponse<Result<number>> = await request.post(`${contextPath}/delete?appCode=${appCode}&counterPrefix=${counterPrefix}`)
  return res.data
}
