Skip to content

Vote Events Endpoints

Wei Zhe edited this page Dec 8, 2024 · 1 revision

Types

Vote Event

{
    "voteEvent": {
        "id": "number",
        "title": "string",
        "startTime": "string (ISO 8601 DateTime)",
        "endTime": "string (ISO 8601 DateTime)",
        "voterManagement": {
            "hasInternalList": "boolean",
            "hasExternalList": "boolean",
            "registrationStartTime": "string (ISO 8601 DateTime)",
            "registrationEndTime": "string (ISO 8601 DateTime)"
        },
        "voteConfig": {
            "maxVotes": "number",
            "minVotes": "number",
            "isRandomOrder": "boolean",
            "instructions": "string",
            "displayType": "string"
        },
        "resultsFilter": {
            "areResultsPublished": "boolean",
            "displayLimit": "number",
            "showRank": "boolean",
            "showVotes": "boolean",
            "showPoints": "boolean",
            "showPercentage": "boolean",
            "studentWeight": "number",
            "adviserWeight": "number",
            "mentorWeight": "number",
            "administratorWeight": "number",
            "publicWeight": "number"
        }
    }
}

External Voter

{
    "externalVoter": {
        "id": "string",
        "voteEventId": "number",
    }
}

Vote

{
    "vote": {
        "id": "number",
        "voteEventId": "number",
        "projectId": "number",
        "userId": "number (optional)",
        "externalVoterId": "string (optional)",
    }
}

Endpoints

Get all vote events

GET /api/vote-events

  • Authorization Required: authorizeVoter

Description:
Returns an array of vote events the voter has access to.


Get a single vote event

GET /api/vote-events/:voteEventId

  • Authorization Required: authorizeVoter + authorizeVoterOfVoteEvent

Description:
Returns the vote event with the specified voteEventId.


Create a new vote event

POST /api/vote-events

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "voteEvent": {
            "title": "string",
            "startTime": "string",
            "endTime": "string"
        }
    }

Description:
Creates a new vote event and returns the created vote event.


Set voter management for a vote event

POST /api/vote-events/:voteEventId/voter-management

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "voterManagement": {
            "hasInternalList": "boolean",
            "hasExternalList": "boolean",
            "registrationStartTime": "string",
            "registrationEndTime": "string",
            "copyInternalVoteEventId": "number (optional)",
            "copyExternalVoteEventId": "number (optional)"
        }
    }

Description:
Sets the voter management settings for the specified vote event. Returns the vote event with updated voter management.


Delete a vote event

DELETE /api/vote-events/:voteEventId

  • Authorization Required: authorizeAdmin

Description:
Deletes the specified vote event and returns the deleted vote event.


Register for a vote event

POST /api/vote-events/:voteEventId/register

  • Authorization Required: authorizeVoter

Description:
Registers the user as an internal voter for the specified vote event.


Get all internal voters of a vote event

GET /api/vote-events/:voteEventId/voter-management/internal-voters

  • Authorization Required: authorizeAdmin

Description:
Returns an array of internal voters (users) of the specified vote event.


Add an internal voter to a vote event

POST /api/vote-events/:voteEventId/voter-management/internal-voters

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "email": "string"
    }

Description:
Adds an internal voter to the specified vote event and returns the added voter (user object).


Add multiple internal voters to a vote event

POST /api/vote-events/:voteEventId/voter-management/internal-voters/batch

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "emails": ["string"]
    }

Description:
Adds multiple internal voters to the specified vote event and returns all internal voters of the event.


Remove an internal voter from a vote event

DELETE /api/vote-events/:voteEventId/voter-management/internal-voters/:internalVoterId

  • Authorization Required: authorizeAdmin

Description:
Removes the specified internal voter from the vote event, including their votes. Returns the deleted voter.


Get all external voters of a vote event

GET /api/vote-events/:voteEventId/voter-management/external-voters

  • Authorization Required: authorizeAdmin

Description:
Returns all external voters of the specified vote event.


Add an external voter to a vote event

POST /api/vote-events/:voteEventId/voter-management/external-voters

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "voterId": "string"
    }

Description:
Adds an external voter to the specified vote event and returns the added voter.


Add multiple external voters to a vote event

POST /api/vote-events/:voteEventId/voter-management/external-voters/batch

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "voterIds": ["string"]
    }

Description:
Adds multiple external voters to the specified vote event and returns all external voters of the event.


Generate external voter IDs

POST /api/vote-events/:voteEventId/voter-management/external-voters/generate

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "amount": "number",
        "length": "number"
    }

Description:
Generates external voter IDs and returns all external voters of the specified vote event.


Remove an external voter from a vote event

DELETE /api/vote-events/:voteEventId/voter-management/external-voters/:externalVoterId

  • Authorization Required: authorizeAdmin

Description:
Removes the specified external voter from the vote event and returns the deleted voter.


Get all candidates of a vote event

GET /api/vote-events/:voteEventId/candidates

  • Authorization Required: authorizeVoter + authorizeVoterOfVoteEvent

Description:
Returns an array of candidates for the specified vote event.


Add a candidate to a vote event

POST /api/vote-events/:voteEventId/candidates

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "projectId": "number"
    }

Description:
Adds a candidate (based on the project ID) to the specified vote event and returns the added candidate.


Add multiple candidates to a vote event

POST /api/vote-events/:voteEventId/candidates/batch

  • Authorization Required: authorizeAdmin

Request Body:

    {
        "cohort": "number",
        "achievement": "string"
    }

Description:
Adds multiple candidates to the specified vote event based on the cohort and achievement. Returns all candidates of the vote event.


Remove a candidate from a vote event

DELETE /api/vote-events/:voteEventId/candidates/:candidateId

  • Authorization Required: authorizeAdmin

Description:
Deletes the specified candidate from the vote event and returns the deleted candidate.


Get the votes of the current voter

GET /api/vote-events/:voteEventId/votes

  • Authorization Required: authorizeVoter + authorizeVoterOfVoteEvent

Description:
Returns the votes cast by the current voter for the specified vote event.


Get all votes of a vote event

GET /api/vote-events/:voteEventId/votes/all

  • Authorization Required: authorizeAdmin

Description:
Returns all votes cast in the specified vote event.


Submit votes for a vote event

POST /api/vote-events/:voteEventId/votes

  • Authorization Required: authorizeVoter + authorizeVoterOfVoteEvent

Request Body:

    {
        "projectIds": ["number"]
    }

Description:
Submits the voter's votes for the specified vote event. Returns the submitted votes.


Delete a vote from a vote event

DELETE /api/vote-events/:voteEventId/votes/:voteId

  • Authorization Required: authorizeAdmin

Description:
Deletes the specified vote from the vote event and returns the deleted vote.


Get the published results of a vote event

GET /api/vote-events/:voteEventId/results

  • Authorization Required: authorizeVoter + authorizeVoterOfVoteEvent

Description:
Returns the published results of the specified vote event.

NUS Skylab v2 - Backend

Introduction

Project Organization

Project Requirements

Endpoints

Clone this wiki locally