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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import { pick } from '@shared/core-utils'
import { HttpStatusCode, VideoStatsOverall, VideoStatsRetention, VideoStatsTimeserie, VideoStatsTimeserieMetric } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class VideoStatsCommand extends AbstractCommand {
getOverallStats (options: OverrideCommandOptions & {
videoId: number | string
startDate?: string
endDate?: string
}) {
const path = '/api/v1/videos/' + options.videoId + '/stats/overall'
return this.getRequestBody<VideoStatsOverall>({
...options,
path,
query: pick(options, [ 'startDate', 'endDate' ]),
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getTimeserieStats (options: OverrideCommandOptions & {
videoId: number | string
metric: VideoStatsTimeserieMetric
startDate?: Date
endDate?: Date
}) {
const path = '/api/v1/videos/' + options.videoId + '/stats/timeseries/' + options.metric
return this.getRequestBody<VideoStatsTimeserie>({
...options,
path,
query: pick(options, [ 'startDate', 'endDate' ]),
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getRetentionStats (options: OverrideCommandOptions & {
videoId: number | string
}) {
const path = '/api/v1/videos/' + options.videoId + '/stats/retention'
return this.getRequestBody<VideoStatsRetention>({
...options,
path,
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
}
|