Files
live-hub-py/web/frontend/src/api/login.ts
T

23 lines
1.0 KiB
TypeScript

import api from './client';
import type { BatchLoginResult, LoginTaskItem, MessageDeletedResponse, MessageResponse, TaskSummary } from './types';
interface CreateBatchParams {
account_ids: number[];
concurrency?: number;
max_login_retries?: number;
max_total_time?: number;
api_strategy?: string;
mode?: 'login' | 'check';
}
export const loginApi = {
createBatch: (params: CreateBatchParams) =>
api.post<BatchLoginResult, BatchLoginResult>('/login/batch', params),
listTasks: (batch_id?: string) =>
api.get<LoginTaskItem[], LoginTaskItem[]>('/login/tasks', { params: batch_id ? { batch_id } : {} }),
tasksSummary: () => api.get<TaskSummary, TaskSummary>('/login/tasks/summary'),
stop: (batch_id: string) => api.post<MessageResponse, MessageResponse>(`/login/stop/${batch_id}`),
deleteTask: (id: number) => api.delete<MessageResponse, MessageResponse>(`/login/tasks/${id}`),
deleteTasks: (ids: number[]) => api.delete<MessageDeletedResponse, MessageDeletedResponse>(`/login/tasks`, { params: { task_ids: ids.join(',') } }),
};