]>
Commit | Line | Data |
---|---|---|
3545e72c C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ |
2 | ||
3 | import { HttpStatusCode, VideoToken } from '@shared/models' | |
4 | import { unwrapBody } from '../requests' | |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | |
6 | ||
7 | export class VideoTokenCommand extends AbstractCommand { | |
8 | ||
9 | create (options: OverrideCommandOptions & { | |
10 | videoId: number | string | |
11 | }) { | |
12 | const { videoId } = options | |
13 | const path = '/api/v1/videos/' + videoId + '/token' | |
14 | ||
15 | return unwrapBody<VideoToken>(this.postBodyRequest({ | |
16 | ...options, | |
17 | ||
18 | path, | |
19 | implicitToken: true, | |
20 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
21 | })) | |
22 | } | |
23 | ||
24 | async getVideoFileToken (options: OverrideCommandOptions & { | |
25 | videoId: number | string | |
26 | }) { | |
27 | const { files } = await this.create(options) | |
28 | ||
29 | return files.token | |
30 | } | |
31 | } |