import { Injectable } from '@angular/core';
import { HttpRequestService } from 'src/app/services/resources/http-request.service';
import { Observable, map } from 'rxjs';

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

  private _url: string;
  constructor( private _httpRequestService:HttpRequestService ) {
    this._url = 'acquisition-management/acquisition';
  }

  public createUnit(objRequest: any) {
    return this._httpRequestService.postQuery(`${ this._url }/register-unit`, objRequest).pipe(map( (data:any) => data ));
  }

  public getUnits() : Observable<any> {
    return this._httpRequestService.getQuery(`${ this._url }/get-units`).pipe(map((data:any) => data));
  }

  public getUnitsActives() : Observable<any> {
    return this._httpRequestService.getQuery(`${ this._url }/get-units-actives`).pipe(map((data:any) => data));
  }
}
