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:
1014 bytes
|
Line | |
---|
1 | import { Injectable } from '@angular/core';
|
---|
2 | import {HttpClient, HttpHeaders} from "@angular/common/http";
|
---|
3 | import {Observable} from "rxjs";
|
---|
4 | import {TicketBuyRequest} from "../../model/requests/TicketBuyRequest";
|
---|
5 | import {TicketResponse} from "../../model/responses/TicketResponse";
|
---|
6 |
|
---|
7 | @Injectable({
|
---|
8 | providedIn: 'root'
|
---|
9 | })
|
---|
10 | export 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.