diff --git a/API.md b/API.md new file mode 100644 index 0000000..1f597f7 --- /dev/null +++ b/API.md @@ -0,0 +1,68 @@ +# VerlainePoll's API + +## Methods + +### Create a poll +``` +POST /polls +``` + +| Field | Description | Optional | +| -------------- | ------------------------------------ | ---------- | +| `title` | The question. | no | +| `options` | All the options. Array of strings. | no | +| `settings` | A Settings object. | yes | + +Return a Poll. + +### Retrieve a poll + +``` +GET /polls/:id +``` + +Return a Poll. + +### Vote + +``` +POST /polls/:id/vote +``` +| Field | Description | Optional | +| -------------- | -------------------------------------------- | ---------- | +| `options` | Options you want to vote for. Array of ids. | no | + +Return a Poll. + +### Delete a poll + +``` +DELETE /polls/:id +``` + +Return a Poll. + +## Entities + +### Poll + +| Attribute | Description | Nullable | +| --------------- | ------------------------------------ | ---------- | +| `id` | | no | +| `title` | The question. | no | +| `options` | All the options. Array of Options. | no | +| `settings` | A Settings object. | no | +| `creation_date` | Creation date. | no | + +### Options + +| Attribute | Description | Nullable | +| --------------- | ------------------------------------ | ---------- | +| `id` | | no | +| `label` | The option. | no | + +### Settings + +| Attribute | Description | Nullable | +| --------------- | ------------------------------------ | ---------- | +| `unique_ip` | One vote per IP address. Boolean. | yes | diff --git a/README.md b/README.md index f32fa59..300c44c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Clone the repository : mkdir db && touch db/polls.db && composer install ``` -Uncomment the dba extention in `php.ini` : +Uncomment the `dba` extention in `php.ini` : ``` extension=dba ``` @@ -25,3 +25,5 @@ location / ``` ## API + +See [API.md](API.md). \ No newline at end of file