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 AccrualService {
  public static GET_ACCRUAL_BALANCE =
    'Services/ERP.svc/REST/GET_ACCRUAL_BALANCES';
  constructor(
    public con: ConnectorService,
    public authService: AuthenticationService
  ) {}
  public getAccrualBalances(balance: any, onError?: any, errorLabel?: string, isPostNoLoad = false) {
    const request = balance;
    this.authService.authenticateRequest(request);
    if (isPostNoLoad) {
      return this.con.postNoLoad(
        AccrualService.GET_ACCRUAL_BALANCE,
        request,
        onError,
        errorLabel
      );
    } else {
      return this.con.post(
        AccrualService.GET_ACCRUAL_BALANCE,
        request,
        onError,
        errorLabel
      );
    }
  }
}
