2018-12-17 08:52:38 -06:00
|
|
|
import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
|
2020-12-07 07:32:36 -06:00
|
|
|
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
2018-10-05 04:15:06 -05:00
|
|
|
|
2020-12-08 14:16:10 -06:00
|
|
|
function userWatchVideo (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
videoId: number | string,
|
|
|
|
currentTime: number,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-05 04:15:06 -05:00
|
|
|
const path = '/api/v1/videos/' + videoId + '/watching'
|
|
|
|
const fields = { currentTime }
|
|
|
|
|
2018-12-17 08:52:38 -06:00
|
|
|
return makePutBodyRequest({ url, path, token, fields, statusCodeExpected })
|
|
|
|
}
|
|
|
|
|
|
|
|
function listMyVideosHistory (url: string, token: string) {
|
|
|
|
const path = '/api/v1/users/me/history/videos'
|
|
|
|
|
|
|
|
return makeGetRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
2020-12-07 07:32:36 -06:00
|
|
|
statusCodeExpected: HttpStatusCode.OK_200
|
2018-12-17 08:52:38 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeMyVideosHistory (url: string, token: string, beforeDate?: string) {
|
|
|
|
const path = '/api/v1/users/me/history/videos/remove'
|
|
|
|
|
|
|
|
return makePostBodyRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
fields: beforeDate ? { beforeDate } : {},
|
2020-12-07 07:32:36 -06:00
|
|
|
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
2018-12-17 08:52:38 -06:00
|
|
|
})
|
2018-10-05 04:15:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2018-12-17 08:52:38 -06:00
|
|
|
userWatchVideo,
|
|
|
|
listMyVideosHistory,
|
|
|
|
removeMyVideosHistory
|
2018-10-05 04:15:06 -05:00
|
|
|
}
|