import  { ProfileRepository } from '../../infrastructure/repositories/profile.repository'
import { ProfileSummaryResponse } from '../models/profiles/ProfileSummaryResponse.interface';
import { JobResponse } from '../../domain/models/profiles/JobResponse.interface'
import { Response } from '../../domain/models/Response.interface'
export class ProfileService {
private profileRepository: ProfileRepository;
    constructor() {
        this.profileRepository = new ProfileRepository();
    }

    async getProfileSummary(): Promise<ProfileSummaryResponse> {
        return await this.profileRepository.getProfileSummary();
    }

    async deleteProfile(idTaskSelected : String): Promise<Response>{
        return await this.profileRepository.deleteProfile(idTaskSelected);
    }

    showEditProfileById(idTaskSelected : String){
        location.href = 'profile.html?action=edit&id=' + idTaskSelected;
    }

    async submitJob(idTaskSelected : String): Promise<JobResponse>{
        const response = await this.profileRepository.submitJob(idTaskSelected);
        return response;
    }

    async addProfile(attributes : any) : Promise<Response>{
        return await this.profileRepository.post(process.env.VUE_APP_ROOT_API + '/tasks/profile', attributes);
    }

    async updateProfile(idTask :string, attributes : any) : Promise<Response>{
        return await this.profileRepository.put(process.env.VUE_APP_ROOT_API + '/tasks/profile/' + idTask, attributes);
    }

    async getProfile(idTask : String) : Promise<Response>{
        return await this.profileRepository.get(process.env.VUE_APP_ROOT_API + '/tasks/profile/' + idTask);
    }

    async getDataSchema(idJob: String){
        return await this.profileRepository.get(process.env.VUE_APP_ROOT_API + '/jobs/results/profile/schema/' + idJob);
    }

    async getNamesColumnsStatistics(typeConnection: string){
        return await this.profileRepository.get(process.env.VUE_APP_ROOT_API + '/configurations/profile/metrics/platform/' + typeConnection + "/names");
    }

    async getColumnsStatistics(idJob: string){
        return await this.profileRepository.get(process.env.VUE_APP_ROOT_API + '/jobs/results/profile/stats/' + idJob);
    }

    async getValueFrecuency(idJob: string, column: string){
        return await this.profileRepository.get(process.env.VUE_APP_ROOT_API + '/jobs/results/profile/frequency/' + idJob + '/' + column);
    }

    async getDataViewer(idJob: string, column: string, value: string){
        return await this.profileRepository.get(process.env.VUE_APP_ROOT_API + '/jobs/results/profile/viewer/' + idJob + '/' + column + "/" + value);
    }
}