1 import { buildUUID } from '@shared/extra-utils'
2 import { HttpStatusCode } from '@shared/models'
3 import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 type FeedType = 'videos' | 'video-comments' | 'subscriptions'
7 export class FeedCommand extends AbstractCommand {
9 getXML (options: OverrideCommandOptions & {
14 const { feed, format, ignoreCache } = options
15 const path = '/feeds/' + feed + '.xml'
17 const query: { [id: string]: string } = {}
19 if (ignoreCache) query.v = buildUUID()
20 if (format) query.format = format
22 return this.getRequestText({
27 accept: 'application/xml',
29 defaultExpectedStatus: HttpStatusCode.OK_200
33 getJSON (options: OverrideCommandOptions & {
36 query?: { [ id: string ]: any }
38 const { feed, query = {}, ignoreCache } = options
39 const path = '/feeds/' + feed + '.json'
41 const cacheQuery = ignoreCache
45 return this.getRequestText({
49 query: { ...query, ...cacheQuery },
50 accept: 'application/json',
52 defaultExpectedStatus: HttpStatusCode.OK_200