37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
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 {ShowsApiDeletion} from '../../interfaces/shows-api-deletion';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ShowsApiService {
|
|
|
|
private readonly url: string = "https://shows.everest.tailscale/api/";
|
|
private showsEndpoint: string
|
|
private http: HttpClient = inject(HttpClient);
|
|
|
|
constructor() {
|
|
this.showsEndpoint = this.url + "shows/"
|
|
}
|
|
|
|
getShows(): Observable<ShowsApiResponse> {
|
|
return this.http.get<ShowsApiResponse>(this.showsEndpoint)
|
|
}
|
|
|
|
getShow(id: string): Observable<ShowsApiIdResponse> {
|
|
return this.http.get<ShowsApiIdResponse>(this.showsEndpoint + "id/" + id )
|
|
}
|
|
|
|
sendShow(newShow: {}) {
|
|
return this.http.post<ShowsApiCreation>(this.showsEndpoint, newShow)
|
|
}
|
|
|
|
deleteShw(id: string): Observable<ShowsApiDeletion> {
|
|
return this.http.delete<ShowsApiDeletion>(this.showsEndpoint + "id/" + id)
|
|
}
|
|
}
|