2021-07-06 08:21:35 +00:00
|
|
|
|
2020-12-07 13:32:36 +00:00
|
|
|
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
2021-07-06 08:21:35 +00:00
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
2018-04-18 14:08:36 +00:00
|
|
|
|
2020-11-09 15:25:27 +00:00
|
|
|
type FeedType = 'videos' | 'video-comments' | 'subscriptions'
|
2018-06-08 18:34:37 +00:00
|
|
|
|
2021-07-06 08:21:35 +00:00
|
|
|
export class FeedCommand extends AbstractCommand {
|
2018-04-18 14:08:36 +00:00
|
|
|
|
2021-07-06 08:21:35 +00:00
|
|
|
getXML (options: OverrideCommandOptions & {
|
|
|
|
feed: FeedType
|
|
|
|
format?: string
|
|
|
|
}) {
|
|
|
|
const { feed, format } = options
|
|
|
|
const path = '/feeds/' + feed + '.xml'
|
2018-04-18 14:08:36 +00:00
|
|
|
|
2021-07-06 08:21:35 +00:00
|
|
|
return this.getRequestText({
|
|
|
|
...options,
|
2018-04-18 14:08:36 +00:00
|
|
|
|
2021-07-06 08:21:35 +00:00
|
|
|
path,
|
|
|
|
query: format ? { format } : undefined,
|
|
|
|
accept: 'application/xml',
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
getJSON (options: OverrideCommandOptions & {
|
|
|
|
feed: FeedType
|
|
|
|
query?: { [ id: string ]: any }
|
|
|
|
}) {
|
|
|
|
const { feed, query } = options
|
|
|
|
const path = '/feeds/' + feed + '.json'
|
2018-04-18 14:08:36 +00:00
|
|
|
|
2021-07-06 08:21:35 +00:00
|
|
|
return this.getRequestText({
|
|
|
|
...options,
|
2018-04-18 14:08:36 +00:00
|
|
|
|
2021-07-06 08:21:35 +00:00
|
|
|
path,
|
|
|
|
query,
|
|
|
|
accept: 'application/json',
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
2018-04-18 14:08:36 +00:00
|
|
|
}
|