]>
Commit | Line | Data |
---|---|---|
c6c0fa6c C |
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' | |
39e68a32 | 5 | import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@shared/models' |
f8c00564 | 6 | import { environment } from '../../../environments/environment' |
c6c0fa6c C |
7 | |
8 | @Injectable() | |
a5cf76af | 9 | export class LiveVideoService { |
c6c0fa6c C |
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 | ||
b5b68755 | 17 | goLive (video: LiveVideoCreate) { |
c6c0fa6c | 18 | return this.authHttp |
2e80d256 | 19 | .post<{ video: VideoCreateResult }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video) |
c6c0fa6c C |
20 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
21 | } | |
22 | ||
23 | getVideoLive (videoId: number | string) { | |
24 | return this.authHttp | |
a5cf76af | 25 | .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId) |
c6c0fa6c C |
26 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
27 | } | |
b5b68755 | 28 | |
39e68a32 C |
29 | listSessions (videoId: number | string) { |
30 | return this.authHttp | |
31 | .get<ResultList<LiveVideoSession>>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId + '/sessions') | |
32 | .pipe(catchError(err => this.restExtractor.handleError(err))) | |
33 | } | |
34 | ||
b5b68755 C |
35 | updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) { |
36 | return this.authHttp | |
37 | .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate) | |
38 | .pipe(catchError(err => this.restExtractor.handleError(err))) | |
39 | } | |
c6c0fa6c | 40 | } |