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 { WorkListReplacmentEmployeeRequest } from '../models/ReplacmentEmployeeReq';
import { WorkListActionHistoryRequest } from '../models/ActionHistoryReq';
import { WorKListRFCEmployeeResponse } from '../models/RFC-EmployeeRes';
import { WorkListActionHistoryResponse } from '../models/ActionHistoryRes';


@Injectable()
export class WorklistService {

  public static getWorkList = 'Services/ERP.svc/REST/GET_WORKLIST';
  public static getReplacmentEmployeeList = 'Services/ERP.svc/REST/GET_REPLACEMENT_LIST';
  public static getRFCEmployeeList = 'Services/ERP.svc/REST/GET_RFC_EMPLOYEE_LIST';
  public static getActionHistory = 'Services/ERP.svc/REST/GET_ACTION_HISTORY';

  constructor(
    public api: ConnectorService,
    public authService: AuthenticationService,

  ) { }

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

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

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

  public getActionHistory(historyActionReq: any, onError?: any, errorLabel?: string): Observable<WorkListActionHistoryResponse> {
    const request = historyActionReq;
    this.authService.authenticateRequest(request);
    return this.api.post(WorklistService.getActionHistory, request, onError, errorLabel);
  }

}