import { Injectable } from '@angular/core';
import { Observable } from "rxjs";
import { ConnectorService } from 'src/app/hmg-common/services/connector/connector.service';
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
@Injectable({
  providedIn: 'root'
})
export class ProfileService {
  public static updateEmpImage = "Services/ERP.svc/REST/UPDATE_EMPLOYEE_IMAGE";
  public static getEmployeeBasicDetails = "Services/ERP.svc/REST/GET_EMPLOYEE_BASIC_DETAILS";
  /*  EIT Services URLs  */
  public static getMenuEntries = 'Services/ERP.svc/REST/GET_MENU_ENTRIES';
  public static getEITTransctions = 'Services/ERP.svc/REST/GET_EIT_TRANSACTIONS';
  public static getBASICDFFStrutre = 'Services/ERP.svc/REST/GET_BASIC_DET_DFF_STRUCTURE';
  public static getBASICCOLStructure = 'Services/ERP.svc/REST/GET_BASIC_DET_COLS_STRUCTURE';
  public static getSetValue = 'Services/ERP.svc/REST/GET_VALUE_SET_VALUES';
  public static getDefaultValue = 'Services/ERP.svc/REST/GET_DEFAULT_VALUE';
  public static validateEITTransctions = 'Services/ERP.svc/REST/VALIDATE_EIT_TRANSACTION';
  public static submitEit = 'Services/ERP.svc/REST/SUBMIT_EIT_TRANSACTION';
  public static resubmitEit = 'Services/ERP.svc/REST/RESUBMIT_EIT_TRANSACTION';
  public static startEitProcess = 'Services/ERP.svc/REST/START_ADDRESS_APPROVAL_PROCESS';
  public static startBasicProcess = 'Services/ERP.svc/REST/START_BASIC_DET_APPR_PROCESS';
  public static updateAttach = 'Services/ERP.svc/REST/UPDATE_ATTACHMENT';
  public static deleteAttach = 'Services/ERP.svc/REST/DELETE_ATTACHMENT';
  public static getApproversList = 'Services/ERP.svc/REST/GET_APPROVERS_LIST';
  public static addAttachment = 'Services/ERP.svc/REST/ADD_ATTACHMENT';
  public static cancelHRTransaction = 'Services/ERP.svc/REST/CANCEL_HR_TRANSACTION';
  public static getAttach = 'Services/ERP.svc/REST/GET_ATTACHMENTS';

  public static getEmployeeAddress = "Services/ERP.svc/REST/GET_EMPLOYEE_ADDRESS";
  public static getCountries = "Services/ERP.svc/REST/GET_COUNTRIES";
  public static getDiffStructure = "Services/ERP.svc/REST/GET_ADDRESS_DFF_STRUCTURE";
  public static submitAddressTransactions = "Services/ERP.svc/REST/SUBMIT_ADDRESS_TRANSACTION";
  public static submitBasicDetailsTransaction = "Services/ERP.svc/REST/SUBMIT_BASIC_DET_TRANSACTION";

  public static ADRESS_ENTRIES = 'address-entries';
  public static EMP_ADDRESS = 'emp-address';
  public static COUNTRY = 'country';
  public static SELECTED_STATUS = 'selected-status';
  constructor(
    public con: ConnectorService,
    public authService: AuthenticationService
  ) { }

  public updateImageProfile(updateImgRequest: any, onError?: any, errorLabel?: string
  ): Observable<any> {
    const request = updateImgRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(
      ProfileService.updateEmpImage,
      request,
      onError,
      errorLabel
    );
  }

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

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

  public getBasicDFFStrutre(BASICDFFStrutreReq: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = BASICDFFStrutreReq;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.getBASICDFFStrutre, request, onError, errorLabel);
  }

  public getColumnStructure(body: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = body;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.getBASICCOLStructure, request, onError, errorLabel);
  }

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

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

  public submitEit(eit: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = eit;
    request.EITTransactionTBLModel = eit.EITTransactionTBL;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.submitEit, request, onError, errorLabel);
  }

  public getCountries(basicEmployeeDetailsRequest: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = basicEmployeeDetailsRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.getCountries, request, onError, errorLabel);
  }
  public getAddressDiffStructure(basicEmployeeDetailsRequest: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = basicEmployeeDetailsRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.getDiffStructure, request, onError, errorLabel);
  }
  public submitAddressTransaction(validateEITTransactionReq: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = validateEITTransactionReq;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.submitAddressTransactions, request, onError, errorLabel);
  }
  public submitBasicDetailsTransaction(basicDetailsRequest: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = basicDetailsRequest;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.submitBasicDetailsTransaction, request, onError, errorLabel);
  }
  public startEitApprovalProcess(eitProcess: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = eitProcess;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.startEitProcess, request, onError, errorLabel);
  }
  public startBasicDetailsApprovalProcess(basicDetailsProcess: any, onError?: any, errorLabel?: string): Observable<any> {
    const request = basicDetailsProcess;
    this.authService.authenticateRequest(request);
    return this.con.post(ProfileService.startBasicProcess, request, onError, errorLabel);
  }
}