31 lines
1.4 KiB
TypeScript
31 lines
1.4 KiB
TypeScript
import api from './client';
|
|
import type {
|
|
HuyaAccountItem,
|
|
HuyaConfig,
|
|
HuyaCookieImportResult,
|
|
HuyaGoodsItem,
|
|
HuyaTaskBatchRequest,
|
|
HuyaTaskBatchResult,
|
|
HuyaTaskItem,
|
|
MessageDeletedResponse,
|
|
MessageResponse,
|
|
} from './types';
|
|
|
|
export const huyaApi = {
|
|
taskTypes: () => api.get<Record<string, string>, Record<string, string>>('/huya/task-types'),
|
|
listAccounts: (params?: { tag?: string }) =>
|
|
api.get<HuyaAccountItem[], HuyaAccountItem[]>('/huya/accounts', { params }),
|
|
importCookies: (text: string, tag: string = '') =>
|
|
api.post<HuyaCookieImportResult, HuyaCookieImportResult>('/huya/accounts/import-cookies', { text, tag }),
|
|
deleteAccount: (id: number) => api.delete<MessageResponse, MessageResponse>(`/huya/accounts/${id}`),
|
|
deleteAccounts: (accountIds: number[]) =>
|
|
api.delete<MessageDeletedResponse, MessageDeletedResponse>('/huya/accounts/batch', { params: { account_ids: accountIds.join(',') } }),
|
|
getConfig: () => api.get<HuyaConfig, HuyaConfig>('/huya/config'),
|
|
updateConfig: (data: Partial<HuyaConfig>) => api.put<HuyaConfig, HuyaConfig>('/huya/config', data),
|
|
listGoods: () => api.get<HuyaGoodsItem[], HuyaGoodsItem[]>('/huya/goods'),
|
|
createTasks: (data: HuyaTaskBatchRequest) =>
|
|
api.post<HuyaTaskBatchResult, HuyaTaskBatchResult>('/huya/tasks/batch', data),
|
|
listTasks: (batchId?: string) =>
|
|
api.get<HuyaTaskItem[], HuyaTaskItem[]>('/huya/tasks', { params: batchId ? { batch_id: batchId } : {} }),
|
|
};
|