1 import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../requests/requests'
2 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4 function addUserSubscription (url: string, token: string, targetUri: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
5 const path = '/api/v1/users/me/subscriptions'
7 return makePostBodyRequest({
12 fields: { uri: targetUri }
16 function listUserSubscriptions (parameters: {
21 statusCodeExpected?: number
23 const { url, token, sort = '-createdAt', search, statusCodeExpected = HttpStatusCode.OK_200 } = parameters
24 const path = '/api/v1/users/me/subscriptions'
26 return makeGetRequest({
38 function listUserSubscriptionVideos (url: string, token: string, sort = '-createdAt', statusCodeExpected = HttpStatusCode.OK_200) {
39 const path = '/api/v1/users/me/subscriptions/videos'
41 return makeGetRequest({
50 function getUserSubscription (url: string, token: string, uri: string, statusCodeExpected = HttpStatusCode.OK_200) {
51 const path = '/api/v1/users/me/subscriptions/' + uri
53 return makeGetRequest({
61 function removeUserSubscription (url: string, token: string, uri: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
62 const path = '/api/v1/users/me/subscriptions/' + uri
64 return makeDeleteRequest({
72 function areSubscriptionsExist (url: string, token: string, uris: string[], statusCodeExpected = HttpStatusCode.OK_200) {
73 const path = '/api/v1/users/me/subscriptions/exist'
75 return makeGetRequest({
78 query: { 'uris[]': uris },
84 // ---------------------------------------------------------------------------
87 areSubscriptionsExist,
89 listUserSubscriptions,
91 listUserSubscriptionVideos,
92 removeUserSubscription