import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ScanApiRepository } from './scanAll.api.repository';
import { ErrorHandler } from '../../error-handler/index';


@Injectable()
export class ScanAllRepoService {

    constructor(
        private scanApiRepository: ScanApiRepository,
        private errorHandler: ErrorHandler) {
    }

    public manualScan(): Observable <any> {
        let param = {
            "schedule": {
                "type": "Manual"
            }
        };
        return this.scanApiRepository.postSchedule(param);
    }

    public getSchedule(): Observable <any> {
        return this.scanApiRepository.getSchedule();
    }

    public postSchedule(type, cron): Observable <any> {
        let param = {
            "schedule": {
                "type": type,
                "cron": cron,
            }
        };

        return this.scanApiRepository.postSchedule(param);
    }

    public putSchedule(type, cron): Observable <any> {
        let param = {
            "schedule": {
                "type": type,
                "cron": cron,
            }
        };

        return this.scanApiRepository.putSchedule(param);
    }
}
