]>
Commit | Line | Data |
---|---|---|
c1bc8ee4 | 1 | |
c0e8b12e | 2 | import { HttpStatusCode } from '@shared/models' |
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', | |
a1637fa1 | 22 | implicitToken: false, |
c1bc8ee4 C |
23 | defaultExpectedStatus: HttpStatusCode.OK_200 |
24 | }) | |
25 | } | |
26 | ||
27 | getJSON (options: OverrideCommandOptions & { | |
28 | feed: FeedType | |
29 | query?: { [ id: string ]: any } | |
30 | }) { | |
31 | const { feed, query } = options | |
32 | const path = '/feeds/' + feed + '.json' | |
966eb053 | 33 | |
c1bc8ee4 C |
34 | return this.getRequestText({ |
35 | ...options, | |
966eb053 | 36 | |
c1bc8ee4 C |
37 | path, |
38 | query, | |
39 | accept: 'application/json', | |
a1637fa1 | 40 | implicitToken: false, |
c1bc8ee4 C |
41 | defaultExpectedStatus: HttpStatusCode.OK_200 |
42 | }) | |
43 | } | |
966eb053 | 44 | } |