From e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 09:55:05 +0200 Subject: Introduce CustomPage command --- shared/extra-utils/custom-pages/custom-pages.ts | 47 ++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'shared/extra-utils/custom-pages/custom-pages.ts') diff --git a/shared/extra-utils/custom-pages/custom-pages.ts b/shared/extra-utils/custom-pages/custom-pages.ts index bf2d16c70..56dabdc0f 100644 --- a/shared/extra-utils/custom-pages/custom-pages.ts +++ b/shared/extra-utils/custom-pages/custom-pages.ts @@ -1,31 +1,30 @@ +import { CustomPage } from '@shared/models' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' -import { makeGetRequest, makePutBodyRequest } from '../requests/requests' +import { AbstractCommand, OverrideCommandOptions } from '../shared' -function getInstanceHomepage (url: string, statusCodeExpected = HttpStatusCode.OK_200) { - const path = '/api/v1/custom-pages/homepage/instance' +export class CustomPagesCommand extends AbstractCommand { - return makeGetRequest({ - url, - path, - statusCodeExpected - }) -} - -function updateInstanceHomepage (url: string, token: string, content: string) { - const path = '/api/v1/custom-pages/homepage/instance' + getInstanceHomepage (options: OverrideCommandOptions = {}) { + const path = '/api/v1/custom-pages/homepage/instance' - return makePutBodyRequest({ - url, - path, - token, - fields: { content }, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 - }) -} + return this.getRequestBody({ + ...options, + path, + defaultExpectedStatus: HttpStatusCode.OK_200 + }) + } -// --------------------------------------------------------------------------- + updateInstanceHomepage (options: OverrideCommandOptions & { + content: string + }) { + const { content } = options + const path = '/api/v1/custom-pages/homepage/instance' -export { - getInstanceHomepage, - updateInstanceHomepage + return this.putBodyRequest({ + ...options, + path, + fields: { content }, + defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 + }) + } } -- cgit v1.2.3