From 7eb5dc283403b6f0cb5705cf326b589426211eab Mon Sep 17 00:00:00 2001 From: Haukur Ingi Date: Mon, 30 Sep 2024 15:06:41 +0000 Subject: [PATCH] add new admin api --- libs/clients/signature-collection/src/lib/apis.ts | 3 +++ .../src/lib/signature-collection-admin.service.ts | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/clients/signature-collection/src/lib/apis.ts b/libs/clients/signature-collection/src/lib/apis.ts index b67558999093..5719223f72b8 100644 --- a/libs/clients/signature-collection/src/lib/apis.ts +++ b/libs/clients/signature-collection/src/lib/apis.ts @@ -5,6 +5,7 @@ import { MedmaelasofnunApi, MedmaeliApi, FrambodApi, + AdminApi as AdminClient, } from '../../gen/fetch' import { SignatureCollectionClientConfig } from './signature-collection.config' import { IdsClientConfig, XRoadConfig } from '@island.is/nest/config' @@ -15,6 +16,7 @@ export class AdminListApi extends MedmaelalistarApi {} export class AdminCollectionApi extends MedmaelasofnunApi {} export class AdminSignatureApi extends MedmaeliApi {} export class AdminCandidateApi extends FrambodApi {} +export class AdminApi extends AdminClient {} export class ManagerConfig extends Configuration {} export class ManagerListApi extends MedmaelalistarApi {} @@ -74,6 +76,7 @@ export const exportedApis = [ AdminCollectionApi, AdminSignatureApi, AdminCandidateApi, + AdminApi, ].map((Api) => ({ provide: Api, useFactory: ( diff --git a/libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts b/libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts index 78ac0e788e5f..f5bb5a183092 100644 --- a/libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts +++ b/libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts @@ -20,6 +20,7 @@ import { AdminCollectionApi, AdminListApi, AdminSignatureApi, + AdminApi, } from './apis' import { SignatureCollectionSharedClientService } from './signature-collection-shared.service' @@ -28,6 +29,7 @@ type Api = | AdminCollectionApi | AdminSignatureApi | AdminCandidateApi + | AdminApi @Injectable() export class SignatureCollectionAdminClientService { @@ -37,6 +39,7 @@ export class SignatureCollectionAdminClientService { private signatureApi: AdminSignatureApi, private sharedService: SignatureCollectionSharedClientService, private candidateApi: AdminCandidateApi, + private adminApi: AdminApi, ) {} private getApiWithAuth(api: T, auth: Auth) { @@ -296,9 +299,11 @@ export class SignatureCollectionAdminClientService { async removeList(listId: string, auth: Auth): Promise { try { - await this.getApiWithAuth(this.listsApi, auth).medmaelalistarIDDelete({ - iD: parseInt(listId), - }) + await this.getApiWithAuth(this.adminApi, auth).adminMedmaelalistiIDDelete( + { + iD: parseInt(listId), + }, + ) return { success: true } } catch (error) { return { success: false, reasons: [ReasonKey.DeniedByService] }