| 1 | import { buildQueryString, http } from './http' |
| 2 | import type { V2Page } from './http' |
| 3 | import type { ClientInfoData, ClientListV2Params } from '../types/client' |
| 4 | |
| 5 | export const getClients = () => { |
| 6 | return http.get<ClientInfoData[]>('../api/clients') |
| 7 | } |
| 8 | |
| 9 | export const getClientsV2 = (params: ClientListV2Params = {}) => { |
| 10 | return http.getV2<V2Page<ClientInfoData>>( |
| 11 | `../api/v2/clients${buildQueryString({ |
| 12 | page: params.page, |
| 13 | pageSize: params.pageSize, |
| 14 | status: |
| 15 | params.status && params.status !== 'all' ? params.status : undefined, |
| 16 | q: params.q || undefined, |
| 17 | user: params.user, |
| 18 | clientID: params.clientID || undefined, |
| 19 | runID: params.runID || undefined, |
| 20 | })}`, |
| 21 | ) |
| 22 | } |
| 23 | |
| 24 | export const getClient = (key: string) => { |
| 25 | return http.get<ClientInfoData>(`../api/clients/${key}`) |
| 26 | } |
| 27 | |
| 28 | export const getClientV2 = (key: string) => { |
| 29 | return http.getV2<ClientInfoData>(`../api/v2/clients/${encodeURIComponent(key)}`) |
| 30 | } |