import { ReplacementServiceRequest } from './../model/replacement-Service.request';
import { notificationTypeRequest } from './../model/notification.Request';
import { Response } from 'src/app/hmg-common/services/models/response';
import { VacationRuleRequest } from './../model/VacationRuleRequest';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ConnectorService } from 'src/app/hmg-common/services/connector/connector.service';
import { VacationTypeRequest } from '../model/VacationTypeRequest';
import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request';
import { DeleteVacationRuleRequest } from '../model/deleteVacationRule.Request';

@Injectable({
  providedIn: 'root'
})
export class VacationRuleServiceService {

  /*  Vacation Rule Methods  */
  public static getVacationRule = 'Services/ERP.svc/REST/GET_VACATION_RULES';
  public static changePassword = 'Services/ERP.svc/REST/ChangePassword_FromActiveSession';
  public static userChecking = 'Services/ERP.svc/REST/Get_BasicUserInformation';
  public static getVacationType = 'Services/ERP.svc/REST/GET_VR_ITEM_TYPES';
  public static getNotificationType = 'Services/ERP.svc/REST/GET_ITEM_TYPE_NOTIFICATIONS';
  public static createVacationRule = 'Services/ERP.svc/REST/CREATE_VACATION_RULE';
  public static deleteVacationRule = 'Services/ERP.svc/REST/DELETE_VACATION_RULE';
  public static updateVacationRule = 'Services/ERP.svc/REST/UPDATE_VACATION_RULE';
  public static respondAttributes = 'Services/ERP.svc/REST/GET_RESPOND_ATTRIBUTES';
  public static notificationReassign = 'Services/ERP.svc/REST/GET_NOTIFICATION_REASSIGN_MODE';
  public static getRespondAttributeValues = 'Services/ERP.svc/REST/GET_RESPOND_ATTRIBUTE_VALUE';
  public static getReplacmentEmployeeList = 'Services/ERP.svc/REST/GET_REPLACEMENT_LIST';
  public static getLookup='Services/ERP.svc/REST/GET_WF_LOOKUP';
  constructor(public authService: AuthenticationService, public con: ConnectorService) { }


  public getVacationRule(vacationRuleRequest: VacationRuleRequest, onError: any, errorLabel: string): Observable<any> {
    const request = vacationRuleRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.getVacationRule, request, onError, errorLabel);
  }

  public getVacationType(vacationTypeRequest: VacationTypeRequest, onError: any, errorLabel: string): Observable<any> {
    const request = vacationTypeRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.getVacationType, request, onError, errorLabel);
  }

  public getNotificationType(notificationTypeRequest: notificationTypeRequest, onError: any, errorLabel: string): Observable<any> {
    const request = notificationTypeRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.getNotificationType, request, onError, errorLabel);
  }

  public notificationReassign(notificationRequest: LoginRequest, onError: any, errorLabel: string): Observable<any> {
    const request = notificationRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.notificationReassign, request, onError, errorLabel);
  }

  public respondAttributes(notificationTypeRequest: notificationTypeRequest, onError: any, errorLabel: string): Observable<any> {
    const request = notificationTypeRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.respondAttributes, request, onError, errorLabel);
  }

  public getRespondAttributeValues(repsondAttrValues: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = repsondAttrValues;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.getRespondAttributeValues, request, onError, errorLabel);
  }

  public getReplacementList(req: ReplacementServiceRequest, onError?: any, errorLabel?: string): Observable<any> {
    const request = req;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.getReplacmentEmployeeList, request, onError, errorLabel);
  }

  public createVacationRule(ActionHistoryRequest: LoginRequest, onError?: any, errorLabel?: string): Observable<any> {
    const request = ActionHistoryRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.createVacationRule, request, onError, errorLabel);
  }

  public updateVacationRule(ActionHistoryRequest: LoginRequest, onError?: any, errorLabel?: string): Observable<any> {
    const request = ActionHistoryRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.updateVacationRule, request, onError, errorLabel);
  }

  public deleteVacationRule(ActionHistoryRequest: DeleteVacationRuleRequest, onError?: any, errorLabel?: string): Observable<any> {
    const request = ActionHistoryRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(VacationRuleServiceService.deleteVacationRule, request, onError, errorLabel);
  }

  public getLookup (getLookupRequest :any,onError,errorLabel){
   const request =getLookupRequest;
   this.authService.authenticateRequest(request);
   return this.con.post(VacationRuleServiceService.getLookup,request,onError,errorLabel);
  }
}
