1 import { HttpStatusCode, ResultList, VideoChannelSync, VideoChannelSyncCreate } from '@shared/models'
2 import { pick } from '@shared/core-utils'
3 import { unwrapBody } from '../requests'
4 import { AbstractCommand, OverrideCommandOptions } from '../shared'
6 export class ChannelSyncsCommand extends AbstractCommand {
7 private static readonly API_PATH = '/api/v1/video-channel-syncs'
9 listByAccount (options: OverrideCommandOptions & {
15 const { accountName, sort = 'createdAt' } = options
17 const path = `/api/v1/accounts/${accountName}/video-channel-syncs`
19 return this.getRequestBody<ResultList<VideoChannelSync>>({
23 query: { sort, ...pick(options, [ 'start', 'count' ]) },
25 defaultExpectedStatus: HttpStatusCode.OK_200
29 async create (options: OverrideCommandOptions & {
30 attributes: VideoChannelSyncCreate
32 return unwrapBody<{ videoChannelSync: VideoChannelSync }>(this.postBodyRequest({
35 path: ChannelSyncsCommand.API_PATH,
36 fields: options.attributes,
38 defaultExpectedStatus: HttpStatusCode.OK_200
42 delete (options: OverrideCommandOptions & {
45 const path = `${ChannelSyncsCommand.API_PATH}/${options.channelSyncId}`
47 return this.deleteRequest({
52 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204