import {inject, Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {Observable} from 'rxjs'; import {ShowsApiResponse} from '../../interfaces/shows-api-response'; import {ShowsApiCreation} from '../../interfaces/shows-api-creation'; import {ShowsApiIdResponse} from '../../interfaces/shows-api-id-response'; import {ShowsApiDeletionEdit} from '../../interfaces/shows-api-deletion-edit'; import {Show} from '../../interfaces/show'; @Injectable({ providedIn: 'root' }) export class ShowsApiService { private readonly url: string = "https://shows.everest.tailscale/api/"; private showsEndpoint: string private idEndpoint: string private http: HttpClient = inject(HttpClient); constructor() { this.showsEndpoint = this.url + "shows/" this.idEndpoint = this.showsEndpoint + "id/" } getShows(): Observable { return this.http.get(this.showsEndpoint) } getShow(id: string): Observable { return this.http.get(this.idEndpoint + id) } sendShow(newShow: Show): Observable { return this.http.post(this.showsEndpoint, newShow) } deleteShw(id: string): Observable { return this.http.delete(this.idEndpoint + id) } updateShow(show: Show): Observable { return this.http.put(this.idEndpoint + show._id, show) } }