source: bus-n-go-pavel-216049/bus-n-go-frontend/src/app/services/ticket/ticket.service.ts@ dedbf60

Last change on this file since dedbf60 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: 1014 bytes
RevLine 
[baf4cc4]1import { Injectable } from '@angular/core';
2import {HttpClient, HttpHeaders} from "@angular/common/http";
3import {Observable} from "rxjs";
4import {TicketBuyRequest} from "../../model/requests/TicketBuyRequest";
5import {TicketResponse} from "../../model/responses/TicketResponse";
6
7@Injectable({
8 providedIn: 'root'
9})
10export class TicketService {
11
12 private _url = '/api/tickets'
13
14 constructor(private http: HttpClient) { }
15
16 getTickets(): Observable<TicketResponse[]> {
17 return this.http.get<TicketResponse[]>(`${this._url}`)
18 }
19
20 activateTicket(id: number): Observable<TicketResponse> {
21 return this.http.patch<TicketResponse>(`${this._url}/activate/${id}`, JSON.stringify({}), {
22 headers: new HttpHeaders({'Content-Type': 'application/json'})
23 })
24 }
25
26 buyTicket(request: TicketBuyRequest): Observable<TicketResponse> {
27 return this.http.post<TicketResponse>(`${this._url}/buy`, JSON.stringify(request), {
28 headers: new HttpHeaders({'Content-Type': 'application/json'})
29 })
30 }
31}
Note: See TracBrowser for help on using the repository browser.