import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { RequestDataDeleteSymtom, RequestDataFormSymptom, ResponseDataGetSymptomList, ResponseDataSymptomList } from 'src/app/interfaces/failure-analysis/symptom.interface';
import { ResponseData } from 'src/app/interfaces/response-data';
import { HttpRequestService } from '../resources/http-request.service';

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

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

  public getSymptom(idUser: string): Observable<ResponseDataGetSymptomList> {
    return this._httpRequestService.getQuery(`${this._url}/get-symptoms`).pipe(map((data: any) => data));
  }
  public getSymptomsActives(): Observable<ResponseDataGetSymptomList> {
    return this._httpRequestService.getQuery(`${this._url}get-symptoms-actives`).pipe(map((data: any) => data));
  }
  public getSymptomsByEquipment(idUser: string, codeEquipment:string): Observable<ResponseDataGetSymptomList> {
    return this._httpRequestService.getQuery(`${this._url}/get-symptoms-by-equipment/${codeEquipment}`).pipe(map((data: any) => data));
  }
  public getSymptomById(idSymptom:string): Observable<ResponseDataSymptomList> {
    return this._httpRequestService.getQuery(`${this._url}/get-symptom-by-id/${idSymptom}`).pipe(map((data: any) => data));
  }
  public registerSymptom(response:RequestDataFormSymptom): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/register-symptom`, response).pipe(map((data:any) => data));
  }
  public updateSymptom(response:RequestDataFormSymptom): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/update-symptom`, response).pipe(map((data:any) => data));
  }
  public deteleSymptom(response:RequestDataDeleteSymtom): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/delete-symptom`, response).pipe(map((data:any) => data));
  }
                                   
}
