2021-07-06 03:21:35 -05:00
|
|
|
|
2021-07-16 03:42:24 -05:00
|
|
|
import { HttpStatusCode } from '@shared/models'
|
2021-07-06 03:21:35 -05:00
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
2018-04-18 09:08:36 -05:00
|
|
|
|
2020-11-09 09:25:27 -06:00
|
|
|
type FeedType = 'videos' | 'video-comments' | 'subscriptions'
|
2018-06-08 13:34:37 -05:00
|
|
|
|
2021-07-06 03:21:35 -05:00
|
|
|
export class FeedCommand extends AbstractCommand {
|
2018-04-18 09:08:36 -05:00
|
|
|
|
2021-07-06 03:21:35 -05:00
|
|
|
getXML (options: OverrideCommandOptions & {
|
|
|
|
feed: FeedType
|
|
|
|
format?: string
|
|
|
|
}) {
|
|
|
|
const { feed, format } = options
|
|
|
|
const path = '/feeds/' + feed + '.xml'
|
2018-04-18 09:08:36 -05:00
|
|
|
|
2021-07-06 03:21:35 -05:00
|
|
|
return this.getRequestText({
|
|
|
|
...options,
|
2018-04-18 09:08:36 -05:00
|
|
|
|
2021-07-06 03:21:35 -05:00
|
|
|
path,
|
|
|
|
query: format ? { format } : undefined,
|
|
|
|
accept: 'application/xml',
|
2021-07-08 03:55:16 -05:00
|
|
|
implicitToken: false,
|
2021-07-06 03:21:35 -05:00
|
|
|
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 09:08:36 -05:00
|
|
|
|
2021-07-06 03:21:35 -05:00
|
|
|
return this.getRequestText({
|
|
|
|
...options,
|
2018-04-18 09:08:36 -05:00
|
|
|
|
2021-07-06 03:21:35 -05:00
|
|
|
path,
|
|
|
|
query,
|
|
|
|
accept: 'application/json',
|
2021-07-08 03:55:16 -05:00
|
|
|
implicitToken: false,
|
2021-07-06 03:21:35 -05:00
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
2018-04-18 09:08:36 -05:00
|
|
|
}
|