]>
Commit | Line | Data |
---|---|---|
c1bc8ee4 | 1 | |
2d53be02 | 2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
c1bc8ee4 | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
966eb053 | 4 | |
5beb89f2 | 5 | type FeedType = 'videos' | 'video-comments' | 'subscriptions' |
fe3a55b0 | 6 | |
c1bc8ee4 | 7 | export class FeedCommand extends AbstractCommand { |
966eb053 | 8 | |
c1bc8ee4 C |
9 | getXML (options: OverrideCommandOptions & { |
10 | feed: FeedType | |
11 | format?: string | |
12 | }) { | |
13 | const { feed, format } = options | |
14 | const path = '/feeds/' + feed + '.xml' | |
966eb053 | 15 | |
c1bc8ee4 C |
16 | return this.getRequestText({ |
17 | ...options, | |
966eb053 | 18 | |
c1bc8ee4 C |
19 | path, |
20 | query: format ? { format } : undefined, | |
21 | accept: 'application/xml', | |
22 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
23 | }) | |
24 | } | |
25 | ||
26 | getJSON (options: OverrideCommandOptions & { | |
27 | feed: FeedType | |
28 | query?: { [ id: string ]: any } | |
29 | }) { | |
30 | const { feed, query } = options | |
31 | const path = '/feeds/' + feed + '.json' | |
966eb053 | 32 | |
c1bc8ee4 C |
33 | return this.getRequestText({ |
34 | ...options, | |
966eb053 | 35 | |
c1bc8ee4 C |
36 | path, |
37 | query, | |
38 | accept: 'application/json', | |
39 | defaultExpectedStatus: HttpStatusCode.OK_200 | |
40 | }) | |
41 | } | |
966eb053 | 42 | } |