1 import { HttpStatusCode, ResultList, Video } from '@shared/models'
2 import { AbstractCommand, OverrideCommandOptions } from '../shared'
4 export class HistoryCommand extends AbstractCommand {
6 watchVideo (options: OverrideCommandOptions & {
7 videoId: number | string
10 const { videoId, currentTime } = options
12 const path = '/api/v1/videos/' + videoId + '/watching'
13 const fields = { currentTime }
15 return this.putBodyRequest({
21 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
25 list (options: OverrideCommandOptions & {
28 const { search } = options
29 const path = '/api/v1/users/me/history/videos'
31 return this.getRequestBody<ResultList<Video>>({
39 defaultExpectedStatus: HttpStatusCode.OK_200
43 removeElement (options: OverrideCommandOptions & {
46 const { videoId } = options
47 const path = '/api/v1/users/me/history/videos/' + videoId
49 return this.deleteRequest({
54 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
58 removeAll (options: OverrideCommandOptions & {
61 const { beforeDate } = options
62 const path = '/api/v1/users/me/history/videos/remove'
64 return this.postBodyRequest({
68 fields: { beforeDate },
70 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204