Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Poll Rest

No security coverage Under active development 2 sites

This module provides a REST API for interacting with polls, allowing you to retrieve poll choices and votes, and to cast or cancel votes. It leverages the core REST module to expose these functionalities.

Overview

The Poll Rest module provides a REST endpoint to retrieve and submit choices or votes based on the Poll module.

Requirements

Post-Installation

  1. Enable poll, rest, and poll_rest modules.
  2. Head over to /admin/config/services/rest and enable the poll vote resource.
  3. 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
}

Ask your assistant about Poll Rest

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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

Tracked releases
5
Tracked since
Aug 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
1.0.0-alpha4 Pre-release 9–11 Oct 8, 2024
1.0.0-alpha3 Pre-release 9–11 Oct 3, 2024
1.0.0-alpha2 Pre-release 9–11 Oct 1, 2024
1.0.0-alpha1 Pre-release 9–11 Sep 13, 2024
1.0.x-dev Dev 9–11 Aug 9, 2024