Poll API¶
Poll API will hold preferences related to the users.
Poll Resource¶
-
class
v1.resources.poll.PollResource¶ PollResource Class
Note
Allowed Methods: GET / POST / PUT / DELETE
GET Method¶
-
PollResource.on_get(req, resp, pk=None)¶ PollResource GET Method
Request
Method:
GETURL 1: https://dev.api.ranenetwork.com/poll/v1/poll[/poll_id | poll_name]
Response Object:
{ "status_code": 200, "request_id": <Request UUID>, "data": [<Array, Array of Poll list>, <JSON, JSON object of response>] }
Example:
{ "status_code": 200, "request_id": "189b5a25-2128-4e65-b856-11829a3c435f", "data": [ { "version": "v1.0", "questions": 1, "metadata": {}, "begin_on": 1595606224, "id": 1, "updated_by": 1, "created_by": 1, "text": "question 1", "restrictions": {}, "name": "poll", "end_on": 1595606224, "status": 0, "updated_on": 1595606379, "created_on": 1595606379, "values": [ { "choice1": "What?" }, { "choice2": "How?" }, { "choice3": "When?" }, { "choice4": "What?" } ] }, { "version": "v1.0", "questions": 1, "metadata": {}, "begin_on": 1595606223, "id": 2, "updated_by": 1, "created_by": 1, "text": "question 2", "restrictions": {}, "name": "poll", "end_on": 1595606223, "status": 0, "updated_on": 1595606385, "created_on": 1595606385, "values": [ { "choice1": "What?" }, { "choice2": "How?" }, { "choice3": "When?" }, { "choice4": "What?" } ] // "meta" info will only be displayed when a poll_id or poll_name is passed "meta": { "voted": { "choice1": 0, "choice2": 1, "choice3": 0, "choice4": 0 } } } ] }
POST Method¶
-
PollResource.on_post(req, resp)¶ PollResource POST Method
Request
Method:
POST
Request Object:
{ "text": <String, Poll Text>, "values": <JSON, JSON object of choices> }
Example:
{ "text": "question 3", "values": [ { "choice1": "What?" }, { "choice2": "How?" }, { "choice3": "When?" }, { "choice4": "What?" } ] }
Response
Response Object:
{ "status_code": 201, "request_id": <Request UUID>, "data": {} }
PUT Method¶
-
PollResource.on_put(req, resp, pk: int)¶ PollResource PUT Method
Request
Method:
PUTURL: https://dev.api.ranenetwork.com/poll/v1/poll/<poll_id>
Request Object:
{ "text": <String, Poll Question text>, "values": <Array, Array of Poll Values in JSON format> }
Example:
{ "text": "what is my first name?", "values": [ { "choice1": "John" }, { "choice2": "Doe" } ] }
Response:
**Response Object**:: { "status_code": 200, "request_id": <Request UUID>, "data": {} }
DELETE Method¶
-
PollResource.on_delete(req, resp, pk: int)¶ PollResource Delete Method
Request
Method:
DELETEURL: https://dev.api.ranenetwork.com/poll/v1/poll/<poll_id>
Response:
Response Object:
{ "status_code": 204, "request_id": <Request UUID>, }
Vote Resource¶
-
class
v1.resources.vote.VoteResource¶ VoteResource Class
Note
Allowed Methods: POST
-
on_get(req, resp, pk=None)¶ VoteResource POST Method
Request
Method:
GET
Response
Response Object:
{ "status_code": 200, "request_id": "11f22b1b-f003-41ff-ab83-dce447202100", "data": <Object of counts and percentage> }
Example:
{ "status_code": 200, "request_id": "11f22b1b-f003-41ff-ab83-dce447202100", "data": { "counts": [ { "choice1": 2, "text": "Hello2" }, { "choice2": 2, "text": "World2" } ], "percentage": [ { "choice1": 50, "text": "Hello2" }, { "choice2": 50, "text": "World2" } ], "question": "Question sample 1?" } }
-
POST Method¶
-
VoteResource.on_post(req, resp, pk=None)¶ VoteResource POST Method
Request
Method:
POST
Request Object:
Headers: { Cookies: "WVBACKEND=<wv_backend_cookie>", Content-Type: "application/json" } Body: { "options": Array of strings, "location": string, "isEnterpriseUser": boolean }
Example:
{ "options": ["Choice1"], "location": "/", "isEnterpriseUser": true }
Response
Response Object:
{ "status_code": 200, "request_id": "11f22b1b-f003-41ff-ab83-dce447202100", "data": <Object of counts and percentage> }
Example:
{ "status_code": 200, "request_id": "11f22b1b-f003-41ff-ab83-dce447202100", "data": { "counts": [ { "choice1": 2, "text": "Hello2" }, { "choice2": 2, "text": "World2" } ], "percentage": [ { "choice1": 50, "text": "Hello2" }, { "choice2": 50, "text": "World2" } ], "question": "Question sample 1?" } }