aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/videos/video-token-command.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/server-commands/videos/video-token-command.ts')
-rw-r--r--shared/server-commands/videos/video-token-command.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/shared/server-commands/videos/video-token-command.ts b/shared/server-commands/videos/video-token-command.ts
new file mode 100644
index 000000000..0531bee65
--- /dev/null
+++ b/shared/server-commands/videos/video-token-command.ts
@@ -0,0 +1,31 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
2
3import { HttpStatusCode, VideoToken } from '@shared/models'
4import { unwrapBody } from '../requests'
5import { AbstractCommand, OverrideCommandOptions } from '../shared'
6
7export 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}