This commit is contained in:
dartcafe 2020-06-14 22:42:37 +02:00
Родитель 76cba400fc
Коммит 464e91b444
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CCE73CEF3035D3C8
1 изменённых файлов: 83 добавлений и 66 удалений

Просмотреть файл

@ -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`
```json
[
{
"pollId": 2,
},
]
```
This will return all comments from poll no. 2
```json
[
{
"token": "X3jXHb8WHLMb9MRg",
},
]
```
This returns all comments from the poll which can be called with the token "X3jXHb8WHLMb9MRg"
# Comments
## Get comments
### Get all Comments by poll as a nextcloud user
GET `/index.php/apps/polls/api/1.0/comments/{pollId}`
## List all comments by poll
GET `/index.php/apps/polls/api/1.0/poll/{pollId}/comments`
### Post a comment
POST `/index.php/apps/polls/api/1.0/comments`
### Return HTTP status 200
Response body contains all comments of the poll with {pollId}
Body
### Return HTTP status 403 - Forbidden
Authorization is missing use correct username:passwort
### Return HTTP status 404 - Not found
commentId not found
## Post a new comment
POST `/index.php/apps/polls/api/1.0/comment`
Data
```json
[
{
"message": "Comment text",
"pollId": 1,
"token": "users's personal token"
},
]
{
"message": "Comment text",
"pollId": 1,
}
```
### Return HTTP status 201 - Created
Comment successfully created
Response Body contains the comment as json
DELETE `/index.php/apps/polls/api/1.0/comments/{commentId}`
### Return HTTP status 403 - Forbidden
Authorization is missing use correct username:passwort
Body
### Return HTTP status 404 - Not found
pollId not found
## Delete a comment
DELETE `/index.php/apps/polls/api/1.0/comment/{commentId}`
### Return HTTP status 200
Response body contains the commentId
### Return HTTP status 403 - Forbidden
Authorization is missing, use correct username:passwort
### Return HTTP status 404 - Not found
commentId not found
# 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}
### 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
[
{
"commentId": 123,
"token": "users's personal token"
},
]
{
"message": "Comment text",
"pollId": 1,
}
```
### Return HTTP status 201 - Created
Comment successfully created
Response Body contains the option as json
### Returns an array of Comment objects
```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"
}, ...
### 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