]>
Commit | Line | Data |
---|---|---|
41e74ec9 | 1 | import { buildUUID } from '@shared/extra-utils' |
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 | |
41e74ec9 | 11 | ignoreCache: boolean |
c1bc8ee4 C |
12 | format?: string |
13 | }) { | |
41e74ec9 | 14 | const { feed, format, ignoreCache } = options |
c1bc8ee4 | 15 | const path = '/feeds/' + feed + '.xml' |
966eb053 | 16 | |
41e74ec9 C |
17 | const query: { [id: string]: string } = {} |
18 | ||
19 | if (ignoreCache) query.v = buildUUID() | |
20 | if (format) query.format = format | |
21 | ||
c1bc8ee4 C |
22 | return this.getRequestText({ |
23 | ...options, | |
966eb053 | 24 | |
c1bc8ee4 | 25 | path, |
41e74ec9 | 26 | query, |
c1bc8ee4 | 27 | accept: 'application/xml', |
a1637fa1 | 28 | implicitToken: false, |
c1bc8ee4 C |
29 | defaultExpectedStatus: HttpStatusCode.OK_200 |
30 | }) | |
31 | } | |
32 | ||
33 | getJSON (options: OverrideCommandOptions & { | |
34 | feed: FeedType | |
41e74ec9 | 35 | ignoreCache: boolean |
c1bc8ee4 C |
36 | query?: { [ id: string ]: any } |
37 | }) { | |
41e74ec9 | 38 | const { feed, query = {}, ignoreCache } = options |
c1bc8ee4 | 39 | const path = '/feeds/' + feed + '.json' |
966eb053 | 40 | |
41e74ec9 C |
41 | const cacheQuery = ignoreCache |
42 | ? { v: buildUUID() } | |
43 | : {} | |
44 | ||
c1bc8ee4 C |
45 | return this.getRequestText({ |
46 | ...options, | |
966eb053 | 47 | |
c1bc8ee4 | 48 | path, |
41e74ec9 | 49 | query: { ...query, ...cacheQuery }, |
c1bc8ee4 | 50 | accept: 'application/json', |
a1637fa1 | 51 | implicitToken: false, |
c1bc8ee4 C |
52 | defaultExpectedStatus: HttpStatusCode.OK_200 |
53 | }) | |
54 | } | |
966eb053 | 55 | } |