]>
Commit | Line | Data |
---|---|---|
901bcf5c | 1 | import { pick } from '@shared/core-utils' |
b2111066 C |
2 | import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | |
4 | ||
5 | export class VideoStatsCommand extends AbstractCommand { | |
6 | ||
7 | getOverallStats (options: OverrideCommandOptions & { | |
8 | videoId: number | string | |
9 | }) { | |
10 | const path = '/api/v1/videos/' + options.videoId + '/stats/overall' | |
11 | ||
12 | return this.getRequestBody<VideoStatsOverall>({ | |
13 | ...options, | |
14 | path, | |
15 | ||
16 | implicitToken: true, | |
17 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
18 | }) | |
19 | } | |
20 | ||
21 | getTimeserieStats (options: OverrideCommandOptions & { | |
22 | videoId: number | string | |
23 | metric: VideoStatsTimeserieMetric | |
901bcf5c C |
24 | startDate?: Date |
25 | endDate?: Date | |
b2111066 C |
26 | }) { |
27 | const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric | |
28 | ||
29 | return this.getRequestBody<VideoStatsTimeserie>({ | |
30 | ...options, | |
31 | path, | |
32 | ||
901bcf5c | 33 | query: pick(options, [ 'startDate', 'endDate' ]), |
b2111066 C |
34 | implicitToken: true, |
35 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
36 | }) | |
37 | } | |
38 | ||
39 | getRetentionStats (options: OverrideCommandOptions & { | |
40 | videoId: number | string | |
41 | }) { | |
42 | const path = '/api/v1/videos/' + options.videoId + '/stats/retention' | |
43 | ||
44 | return this.getRequestBody<VideoStatsRetention>({ | |
45 | ...options, | |
46 | path, | |
47 | ||
48 | implicitToken: true, | |
49 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
50 | }) | |
51 | } | |
52 | } |