diff --git a/libs/api/domains/signature-collection/src/lib/dto/uploadPaperSignature.input.ts b/libs/api/domains/signature-collection/src/lib/dto/uploadPaperSignature.input.ts new file mode 100644 index 000000000000..f69c102972b1 --- /dev/null +++ b/libs/api/domains/signature-collection/src/lib/dto/uploadPaperSignature.input.ts @@ -0,0 +1,17 @@ +import { IsNumber, IsString } from 'class-validator' +import { Field, InputType } from '@nestjs/graphql' + +@InputType() +export class SignatureCollectionUploadPaperSignatureInput { + @Field() + @IsString() + listId!: string + + @Field() + @IsNumber() + pageNumber!: number + + @Field() + @IsString() + nationalId!: string +} diff --git a/libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts b/libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts index 1570b1795901..a1f783de22de 100644 --- a/libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts +++ b/libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts @@ -32,6 +32,8 @@ import { SignatureCollectionCancelListsInput } from './dto/cencelLists.input' import { SignatureCollectionIdInput } from './dto/collectionId.input' import { SignatureCollectionCanSignInput } from './dto/canSign.input' import { SignatureCollectionAddListsInput } from './dto/addLists.input' +import { SignatureCollectionListBulkUploadInput } from './dto/bulkUpload.input' +import { SignatureCollectionUploadPaperSignatureInput } from './dto/uploadPaperSignature.input' @UseGuards(IdsUserGuard, ScopesGuard, UserAccessGuard) @Resolver() @Audit({ namespace: '@island.is/api/signature-collection' }) @@ -172,4 +174,18 @@ export class SignatureCollectionResolver { ): Promise { return this.signatureCollectionService.add(input, user) } + + @Scopes(ApiScope.signatureCollection) + @AccessRequirement(OwnerAccess.RestrictActor) + @Mutation(() => SignatureCollectionSuccess) + @Audit() + async signatureCollectionUploadPaperSignature( + @CurrentUser() user: User, + @Args('input') input: SignatureCollectionUploadPaperSignatureInput, + ): Promise { + return this.signatureCollectionService.candidacyUploadPaperSignature( + input, + user, + ) + } } diff --git a/libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts b/libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts index 6478b66b7981..c7cd95b72e88 100644 --- a/libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts +++ b/libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts @@ -16,6 +16,8 @@ import { SignatureCollectionCancelListsInput } from './dto/cencelLists.input' import { SignatureCollectionIdInput } from './dto/collectionId.input' import { SignatureCollectionAddListsInput } from './dto/addLists.input' import { SignatureCollectionOwnerInput } from './dto/owner.input' +import { SignatureCollectionListBulkUploadInput } from './dto/bulkUpload.input' +import { SignatureCollectionUploadPaperSignatureInput } from './dto/uploadPaperSignature.input' @Injectable() export class SignatureCollectionService { @@ -130,4 +132,14 @@ export class SignatureCollectionService { user, ) } + + async candidacyUploadPaperSignature( + input: SignatureCollectionUploadPaperSignatureInput, + user: User, + ): Promise { + return await this.signatureCollectionClientService.candidacyUploadPaperSignature( + user, + input, + ) + } } diff --git a/libs/clients/signature-collection/src/lib/signature-collection.service.ts b/libs/clients/signature-collection/src/lib/signature-collection.service.ts index 04cd1a23e53b..d9df57925283 100644 --- a/libs/clients/signature-collection/src/lib/signature-collection.service.ts +++ b/libs/clients/signature-collection/src/lib/signature-collection.service.ts @@ -268,6 +268,34 @@ export class SignatureCollectionClientService { return mapSignature(newSignature) } + async candidacyUploadPaperSignature( + auth: User, + { + listId, + nationalId, + pageNumber, + }: { listId: string; nationalId: string; pageNumber: number }, + ): Promise { + const newSignature = await this.getApiWithAuth( + this.listsApi, + auth, + ).medmaelalistarIDMedmaeliBulkPost({ + medmaeliBulkRequestDTO: { + medmaeli: [ + { + kennitala: nationalId, + bladsida: pageNumber, + }, + ], + }, + iD: parseInt(listId), + }) + + return { + success: !!newSignature.medmaeliKenn?.includes(nationalId), + } + } + async unsignList(listId: string, auth: User): Promise { const { signatures } = await this.getSignee(auth) const activeSignature = signatures?.find((signature) => signature.valid)