2019-11-27 20:55:59 +01:00
|
|
|
# API example
|
|
|
|
after having setup your project and database, and having a local server running you can rest these commands
|
2019-11-28 14:16:56 +01:00
|
|
|
## get Swagger configuration
|
|
|
|
|
|
|
|
```
|
|
|
|
GET
|
|
|
|
http://127.0.0.1:8000/api/doc.json
|
|
|
|
```
|
|
|
|
|
|
|
|
## create a poll
|
2019-11-28 16:48:35 +01:00
|
|
|
```http request
|
|
|
|
POST http://127.0.0.1:8000/api/v1/poll/new
|
2019-11-28 14:16:56 +01:00
|
|
|
Content-Type:"application/json"
|
|
|
|
|
2019-11-28 16:48:35 +01:00
|
|
|
{
|
|
|
|
"title": "un coup à boire",
|
|
|
|
"description": "et on boit quoi?",
|
|
|
|
"kind": "text",
|
|
|
|
"custom_url": "this-is-sparta",
|
|
|
|
"password":"hah",
|
|
|
|
"owner": {
|
|
|
|
"email": "contact@cipherbliss.com",
|
|
|
|
"pseudo": "cipherbliss crée un sondage par postman"
|
|
|
|
},
|
|
|
|
"choices_to_create": [ "cappou" ,"thé", "café", "vodka" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## get configuration of existing poll, protected with a password
|
2019-11-28 14:16:56 +01:00
|
|
|
|
|
|
|
|
2019-11-28 16:48:35 +01:00
|
|
|
|
|
|
|
```http request
|
|
|
|
GET http://127.0.0.1:8000/api/v1/poll/1
|
|
|
|
Content-Type:"application/json"
|
|
|
|
{
|
|
|
|
"password_input": "there_is_my_pass"
|
|
|
|
}
|
|
|
|
|
2019-11-28 14:16:56 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## add a vote to an existing poll
|
2019-11-28 16:48:35 +01:00
|
|
|
```http request
|
|
|
|
POST http://127.0.0.1:8000/api/v1/poll/1/vote
|
2019-11-28 14:16:56 +01:00
|
|
|
Content-Type:"application/json"
|
2019-11-27 20:55:59 +01:00
|
|
|
{
|
2019-11-28 17:10:21 +01:00
|
|
|
"pseudo": "tktest",
|
|
|
|
"email": "testing_vote_people@tktest.com",
|
|
|
|
"votes": [
|
|
|
|
{
|
|
|
|
"choice_id": 5,
|
|
|
|
"value": "no"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"choice_id": 6,
|
|
|
|
"value": "maybe"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"choice_id": 7,
|
|
|
|
"value": "yes"
|
|
|
|
}
|
|
|
|
]
|
2019-11-27 20:55:59 +01:00
|
|
|
}
|
|
|
|
```
|