import  { TaskRepository } from '../../infrastructure/repositories/task.repository'
import { Response } from '../../domain/models/Response.interface'
import { TaskResponse } from '../models/tasks/TaskResponse.interface';
import { TaskSummaryResponse } from '../models/tasks/TaskSummaryResponse.interface';
import { TaskScheduleCountResponse } from '../models/tasks/TaskScheduleCountResponse.interface';
import { ScheduleType } from '../../domain/models/tasks/enums/ScheduleType.enum';

export class TaskService {
private taskRepository: TaskRepository;
    constructor() {
        this.taskRepository = new TaskRepository();
    }

    async addTask(attributes : any, task_type: string) : Promise<TaskResponse>{
        return await this.taskRepository.addTask(attributes, task_type);
    }

    async getTask(task_id: string, task_type: string){
        const response = await this.taskRepository.getTask(task_id, task_type);
        return response;
    }

    async getSummary(task_type: string): Promise<TaskSummaryResponse>{
        return await this.taskRepository.getSummary(task_type);
    }

    async deleteTask(task_id: string, task_type: string): Promise<Response>{
        return await this.taskRepository.deleteTask(task_id, task_type);
    }

    async updateTask(idTask :string, task_type: string, attributes : any) : Promise<Response>{
        return await this.taskRepository.updateTask(idTask, task_type, attributes);
    }

    async validateNewExtractTask(attributes : any){
        return await this.taskRepository.validateNewExtractTask(attributes);
    }

    async addSchedule(scheduleType: ScheduleType, attributes : any){
        return await this.taskRepository.addSchedule(scheduleType, attributes);
    }

    async getScheduleByTask(idTask :string): Promise<any>{
        return await this.taskRepository.getScheduleByTask(idTask);
    }

    async updateSchedule(scheduleId: String, scheduleType: ScheduleType, attributes : any): Promise<Response>{
        return await this.taskRepository.updateSchedule(scheduleId, scheduleType, attributes);
    }

    async getCountScheduleTask() : Promise<TaskScheduleCountResponse>{
        return await this.taskRepository.getCountScheduleTask();
    }

    async getScheduleTaskList() : Promise<TaskSummaryResponse>{
        return await this.taskRepository.getScheduleTaskList();
    }
}