]>
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 | |
49f0468d C |
9 | startDate?: string |
10 | endDate?: string | |
b2111066 C |
11 | }) { |
12 | const path = '/api/v1/videos/' + options.videoId + '/stats/overall' | |
13 | ||
14 | return this.getRequestBody<VideoStatsOverall>({ | |
15 | ...options, | |
16 | path, | |
17 | ||
49f0468d C |
18 | query: pick(options, [ 'startDate', 'endDate' ]), |
19 | ||
b2111066 C |
20 | implicitToken: true, |
21 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
22 | }) | |
23 | } | |
24 | ||
25 | getTimeserieStats (options: OverrideCommandOptions & { | |
26 | videoId: number | string | |
27 | metric: VideoStatsTimeserieMetric | |
901bcf5c C |
28 | startDate?: Date |
29 | endDate?: Date | |
b2111066 C |
30 | }) { |
31 | const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric | |
32 | ||
33 | return this.getRequestBody<VideoStatsTimeserie>({ | |
34 | ...options, | |
35 | path, | |
36 | ||
901bcf5c | 37 | query: pick(options, [ 'startDate', 'endDate' ]), |
b2111066 C |
38 | implicitToken: true, |
39 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
40 | }) | |
41 | } | |
42 | ||
43 | getRetentionStats (options: OverrideCommandOptions & { | |
44 | videoId: number | string | |
45 | }) { | |
46 | const path = '/api/v1/videos/' + options.videoId + '/stats/retention' | |
47 | ||
48 | return this.getRequestBody<VideoStatsRetention>({ | |
49 | ...options, | |
50 | path, | |
51 | ||
52 | implicitToken: true, | |
53 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
54 | }) | |
55 | } | |
56 | } |