2
1

history-command.ts 1.2 KB

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