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 {AddEitResponse} from '../models/add.eit.response'
@Injectable()
export class ConfirmAddEitService {
  public static addAttachment = "Services/ERP.svc/REST/ADD_ATTACHMENT";
  public static submitEit = "Services/ERP.svc/REST/SUBMIT_EIT_TRANSACTION";
  public static startEitProcess =
    "Services/ERP.svc/REST/START_EIT_APPROVAL_PROCESS";
  constructor(
    public api: ConnectorService,
    public authService: AuthenticationService
  ) {}

  public submitEit(eit: any, onError?: any, errorLabel?: string) {
    const request = eit;
    request.EITTransactionTBLModel = eit.EITTransactionTBL;
    //request.EITTransactionTBL=[];
    this.authService.authenticateRequest(request);
    return this.api.post(
      ConfirmAddEitService.submitEit,
      request,
      onError,
      errorLabel
    );
  }

  public startEitApprovalProcess(
    eitProcess: any,
    onError?: any,
    errorLabel?: string
  ): Observable<any> {
    const request = eitProcess;
    this.authService.authenticateRequest(request);
    return this.api.post(
      ConfirmAddEitService.startEitProcess,
      request,
      onError,
      errorLabel
    );
  }
  public addAttachment(
    addAttachrequest: any,
    onError?: any,
    errorLabel?: string
  ): Observable<any> {
    const request = addAttachrequest;
    this.authService.authenticateRequest(request);
    return this.api.post(
      ConfirmAddEitService.addAttachment,
      request,
      onError,
      errorLabel
    );
  }
}
