From 23a3a8827cb8b862f5cc7ee2819f39918303beca Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 14:30:20 +0200 Subject: Introduce overviews command --- shared/extra-utils/overviews/index.ts | 1 + shared/extra-utils/overviews/overviews-command.ts | 25 +++++++++++++++++ shared/extra-utils/overviews/overviews.ts | 34 ----------------------- 3 files changed, 26 insertions(+), 34 deletions(-) create mode 100644 shared/extra-utils/overviews/index.ts create mode 100644 shared/extra-utils/overviews/overviews-command.ts delete mode 100644 shared/extra-utils/overviews/overviews.ts (limited to 'shared/extra-utils/overviews') 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 @@ +import { HttpStatusCode } from '@shared/core-utils' +import { VideosOverview } from '@shared/models' +import { AbstractCommand, OverrideCommandOptions } from '../shared' + +export class OverviewsCommand extends AbstractCommand { + + getVideos (options: OverrideCommandOptions & { + page: number + token?: string + }) { + const { token, page } = options + const path = '/api/v1/overviews/videos' + + const query = { page } + + return this.getRequestBody({ + ...options, + + token: token || null, + path, + query, + defaultExpectedStatus: HttpStatusCode.OK_200 + }) + } +} 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 @@ -import { makeGetRequest } from '../requests/requests' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' - -function getVideosOverview (url: string, page: number, statusCodeExpected = HttpStatusCode.OK_200) { - const path = '/api/v1/overviews/videos' - - const query = { page } - - return makeGetRequest({ - url, - path, - query, - statusCodeExpected - }) -} - -function getVideosOverviewWithToken (url: string, page: number, token: string, statusCodeExpected = HttpStatusCode.OK_200) { - const path = '/api/v1/overviews/videos' - - const query = { page } - - return makeGetRequest({ - url, - path, - query, - token, - statusCodeExpected - }) -} - -export { - getVideosOverview, - getVideosOverviewWithToken -} -- cgit v1.2.3