import { BaseService } from '../BaseService'
import type {
  CancelExportTaskApiResponse,
  CreateExportTaskApiResponse,
  CreateExportTaskRequest,
  ExportTaskDetail,
  ExportTaskDetailApiResponse,
  ExportTaskListApiResponse,
  ExportTaskQueryParams
} from '@/types/api'

export class ExportTaskService extends BaseService {
  static getExportTasks(params?: ExportTaskQueryParams): Promise<ExportTaskListApiResponse> {
    return this.get<ExportTaskListApiResponse>('/api/admin/export-tasks', params)
  }

  static createExportTask(data: CreateExportTaskRequest): Promise<CreateExportTaskApiResponse> {
    return this.post<CreateExportTaskApiResponse>('/api/admin/export-tasks', data)
  }

  static getExportTaskDetail(id: number): Promise<ExportTaskDetailApiResponse> {
    return this.getOne<ExportTaskDetail>(`/api/admin/export-tasks/${id}`)
  }

  static cancelExportTask(id: number): Promise<CancelExportTaskApiResponse> {
    return this.post<CancelExportTaskApiResponse>(`/api/admin/export-tasks/${id}/cancel`, {})
  }
}
