Poll Rest
Overview
The Poll Rest module provides a REST endpoint to retrieve and submit choices or votes based on the Poll module.
Requirements
Post-Installation
- Enable poll, rest, and poll_rest modules.
- Head over to /admin/config/services/rest and enable the poll vote resource.
- Enable the GET, POST, DELETE method.
Usage
GET
The implementation of GET verbose can response options or votes from a poll.
Request options
curl -v http://locahost/api/v1/poll/1?query=choices
Response options
- `chid`: is the choice id.
- `name`: is the name of the option.
- `action`: is the uri to request a vote of a choice
{
"raw_question":"What development methodology do you use??",
"pid":"1",
"user_vote":null,
"choices":[
{
"chid":4,
"name":"KanBan",
},
{
"chid":5,
"name":"RUP",
}]
}
Requests votes
curl -v http://locahost/api/v1/poll/1?query=votes
Response votes
{
"raw_question":"What development methodology do you use??",
"total_votes":"1",
"pid":"1",
"user_vote":null,
"results":[
{
"choice":"RUP",
"display_value":"100% (1 vote)",
"value":"1",
"percentage":100,
"is_current_selection":false
},
{
"choice":"KanBan",
"display_value":"0% (0 votes)",
"value":0,
"percentage":0,
"is_current_selection":false
}]
}
POST
The implementation of POST verbose is use to vote a choice.
Implements some validation, for example, if user is Allowed to Vote.
Request
curl -d '{"chid":"1"}' -H "Content-Type: application/json" -X POST http://locahost/api/v1/poll/1/vote
Response
{
"error": false
}
DELETE
The implementation of DELETE verbose is use to cancel a vote of a User.
Implements some validation, for example, if user is Allowed to cancel his vote.
Request
curl -X DELETE http://locahost/api/v1/poll/1
Response
{
"error": false
}
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 1.0.0-alpha4 | Pre-release | Oct 8, 2024 | |||
| 1.0.0-alpha3 | Pre-release | Oct 3, 2024 | |||
| 1.0.0-alpha2 | Pre-release | Oct 1, 2024 |