From 464e91b444b6af9f3fa10906cfb32576c87deb8f Mon Sep 17 00:00:00 2001 From: dartcafe Date: Sun, 14 Jun 2020 22:42:37 +0200 Subject: Updated doc --- docs/API_v1.0.md | 137 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 77 insertions(+), 60 deletions(-) (limited to 'docs') diff --git a/docs/API_v1.0.md b/docs/API_v1.0.md index ccdbc502..4a5843fd 100644 --- a/docs/API_v1.0.md +++ b/docs/API_v1.0.md @@ -5,83 +5,100 @@ Parameters in the body override the URL-parameter Base URL for all calls: /index.php/apps/polls/api/1.0/ Example calls: * Gets all comments of poll no. 1 -`https://username:password@nextcloud.local/index.php/apps/polls/api/1.0/comments/1` +`https://username:password@nextcloud.local/index.php/apps/polls/api/1.0/poll/1/comments` ```bash -curl -u username:password \ - -X GET https://nextcloud.local/index.php/apps/polls/api/1.0/comments/1 +`curl -u username:password -X GET https://nextcloud.local/index.php/apps/polls/api/1.0/poll/1/comments` ``` -You can add a Body with the parameters, which overrides the URL-Parameter -`https://username:password@nextcloud.local/index.php/apps/polls/api/1.0/comments/1` +# Comments +## List all comments by poll +GET `/index.php/apps/polls/api/1.0/poll/{pollId}/comments` -```json -[ - { - "pollId": 2, - }, +### Return HTTP status 200 +Response body contains all comments of the poll with {pollId} -] -``` +### Return HTTP status 403 - Forbidden +Authorization is missing use correct username:passwort -This will return all comments from poll no. 2 +### Return HTTP status 404 - Not found +commentId not found -```json -[ - { - "token": "X3jXHb8WHLMb9MRg", - }, +## Post a new comment +POST `/index.php/apps/polls/api/1.0/comment` -] +Data +```json +{ + "message": "Comment text", + "pollId": 1, +} ``` +### Return HTTP status 201 - Created +Comment successfully created +Response Body contains the comment as json -This returns all comments from the poll which can be called with the token "X3jXHb8WHLMb9MRg" +### Return HTTP status 403 - Forbidden +Authorization is missing use correct username:passwort +### Return HTTP status 404 - Not found +pollId not found -# Comments -## Get comments -### Get all Comments by poll as a nextcloud user -GET `/index.php/apps/polls/api/1.0/comments/{pollId}` +## Delete a comment +DELETE `/index.php/apps/polls/api/1.0/comment/{commentId}` -### Post a comment -POST `/index.php/apps/polls/api/1.0/comments` +### Return HTTP status 200 +Response body contains the commentId -Body -```json -[ - { - "message": "Comment text", - "pollId": 1, - "token": "users's personal token" - }, - -] -``` +### Return HTTP status 403 - Forbidden +Authorization is missing, use correct username:passwort -DELETE `/index.php/apps/polls/api/1.0/comments/{commentId}` +### Return HTTP status 404 - Not found +commentId not found -Body -```json -[ - { - "commentId": 123, - "token": "users's personal token" - }, +# Options +## List all options by poll +GET `/index.php/apps/polls/api/1.0/poll/{pollId}/options` -] -``` +### Return HTTP status 200 +Response body contains all options of the poll with {pollId} -### Returns an array of Comment objects +### Return HTTP status 403 - Forbidden +Authorization is missing, use correct username:passwort + +### Return HTTP status 404 - Not found +optionId not found + +## Post a new option +POST `/index.php/apps/polls/api/1.0/option` + +Data ```json -[ - { - "id": 1, - "pollId": 1, - "userId": "Commenter's name", - "dt": "2020-01-21 14:01:01", - "timestamp": 1587468691, - "comment": "message", - "displayName": "Commenters's display name" - }, ... - -] +{ + "message": "Comment text", + "pollId": 1, +} ``` +### Return HTTP status 201 - Created +Comment successfully created +Response Body contains the option as json + +### Return HTTP status 403 - Forbidden +Authorization is missing use correct username:passwort + +### Return HTTP status 404 - Not found +pollId not found + +### Return HTTP status 409 - Conflict +The option already exists in this poll + +## Delete an option +DELETE `/index.php/apps/polls/api/1.0/option/{optionId}` + +### Return HTTP status 200 - OK +Response body contains the optionId + +### Return HTTP status 403 - Forbidden +Authorization is missing use correct username:passwort + +### Return HTTP status 404 - Not found +optionId not found -- cgit v1.2.3