Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(signature-collection): Endpoint for parliamentary candidate list overview #16487

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
SignatureCollectionSignedList,
SignatureCollectionSignee,
} from './models'
import { SignatureCollectionListSummary } from './models/areaSummaryReport.model'

@UseGuards(IdsUserGuard, ScopesGuard, UserAccessGuard)
@Resolver()
Expand Down Expand Up @@ -207,4 +208,16 @@ export class SignatureCollectionResolver {
signee.candidate?.id,
)
}

@Scopes(ApiScope.signatureCollection)
@IsOwner()
@AllowManager()
@Query(() => SignatureCollectionListSummary)
@Audit()
async signatureCollectionListOverview(
@CurrentUser() user: User,
@Args('input') input: SignatureCollectionListIdInput,
): Promise<SignatureCollectionListSummary> {
return this.signatureCollectionService.listOverview(user, input.listId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { SignatureCollectionAddListsInput } from './dto/addLists.input'
import { SignatureCollectionUploadPaperSignatureInput } from './dto/uploadPaperSignature.input'
import { SignatureCollectionCanSignFromPaperInput } from './dto/canSignFromPaper.input'
import { SignatureCollectionCollector } from './models/collector.model'
import { SignatureCollectionListSummary } from './models/areaSummaryReport.model'

@Injectable()
export class SignatureCollectionService {
Expand Down Expand Up @@ -187,4 +188,14 @@ export class SignatureCollectionService {
candidateId,
)
}

async listOverview(
user: User,
listId: string,
): Promise<SignatureCollectionListSummary> {
return await this.signatureCollectionClientService.getListOverview(
user,
listId,
)
}
}
35 changes: 35 additions & 0 deletions libs/clients/signature-collection/src/clientConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,41 @@
}
}
},
"/Medmaelalistar/{ID}/Info": {
"get": {
"tags": ["Medmaelalistar"],
"summary": "Skilar yfirliti fyrir ákveðinn meðmælalista",
"description": "Framboð geta sótt yfirlit fyrir sína eigin lista",
"parameters": [
{
"name": "ID",
"in": "path",
"description": "ID meðmælalista",
"required": true,
"schema": { "type": "integer", "format": "int32" }
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MedmaelalistiExtendedDTO"
}
}
}
},
"204": { "description": "No Content" },
"400": {
"description": "Bad Request",
"content": {
"application/json": { "schema": { "type": "string" } }
}
}
}
}
},
"/Medmaelalistar/{ID}/Medmaeli": {
"get": {
"tags": ["Medmaelalistar"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { mapCandidate } from './types/candidate.dto'
import { Slug } from './types/slug.dto'
import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools'
import { SignatureCollectionSharedClientService } from './signature-collection-shared.service'
import { ListSummary, mapListSummary } from './types/areaSummaryReport.dto'
type Api = MedmaelalistarApi | MedmaelasofnunApi | MedmaeliApi | FrambodApi

@Injectable()
Expand Down Expand Up @@ -561,4 +562,15 @@ export class SignatureCollectionClientService {
})) ?? []
)
}

async getListOverview(auth: User, listId: string): Promise<ListSummary> {
const summary = await this.getApiWithAuth(
this.listsApi,
auth,
).medmaelalistarIDInfoGet({
iD: parseInt(listId),
})

return mapListSummary(summary)
}
}
Loading