import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { FormCatalogMeasures, ResponseDataGet } from 'src/app/interfaces/ANFA/catalog-measures.interface';
import { ResponseData } from 'src/app/interfaces/response-data';
import { HttpRequestService } from '../resources/http-request.service';

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

  private _url: string;
  constructor( private _httpRequestService: HttpRequestService ) {
    this._url = 'failure-analysis';
  }

  public getCatalogMeasures(): Observable<ResponseDataGet> {
    return this._httpRequestService.getQuery(`${this._url}/get-catalog-measures/1`).pipe(map((data:any) => data))
  }

  public registerCatalogMeasures(response: FormCatalogMeasures): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/register-catalog-measures`,response).pipe(map((data:any) => data));
  }

  public updateCatalogMeasures(response: FormCatalogMeasures): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/update-catalog-measures`,response).pipe(map((data:any) => data));
  }

  public deleteCatalogMeasures(response: FormCatalogMeasures): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/delete-catalog-measures`,response).pipe(map((data:any) => data));
  }

}
