-
Notifications
You must be signed in to change notification settings - Fork 1
Poll API
Anton Alexeev edited this page Jul 9, 2018
·
10 revisions
Get List of polls
Query params for list filtering:
id : integer
active : tinyint
anonymous : tinyint
position : integer
title : string
closed_at : date
closed_at_from:date
closed_at_to: date
{
"current_page":1,
"data":[
{
"id":1,
"title":"Who is the best football player in the world?",
"type":"OrangeShadow\\Polls\\Types\\SingleVote",
"active":1,
"anonymous":0,
"position":1,
"closed_at":null,
"created_at":"2018-03-15 21:48:25",
"updated_at":"2018-03-15 21:48:25"
},...
],
"first_page_url":"http:\/\/localhost\/pollpage=1",
"from":1,
"last_page":1,
"last_page_url":"http:\/\/localhost\/poll?page=1",
"next_page_url":null,
"path":"http:\/\/localhost\/poll",
"per_page":50,
"prev_page_url":null,
"to":2,
"total":2
}
Make a poll
active : tinyint
anonymous : tinyint
position : integer
title* : string
type* : string
closed_at : date
closed_at_from:date
closed_at_to: date
field with * are required
{
"id":1,
"title":"Who is the best football player in the world?",
"type":"OrangeShadow\\Polls\\Types\\SingleVote",
"active":1,
"anonymous":0,
"position":1,
"closed_at":null,
"created_at":"2018-03-15 21:48:25",
"updated_at":"2018-03-15 21:48:25"
}
Get a poll json for admin
{
"id":1,
"title":"Who is the best football player in the world?",
"type":"OrangeShadow\\Polls\\Types\\SingleVote",
"active":1,
"anonymous":0,
"position":1,
"closed_at":null,
"created_at":"2018-03-15 21:48:25",
"updated_at":"2018-03-15 21:48:25"
}
Get a poll json for users
{
poll: {
"id":1,
"title":"Who is the best football player in the world?",
"type":"OrangeShadow\\Polls\\Types\\SingleVote",
"active":1,
"anonymous":0,
"position":1,
"closed_at":null,
"created_at":"2018-03-15 21:48:25",
"updated_at":"2018-03-15 21:48:25"
},
options:[
{
id: number,
title: string
}, ...
],
results:{
"option_id": {
"title": string
"voter_count": numeric,
"total_weight":numeric,
"percent":numeric
},...
}
}
Update a poll
active : tinyint
anonymous : tinyint
position : integer
title* : string
type* : string
closed_at : date
closed_at_from:date
closed_at_to: date
field with * are required
{
"id":1,
"title":"Who is the best football player in the world?",
"type":"OrangeShadow\\Polls\\Types\\SingleVote",
"active":1,
"anonymous":0,
"position":1,
"closed_at":null,
"created_at":"2018-03-15 21:48:25",
"updated_at":"2018-03-15 21:48:25"
}
Delete a poll
{"success":true}
Make a vote
options*: array
field with * are required
example response from variable poll
{
"success":true,
"results": {
"10": {
"title":"Opportunities for professional development",
"voter_count":1,
"total_weight":6,
"percent":100
},
"8": {
"title":"The compensation and benefits offered",
"voter_count":1,
"total_weight":5,
"percent":83.33
},
"9": {
"title":"The languages, frameworks, and other technologies I'd be working with",
"voter_count":1,
"total_weight":4,
"percent":66.67
},
"11": {
"title":"The office environment or company culture",
"voter_count":1,
"total_weight":3,
"percent":50
},
"13": {
"title":"The industry that I'd be working in",
"voter_count":1,"total_weight":2,"percent":33.33
},
"12": {
"title":"The opportunity to work from home\/remotely",
"voter_count":1,
"total_weight":1,
"percent":16.67
}
}
}