source: bus-n-go-pavel-216049/bus-n-go-frontend/src/app/services/route-instance/route-instance.service.ts

Last change on this file was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import {Injectable} from '@angular/core';
2import {Observable} from "rxjs";
3import {StartRouteInstanceRequest} from "../../model/requests/StartRouteInstanceRequest";
4import {RouteInstanceResponse} from "../../model/responses/RouteInstanceResponse";
5import {HttpClient, HttpHeaders} from "@angular/common/http";
6import {StartCommuteRequest} from "../../model/requests/StartCommuteRequest";
7import {CommuteResponse} from "../../model/responses/CommuteResponse";
8
9@Injectable({
10 providedIn: 'root'
11})
12export class RouteInstanceService {
13 private url = '/api/route-instances'
14
15 constructor(private http: HttpClient) {
16 }
17
18 start(request: StartRouteInstanceRequest): Observable<RouteInstanceResponse> {
19 return this.http.post<RouteInstanceResponse>(`${this.url}/start`, JSON.stringify(request), {
20 headers: new HttpHeaders({'Content-Type': 'application/json'})
21 })
22 }
23
24 getById(id: number): Observable<RouteInstanceResponse> {
25 return this.http.get<RouteInstanceResponse>(`${this.url}/${id}`)
26 }
27
28 stop(id: number): Observable<RouteInstanceResponse> {
29 return this.http.patch<RouteInstanceResponse>(`${this.url}/stop`, JSON.stringify(id), {
30 headers: new HttpHeaders({'Content-Type': 'application/json'})
31 })
32 }
33
34 getForStation(id: number): Observable<RouteInstanceResponse[]> {
35 return this.http.get<RouteInstanceResponse[]>(`${this.url}/station/${id}`)
36 }
37
38 getAll(): Observable<RouteInstanceResponse[]> {
39 return this.http.get<RouteInstanceResponse[]>(`${this.url}`)
40 }
41}
Note: See TracBrowser for help on using the repository browser.