import { inject, Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { PvPlant } from '../models/pv-plant.model'; import { ApiResponse } from '../models/api-response.model'; import { SettingsService } from './settings.service'; @Injectable({ providedIn: 'root' }) export class PvPlantService { private readonly http = inject(HttpClient); private readonly settingsService = inject(SettingsService); getAll(): Observable { const { apiBaseUrl, endpointPlants } = this.settingsService.settings(); return this.http .get>(apiBaseUrl + endpointPlants) .pipe(map((res) => res.data)); } getById(id: string): Observable { const { apiBaseUrl, endpointPlants } = this.settingsService.settings(); return this.http .get>(`${apiBaseUrl}${endpointPlants}/${encodeURIComponent(id)}`) .pipe(map((res) => res.data)); } }