import {Injectable} from '@angular/core';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { ConnectorService } from 'src/app/hmg-common/services/connector/connector.service';
import { Observable } from 'rxjs';
import {AbsenceTransaction} from '../models/absence.transaction'


@Injectable()
export class SubmitAbsenceService {
    public static submitAbsence='Services/ERP.svc/REST/SUBMIT_ABSENCE_TRANSACTION';
    public static getAbsDffStructure='Services/ERP.svc/REST/GET_ABSENCE_DFF_STRUCTURE';
    public static getAbsenceTypes='Services/ERP.svc/REST/GET_ABSENCE_ATTENDANCE_TYPES';
    public static getCalc='Services/ERP.svc/REST/CALCULATE_ABSENCE_DURATION';
    public static validateAbsence='Services/ERP.svc/REST/VALIDATE_ABSENCE_TRANSACTION';
    public static getSetValue='Services/ERP.svc/REST/GET_VALUE_SET_VALUES';
    public static getDefaultValue='Services/ERP.svc/REST/GET_DEFAULT_VALUE';
    public static resubmitAbsence='Services/ERP.svc/REST/RESUBMIT_ABSENCE_TRANSACTION'
    constructor(
      public api: ConnectorService,
      public authService: AuthenticationService,
  
    ) { }
  
    public submitAbsence(absence: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = absence;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.submitAbsence, request, onError, errorLabel);
    }
    public getAbsenceDffStructure(absence: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = absence;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.getAbsDffStructure, request, onError, errorLabel);
    }
    public getAbsenceType(absence: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = absence;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.getAbsenceTypes, request, onError, errorLabel);
    }
    public getCalc(absence: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = absence;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.getCalc, request, onError, errorLabel);
    }

    public validateAbsenceTransaction (validateAbsReq: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = validateAbsReq;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.validateAbsence, request, onError, errorLabel);
    }
    public getSetValue(SetValueReq: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = SetValueReq;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.getSetValue, request, onError, errorLabel);
    }
    public getDefaultValue(DefaultValueReq: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = DefaultValueReq;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.getDefaultValue, request, onError, errorLabel);
    }

    public resubmitAbsence(absence: any, onError?: any, errorLabel?: string): Observable<any> {
      const request = absence;
      this.authService.authenticateRequest(request);
      return this.api.post(SubmitAbsenceService.resubmitAbsence, request, onError, errorLabel);
    }
}