video-history.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
  2. function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) {
  3. const path = '/api/v1/videos/' + videoId + '/watching'
  4. const fields = { currentTime }
  5. return makePutBodyRequest({ url, path, token, fields, statusCodeExpected })
  6. }
  7. function listMyVideosHistory (url: string, token: string) {
  8. const path = '/api/v1/users/me/history/videos'
  9. return makeGetRequest({
  10. url,
  11. path,
  12. token,
  13. statusCodeExpected: 200
  14. })
  15. }
  16. function removeMyVideosHistory (url: string, token: string, beforeDate?: string) {
  17. const path = '/api/v1/users/me/history/videos/remove'
  18. return makePostBodyRequest({
  19. url,
  20. path,
  21. token,
  22. fields: beforeDate ? { beforeDate } : {},
  23. statusCodeExpected: 204
  24. })
  25. }
  26. // ---------------------------------------------------------------------------
  27. export {
  28. userWatchVideo,
  29. listMyVideosHistory,
  30. removeMyVideosHistory
  31. }