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

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

  public static GET_TERM_COLS_STRUCTURE = 'Services/ERP.svc/REST/GET_TERM_COLS_STRUCTURE';
  public static GET_TERM_DIFF_STRUCTURE = 'Services/ERP.svc/REST/GET_TERM_DFF_STRUCTURE';
  public static SUBMIT_TRANSACTION = 'Services/ERP.svc/REST/SUBMIT_TERM_TRANSACTION';
  public static START_APPORVAL = 'Services/ERP.svc/REST/START_TERM_APPROVAL_PROCESS';
  public static TERMINATION_PAGE = 'termination-page';
  public static SHARED_DATA = 'termination-submit-data';
  constructor(
    public con: ConnectorService,
    private authService: AuthenticationService,
    public cs: CommonService
  ) { }
  getTerminationColStructure(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      TerminationServiceService.GET_TERM_COLS_STRUCTURE,
      request,
      onError,
      errorLabel
    );
  }
  getTermDiffStructure(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      TerminationServiceService.GET_TERM_DIFF_STRUCTURE,
      request,
      onError,
      errorLabel
    );
  }
  submitTransation(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      TerminationServiceService.SUBMIT_TRANSACTION,
      request,
      onError,
      errorLabel
    );
  }
  public startApprovalProcess(basicDetailsProcess: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = basicDetailsProcess;
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.post(TerminationServiceService.START_APPORVAL, request, onError, errorLabel);
  }




}
