1 import { ResultList, Video, VideoChannel } from '@shared/models'
2 import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3 import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 export class SubscriptionsCommand extends AbstractCommand {
7 add (options: OverrideCommandOptions & {
10 const path = '/api/v1/users/me/subscriptions'
12 return this.postBodyRequest({
16 fields: { uri: options.targetUri },
17 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
21 list (options: OverrideCommandOptions & {
22 sort?: string // default -createdAt
25 const { sort = '-createdAt', search } = options
26 const path = '/api/v1/users/me/subscriptions'
28 return this.getRequestBody<ResultList<VideoChannel>>({
36 defaultExpectedStatus: HttpStatusCode.OK_200
40 listVideos (options: OverrideCommandOptions & {
41 sort?: string // default -createdAt
43 const { sort = '-createdAt' } = options
44 const path = '/api/v1/users/me/subscriptions/videos'
46 return this.getRequestBody<ResultList<Video>>({
51 defaultExpectedStatus: HttpStatusCode.OK_200
55 get (options: OverrideCommandOptions & {
58 const path = '/api/v1/users/me/subscriptions/' + options.uri
60 return this.getRequestBody<VideoChannel>({
64 defaultExpectedStatus: HttpStatusCode.OK_200
68 remove (options: OverrideCommandOptions & {
71 const path = '/api/v1/users/me/subscriptions/' + options.uri
73 return this.deleteRequest({
77 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
81 exist (options: OverrideCommandOptions & {
84 const path = '/api/v1/users/me/subscriptions/exist'
86 return this.getRequestBody<{ [id: string ]: boolean }>({
90 query: { 'uris[]': options.uris },
91 defaultExpectedStatus: HttpStatusCode.OK_200