Skip to content

Commit

Permalink
add new admin api
Browse files Browse the repository at this point in the history
  • Loading branch information
juni-haukur committed Sep 30, 2024
1 parent 662ba42 commit 7eb5dc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions libs/clients/signature-collection/src/lib/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {}
Expand Down Expand Up @@ -74,6 +76,7 @@ export const exportedApis = [
AdminCollectionApi,
AdminSignatureApi,
AdminCandidateApi,
AdminApi,
].map((Api) => ({
provide: Api,
useFactory: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
AdminCollectionApi,
AdminListApi,
AdminSignatureApi,
AdminApi,
} from './apis'
import { SignatureCollectionSharedClientService } from './signature-collection-shared.service'

Expand All @@ -28,6 +29,7 @@ type Api =
| AdminCollectionApi
| AdminSignatureApi
| AdminCandidateApi
| AdminApi

@Injectable()
export class SignatureCollectionAdminClientService {
Expand All @@ -37,6 +39,7 @@ export class SignatureCollectionAdminClientService {
private signatureApi: AdminSignatureApi,
private sharedService: SignatureCollectionSharedClientService,
private candidateApi: AdminCandidateApi,
private adminApi: AdminApi,
) {}

private getApiWithAuth<T extends Api>(api: T, auth: Auth) {
Expand Down Expand Up @@ -296,9 +299,11 @@ export class SignatureCollectionAdminClientService {

async removeList(listId: string, auth: Auth): Promise<Success> {
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] }
Expand Down

0 comments on commit 7eb5dc2

Please sign in to comment.