The Poll Service is a RESTful API for creating, retrieving, and deleting polls. It manages poll data and interacts with the Vote Service to keep vote counts up to date.
-
Service port: 8082
-
Database port: 5432
The database schema includes the following tables:
CREATE TABLE polls
(
poll_id UUID PRIMARY KEY,
title VARCHAR(255),
description TEXT,
nof_answers_allowed INT,
creator_id UUID,
group_id VARCHAR(255),
time_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
time_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deadline TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE voting_item_options
(
voting_item_id SERIAL PRIMARY KEY,
poll_id UUID REFERENCES polls (poll_id),
description TEXT,
vote_count INT
);
BASE URL: /api/poll
.
All calls to this service must start with the base URL. Any additional URL fields will be specified if relevant.
-
Method: POST
-
Description: Creates a new poll.
-
Request Body:
{
"title": "string",
"description": "string",
"nofAnswersAllowed": 0,
"creatorId": "string",
"groupId": "string",
"deadline": "2024-07-27T00:00:00Z",
"votingItems": [
"string",
"string",
"string"
]
}
-
Constraints:
-
nofAnswersAllowed
- a number between 0 and the number of voting options. -
deadline
- a time in the future.
-
-
Response:
{
"pollId": "uuid",
"title": "string",
"description": "string",
"nofAnswersAllowed": 0,
"creatorId": "string",
"creatorName": "string",
"creatorProfilePictureUrl": "string",
"groupId": "string",
"groupName": "string",
"groupProfilePictureUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z",
"timeUpdated": "2024-07-27T00:00:00Z",
"deadline": "2024-07-27T00:00:00Z",
"votingItems": [
{
"votingItemId": "uuid",
"votingItemOrdinal": 0,
"description": "string",
"voteCount": 0
}
]
}
- Response HTTP Status:
-
200 OK
– Successfully completed request. -
201 Created
– Poll created successfully. -
400 Bad Request
– Invalid input data.
-
-
Method: GET
-
Endpoint:
/all
-
Description: Retrieves a list of all polls.
-
Response:
[
{
"pollId": "uuid",
"title": "string",
"description": "string",
"nofAnswersAllowed": 0,
"creatorId": "string",
"creatorName": "string",
"creatorProfilePictureUrl": "string",
"groupId": "string",
"groupName": "string",
"groupProfilePictureUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z",
"timeUpdated": "2024-07-27T00:00:00Z",
"deadline": "2024-07-27T00:00:00Z",
"votingItems": [
{
"votingItemId": "uuid",
"votingItemOrdinal": 0,
"description": "string",
"voteCount": 0
}
]
}
]
- Response HTTP Status:
200 OK
– List of polls successfully retrieved.
-
Method: GET
-
Endpoint:
/by-poll-id
-
Description: Retrieves a specific poll by its ID.
-
Query Parameters:
pollId
(UUID) – The ID of the poll to retrieve.
-
Response:
{
"pollId": "uuid",
"title": "string",
"description": "string",
"nofAnswersAllowed": 0,
"creatorId": "string",
"creatorName": "string",
"creatorProfilePictureUrl": "string",
"groupId": "string",
"groupName": "string",
"groupProfilePictureUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z",
"timeUpdated": "2024-07-27T00:00:00Z",
"deadline": "2024-07-27T00:00:00Z",
"votingItems": [
{
"votingItemId": "uuid",
"votingItemOrdinal": 0,
"description": "string",
"voteCount": 0
}
]
}
- Response HTTP Status:
-
200 OK
– Poll successfully retrieved. -
404 Not Found
– Poll with the specified ID not found.
-
-
Method: GET
-
Endpoint:
/by-group-id
-
Description: Retrieves all group polls by group ID.
-
Query Parameters:
groupId
(string) – The ID of the group.
-
Response:
[
{
"pollId": "uuid",
"title": "string",
"description": "string",
"nofAnswersAllowed": 0,
"creatorId": "string",
"creatorName": "string",
"creatorProfilePictureUrl": "string",
"groupId": "string",
"groupName": "string",
"groupProfilePictureUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z",
"timeUpdated": "2024-07-27T00:00:00Z",
"deadline": "2024-07-27T00:00:00Z",
"votingItems": [
{
"votingItemId": "uuid",
"votingItemOrdinal": 0,
"description": "string",
"voteCount": 0
}
]
}
]
- Response HTTP Status:
-
200 OK
– Polls successfully retrieved. -
404 Not Found
– Group with the specified ID not found. -
404 Not Found
– Poll with the specified ID not found.
-
-
Method: GET
-
Endpoint:
/by-user-id
-
Description: Retrieves all user polls by user ID.
-
Query Parameters:
userId
(UUID) – The ID of the user.
-
Response:
[
{
"pollId": "uuid",
"title": "string",
"description": "string",
"nofAnswersAllowed": 0,
"creatorId": "string",
"creatorName": "string",
"creatorProfilePictureUrl": "string",
"groupId": "string",
"groupName": "string",
"groupProfilePictureUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z",
"timeUpdated": "2024-07-27T00:00:00Z",
"deadline": "2024-07-27T00:00:00Z",
"votingItems": [
{
"votingItemId": "uuid",
"votingItemOrdinal": 0,
"description": "string",
"voteCount": 0
}
]
}
]
- Response HTTP Status:
-
200 OK
– Polls successfully retrieved. -
404 Not Found
– User with the specified ID not found. -
404 Not Found
– Poll with the specified ID not found.
-
-
Method: GET
-
Endpoint:
/by-multiple-group-ids
-
Description: Retrieves all multiple groups polls by groups IDs.
-
Query Parameters:
groupId
(List) – The ID of the group.
-
Response:
[
{
"pollId": "uuid",
"title": "string",
"description": "string",
"nofAnswersAllowed": 0,
"creatorId": "string",
"creatorName": "string",
"creatorProfilePictureUrl": "string",
"groupId": "string",
"groupName": "string",
"groupProfilePictureUrl": "string",
"timeCreated": "2024-07-27T00:00:00Z",
"timeUpdated": "2024-07-27T00:00:00Z",
"deadline": "2024-07-27T00:00:00Z",
"votingItems": [
{
"votingItemId": "uuid",
"votingItemOrdinal": 0,
"description": "string",
"voteCount": 0
}
]
}
]
- Response HTTP Status:
-
200 OK
– Polls successfully retrieved. -
404 Not Found
– Group with the specified ID not found. -
404 Not Found
– Poll with the specified ID not found.
-
-
Method: DELETE
-
Endpoint:
/by-poll-id
-
Description: Deletes a specific poll by its ID.
-
Request Body:
{
"pollId": "uuid",
"userId": "uuid",
"groupId": "string"
}
- Response:
{
"pollId": "uuid"
}
- Response HTTP Status:
-
200 OK
– Poll successfully deleted. -
404 Not Found
– Poll with the specified ID not found.
-
-
Method: GET
-
Endpoint:
/health
-
Description: Checks the health of the service.
-
Response:
{
"status": "Running",
"message": "Poll Management Service is up and running."
}
- Response HTTP Status:
200 OK
– Service is healthy.
-
Method: PUT
-
Endpoint:
/vote
-
Description: Updates the vote count for a specified voting item.
-
Request Body:
{
"votingItemId": "int",
"action": "add" // or "remove"
}
- Response:
{
"votingItemDescription": "string",
"voteCount": 0
}
- Response HTTP Status:
200 OK
– Vote count successfully updated.
-
Method: GET
-
Endpoint:
/vote
-
Description: Retrieve the vote count for a specified voting item.
-
Request Body:
{
"votingItemId": "int"
}
- Response:
{
"voteCount": "int"
}
- Response HTTP Status:
200 OK
– Vote count successfully retrieved.
-
Method: DELETE
-
Endpoint:
/by-group-id
-
Description: Deletes all group Polls from DB.
-
Request Body:
{
"groupId": "string"
}
- Response:
{
[
{
"pollId": "uuid"
}
]
}
- Response HTTP Status:
-
200 OK
– All Polls successfully deleted. -
404 Not Found
– Group with the specified ID not found.
-
-
400 Bad Request
– The request could not be understood or was missing required parameters. -
404 Not Found
– The specified resource could not be found. -
500 Internal Server Error
– An error occurred on the server.
-
Make sure to include the
Content-Type: application/json
header in your requests. -
Use valid UUIDs and ISO-8601 timestamps in your requests.