2021-07-16 08:27:30 -04:00
|
|
|
import { HttpStatusCode, ResultList, Video } from '@shared/models'
|
2021-07-08 10:21:42 -04:00
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
|
|
|
|
|
|
|
export class HistoryCommand extends AbstractCommand {
|
|
|
|
|
|
|
|
list (options: OverrideCommandOptions & {
|
|
|
|
search?: string
|
|
|
|
} = {}) {
|
|
|
|
const { search } = options
|
|
|
|
const path = '/api/v1/users/me/history/videos'
|
|
|
|
|
|
|
|
return this.getRequestBody<ResultList<Video>>({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
query: {
|
|
|
|
search
|
|
|
|
},
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-01-18 05:23:41 -05:00
|
|
|
removeElement (options: OverrideCommandOptions & {
|
|
|
|
videoId: number
|
|
|
|
}) {
|
|
|
|
const { videoId } = options
|
|
|
|
const path = '/api/v1/users/me/history/videos/' + videoId
|
|
|
|
|
|
|
|
return this.deleteRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
removeAll (options: OverrideCommandOptions & {
|
2021-07-08 10:21:42 -04:00
|
|
|
beforeDate?: string
|
|
|
|
} = {}) {
|
|
|
|
const { beforeDate } = options
|
|
|
|
const path = '/api/v1/users/me/history/videos/remove'
|
|
|
|
|
|
|
|
return this.postBodyRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
fields: { beforeDate },
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|