diff options
Diffstat (limited to 'shared/extra-utils/overviews')
-rw-r--r-- | shared/extra-utils/overviews/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/overviews/overviews-command.ts | 25 | ||||
-rw-r--r-- | shared/extra-utils/overviews/overviews.ts | 34 |
3 files changed, 26 insertions, 34 deletions
diff --git a/shared/extra-utils/overviews/index.ts b/shared/extra-utils/overviews/index.ts new file mode 100644 index 000000000..e19551907 --- /dev/null +++ b/shared/extra-utils/overviews/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './overviews-command' | |||
diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts new file mode 100644 index 000000000..0ac3cbd33 --- /dev/null +++ b/shared/extra-utils/overviews/overviews-command.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | ||
2 | import { VideosOverview } from '@shared/models' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
4 | |||
5 | export class OverviewsCommand extends AbstractCommand { | ||
6 | |||
7 | getVideos (options: OverrideCommandOptions & { | ||
8 | page: number | ||
9 | token?: string | ||
10 | }) { | ||
11 | const { token, page } = options | ||
12 | const path = '/api/v1/overviews/videos' | ||
13 | |||
14 | const query = { page } | ||
15 | |||
16 | return this.getRequestBody<VideosOverview>({ | ||
17 | ...options, | ||
18 | |||
19 | token: token || null, | ||
20 | path, | ||
21 | query, | ||
22 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
23 | }) | ||
24 | } | ||
25 | } | ||
diff --git a/shared/extra-utils/overviews/overviews.ts b/shared/extra-utils/overviews/overviews.ts deleted file mode 100644 index 5e1a13e5e..000000000 --- a/shared/extra-utils/overviews/overviews.ts +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | import { makeGetRequest } from '../requests/requests' | ||
2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | |||
4 | function getVideosOverview (url: string, page: number, statusCodeExpected = HttpStatusCode.OK_200) { | ||
5 | const path = '/api/v1/overviews/videos' | ||
6 | |||
7 | const query = { page } | ||
8 | |||
9 | return makeGetRequest({ | ||
10 | url, | ||
11 | path, | ||
12 | query, | ||
13 | statusCodeExpected | ||
14 | }) | ||
15 | } | ||
16 | |||
17 | function getVideosOverviewWithToken (url: string, page: number, token: string, statusCodeExpected = HttpStatusCode.OK_200) { | ||
18 | const path = '/api/v1/overviews/videos' | ||
19 | |||
20 | const query = { page } | ||
21 | |||
22 | return makeGetRequest({ | ||
23 | url, | ||
24 | path, | ||
25 | query, | ||
26 | token, | ||
27 | statusCodeExpected | ||
28 | }) | ||
29 | } | ||
30 | |||
31 | export { | ||
32 | getVideosOverview, | ||
33 | getVideosOverviewWithToken | ||
34 | } | ||