]>
Commit | Line | Data |
---|---|---|
1 | import { HttpStatusCode, ResultList, Video } from '@shared/models' | |
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | |
3 | ||
4 | export class HistoryCommand extends AbstractCommand { | |
5 | ||
6 | list (options: OverrideCommandOptions & { | |
7 | search?: string | |
8 | } = {}) { | |
9 | const { search } = options | |
10 | const path = '/api/v1/users/me/history/videos' | |
11 | ||
12 | return this.getRequestBody<ResultList<Video>>({ | |
13 | ...options, | |
14 | ||
15 | path, | |
16 | query: { | |
17 | search | |
18 | }, | |
19 | implicitToken: true, | |
20 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
21 | }) | |
22 | } | |
23 | ||
24 | removeElement (options: OverrideCommandOptions & { | |
25 | videoId: number | |
26 | }) { | |
27 | const { videoId } = options | |
28 | const path = '/api/v1/users/me/history/videos/' + videoId | |
29 | ||
30 | return this.deleteRequest({ | |
31 | ...options, | |
32 | ||
33 | path, | |
34 | implicitToken: true, | |
35 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | |
36 | }) | |
37 | } | |
38 | ||
39 | removeAll (options: OverrideCommandOptions & { | |
40 | beforeDate?: string | |
41 | } = {}) { | |
42 | const { beforeDate } = options | |
43 | const path = '/api/v1/users/me/history/videos/remove' | |
44 | ||
45 | return this.postBodyRequest({ | |
46 | ...options, | |
47 | ||
48 | path, | |
49 | fields: { beforeDate }, | |
50 | implicitToken: true, | |
51 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | |
52 | }) | |
53 | } | |
54 | } |