diff options
Diffstat (limited to 'client/src/app/shared/shared-video-live/live-video.service.ts')
-rw-r--r-- | client/src/app/shared/shared-video-live/live-video.service.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-video-live/live-video.service.ts b/client/src/app/shared/shared-video-live/live-video.service.ts new file mode 100644 index 000000000..b02442eae --- /dev/null +++ b/client/src/app/shared/shared-video-live/live-video.service.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | import { catchError } from 'rxjs/operators' | ||
2 | import { HttpClient } from '@angular/common/http' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { RestExtractor } from '@app/core' | ||
5 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate } from '@shared/models' | ||
6 | import { environment } from '../../../environments/environment' | ||
7 | |||
8 | @Injectable() | ||
9 | export class LiveVideoService { | ||
10 | static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/' | ||
11 | |||
12 | constructor ( | ||
13 | private authHttp: HttpClient, | ||
14 | private restExtractor: RestExtractor | ||
15 | ) {} | ||
16 | |||
17 | goLive (video: LiveVideoCreate) { | ||
18 | return this.authHttp | ||
19 | .post<{ video: { id: number, uuid: string } }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video) | ||
20 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
21 | } | ||
22 | |||
23 | getVideoLive (videoId: number | string) { | ||
24 | return this.authHttp | ||
25 | .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId) | ||
26 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
27 | } | ||
28 | |||
29 | updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) { | ||
30 | return this.authHttp | ||
31 | .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate) | ||
32 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
33 | } | ||
34 | } | ||