aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+video-studio/shared/video-studio.service.ts
blob: 8d8b2f0e54a1156c68a20bdab85e8e2353802807 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { catchError } from 'rxjs'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { RestExtractor } from '@app/core'
import { objectToFormData } from '@app/helpers'
import { VideoService } from '@app/shared/shared-main'
import { VideoStudioCreateEdition, VideoStudioTask } from '@shared/models'

@Injectable()
export class VideoStudioService {

  constructor (
    private authHttp: HttpClient,
    private restExtractor: RestExtractor
  ) {}

  editVideo (videoId: number | string, tasks: VideoStudioTask[]) {
    const url = VideoService.BASE_VIDEO_URL + '/' + videoId + '/studio/edit'
    const body: VideoStudioCreateEdition = {
      tasks
    }

    const data = objectToFormData(body)

    return this.authHttp.post(url, data)
      .pipe(catchError(err => this.restExtractor.handleError(err)))
  }
}