Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,73 +27,71 @@
['name' => 'page#index', 'url' => '/not-found', 'verb' => 'GET', 'postfix' => 'notfound'],
['name' => 'page#index', 'url' => '/list/{id}', 'verb' => 'GET', 'postfix' => 'list'],
['name' => 'page#index', 'url' => '/vote/{id}', 'verb' => 'GET', 'postfix' => 'vote'],

['name' => 'page#vote_public', 'url' => '/s/{token}', 'verb' => 'GET', 'postfix' => 'public'],
['name' => 'page#vote_public', 'url' => '/poll/{token}', 'verb' => 'GET', 'postfix' => 'oldpublic'],

['name' => 'subscription#get', 'url' => '/subscription/{pollId}', 'verb' => 'GET'],
['name' => 'subscription#set', 'url' => '/subscription', 'verb' => 'POST'],

['name' => 'comment#getByToken', 'url' => '/comments/s/{token}', 'verb' => 'GET'],
['name' => 'comment#get', 'url' => '/comments/{pollId}', 'verb' => 'GET'],
['name' => 'comment#add', 'url' => '/comment/add', 'verb' => 'POST'],
['name' => 'comment#delete', 'url' => '/comment/delete', 'verb' => 'POST'],

['name' => 'vote#getByToken', 'url' => '/votes/get/s/{token}', 'verb' => 'GET'],
['name' => 'vote#setByToken', 'url' => '/vote/set/s', 'verb' => 'POST'],
['name' => 'vote#get', 'url' => '/votes/get/{pollId}', 'verb' => 'GET'],
['name' => 'vote#set', 'url' => '/vote/set', 'verb' => 'POST'],
// ['name' => 'vote#write', 'url' => '/vote/write/', 'verb' => 'POST'],
['name' => 'vote#delete', 'url' => '/votes/delete', 'verb' => 'POST'],

['name' => 'option#get', 'url' => '/options/get/{pollId}', 'verb' => 'GET'],
['name' => 'option#add', 'url' => '/option/add', 'verb' => 'POST'],
['name' => 'option#update', 'url' => '/option/update', 'verb' => 'POST'],
['name' => 'option#reorder', 'url' => '/option/reorder', 'verb' => 'POST'],
['name' => 'option#remove', 'url' => '/option/remove', 'verb' => 'POST'],
['name' => 'option#getByToken', 'url' => '/options/get/s/{token}', 'verb' => 'GET'],

['name' => 'poll#get', 'url' => '/polls/get/{pollId}', 'verb' => 'GET', 'postfix' => 'auth'],
['name' => 'poll#get', 'url' => '/polls/get/s/{token}', 'verb' => 'GET', 'postfix' => 'public'],
['name' => 'poll#add', 'url' => '/polls/add', 'verb' => 'POST'],
['name' => 'poll#update', 'url' => '/polls/update/{pollId}', 'verb' => 'PUT'],

['name' => 'poll#list', 'url' => '/polls/list', 'verb' => 'GET'],
['name' => 'poll#delete', 'url' => '/polls/delete/{pollId}', 'verb' => 'GET'],
['name' => 'poll#deletePermanently', 'url' => '/polls/delete/permanent/{pollId}', 'verb' => 'GET'],
['name' => 'poll#clone', 'url' => '/polls/clone/{pollId}', 'verb' => 'GET'],

['name' => 'option#add', 'url' => '/option', 'verb' => 'POST'],
['name' => 'option#update', 'url' => '/option/{optionId}', 'verb' => 'PUT'],
['name' => 'option#delete', 'url' => '/option/{optionId}', 'verb' => 'DELETE'],
['name' => 'option#confirm', 'url' => '/option/{optionId}/confirm', 'verb' => 'PUT'],
['name' => 'option#reorder', 'url' => '/options/reorder', 'verb' => 'POST'],
['name' => 'option#list', 'url' => '/polls/{pollId}/options', 'verb' => 'GET'],
// ['name' => 'option#listByToken', 'url' => '/options/get/s/{token}', 'verb' => 'GET'],

['name' => 'vote#set', 'url' => '/vote/set', 'verb' => 'POST'],
['name' => 'vote#setByToken', 'url' => '/vote/set/s', 'verb' => 'POST'],
['name' => 'vote#delete', 'url' => '/votes/delete', 'verb' => 'POST'],
// ['name' => 'vote#get', 'url' => '/votes/get/{pollId}', 'verb' => 'GET'],
// ['name' => 'vote#getByToken', 'url' => '/votes/get/s/{token}', 'verb' => 'GET'],

['name' => 'share#add', 'url' => '/share/add', 'verb' => 'POST'],
['name' => 'share#delete', 'url' => '/share/delete', 'verb' => 'POST'],
['name' => 'share#createPersonalShare', 'url' => '/share/create/s', 'verb' => 'POST'],
['name' => 'share#personal', 'url' => '/share/personal', 'verb' => 'POST'],
['name' => 'share#delete', 'url' => '/share/delete/{token}', 'verb' => 'DELETE'],
['name' => 'share#sendInvitation', 'url' => '/share/send/{token}', 'verb' => 'POST'],

// ['name' => 'share#getShares', 'url' => '/shares/get/{pollId}', 'verb' => 'GET'],
// ['name' => 'share#get', 'url' => '/share/get/{token}', 'verb' => 'GET'],
['name' => 'subscription#get', 'url' => '/subscription/{pollId}', 'verb' => 'GET'],
['name' => 'subscription#set', 'url' => '/subscription', 'verb' => 'POST'],

['name' => 'acl#getByToken', 'url' => '/acl/get/s/{token}', 'verb' => 'GET'],
['name' => 'acl#get', 'url' => '/acl/get/{id}', 'verb' => 'GET'],
['name' => 'comment#add', 'url' => '/comment', 'verb' => 'POST'],
['name' => 'comment#delete', 'url' => '/comment/{commentId}', 'verb' => 'DELETE'],
// ['name' => 'comment#list', 'url' => '/comments/{pollId}', 'verb' => 'GET'],
// ['name' => 'comment#getByToken', 'url' => '/comments/s/{token}', 'verb' => 'GET'],

// ['name' => 'acl#getByToken', 'url' => '/acl/get/s/{token}', 'verb' => 'GET'],
// ['name' => 'acl#get', 'url' => '/acl/get/{id}', 'verb' => 'GET'],

['name' => 'system#get_site_users_and_groups', 'url' => '/siteusers/get', 'verb' => 'POST'],
['name' => 'system#validate_public_username', 'url' => '/check/username', 'verb' => 'POST'],

// REST-API calls
['name' => 'poll_api#get', 'url' => '/api/v1.0/poll/{pollId}', 'verb' => 'GET'],
['name' => 'poll_api#list', 'url' => '/api/v1.0/polls', 'verb' => 'GET'],
['name' => 'poll_api#add', 'url' => '/api/v1.0/poll/add', 'verb' => 'POST'],
['name' => 'poll_api#clone', 'url' => '/api/v1.0/poll/clone/{pollId}', 'verb' => 'POST'],
['name' => 'poll_api#get', 'url' => '/api/v1.0/poll/{pollId}', 'verb' => 'GET'],
['name' => 'poll_api#add', 'url' => '/api/v1.0/poll', 'verb' => 'POST'],
['name' => 'poll_api#update', 'url' => '/api/v1.0/poll/{pollId}', 'verb' => 'PUT'],
['name' => 'poll_api#delete', 'url' => '/api/v1.0/poll/{pollId}', 'verb' => 'DELETE'],
['name' => 'poll_api#delete', 'url' => '/api/v1.0/poll/permanent/{pollId}', 'verb' => 'DELETE'],
['name' => 'poll_api#enum', 'url' => '/api/v1.0/poll/enum', 'verb' => 'GET'],
['name' => 'poll_api#clone', 'url' => '/api/v1.0/poll/{pollId}/clone', 'verb' => 'POST'],
['name' => 'poll_api#trash', 'url' => '/api/v1.0/poll/{pollId}/trash', 'verb' => 'POST'],
['name' => 'poll_api#enum', 'url' => '/api/v1.0/enum/poll', 'verb' => 'GET'],

['name' => 'option_api#list', 'url' => '/api/v1.0/poll/{pollId}/options', 'verb' => 'GET'],
['name' => 'option_api#add', 'url' => '/api/v1.0/option', 'verb' => 'POST'],
['name' => 'option_api#update', 'url' => '/api/v1.0/option', 'verb' => 'PUT'],
['name' => 'option_api#add', 'url' => '/api/v1.0/poll/{pollId}/option', 'verb' => 'POST'],
['name' => 'option_api#update', 'url' => '/api/v1.0/option/{optionId}', 'verb' => 'PUT'],
['name' => 'option_api#delete', 'url' => '/api/v1.0/option/{optionId}', 'verb' => 'DELETE'],
['name' => 'option_api#setOrder', 'url' => '/api/v1.0/option/{optionId}/setorder/{order}', 'verb' => 'PUT'],
['name' => 'option_api#confirm', 'url' => '/api/v1.0/option/{optionId}/confirm', 'verb' => 'PUT'],

['name' => 'comment_api#list', 'url' => '/api/v1.0/poll/{pollId}/comments', 'verb' => 'GET'],
['name' => 'comment_api#add', 'url' => '/api/v1.0/comment', 'verb' => 'POST'],
['name' => 'comment_api#delete', 'url' => '/api/v1.0/comment/{commentId}', 'verb' => 'DELETE'],
['name' => 'vote_api#list', 'url' => '/api/v1.0/poll/{pollId}/votes', 'verb' => 'GET'],
['name' => 'vote_api#set', 'url' => '/api/v1.0/vote', 'verb' => 'POST'],

['name' => 'share_api#list', 'url' => '/api/v1.0/poll/{pollId}/shares', 'verb' => 'GET'],
['name' => 'share_api#get', 'url' => '/api/v1.0/share/{token}', 'verb' => 'GET'],
Expand All @@ -105,7 +103,9 @@
['name' => 'subscription_api#subscribe', 'url' => '/api/v1.0/poll/{pollId}/subscription', 'verb' => 'PUT'],
['name' => 'subscription_api#unsubscribe', 'url' => '/api/v1.0/poll/{pollId}/subscription', 'verb' => 'DELETE'],

['name' => 'vote_api#list', 'url' => '/api/v1.0/poll/{pollId}/votes', 'verb' => 'GET'],
['name' => 'vote_api#set', 'url' => '/api/v1.0/vote', 'verb' => 'POST'],
['name' => 'comment_api#list', 'url' => '/api/v1.0/poll/{pollId}/comments', 'verb' => 'GET'],
['name' => 'comment_api#add', 'url' => '/api/v1.0/comment', 'verb' => 'POST'],
['name' => 'comment_api#delete', 'url' => '/api/v1.0/comment/{commentId}', 'verb' => 'DELETE'],

]
];
94 changes: 48 additions & 46 deletions docs/API_v1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,34 @@ Example calls:
```

# Poll
| Method | Endpoint | Description | Return codes |
| --------- | ----------------------------------- | ---------------------------- | ------------------ |
| GET | /api/v1.0/polls | Get polls list as array | 200, 403, 404 |
| GET | /api/v1.0/poll/{pollId} | Get poll with {pollId} | 200, 403, 404 |
| POST | /api/v1.0/poll/add | Add new poll with payload | 201, 403, 404 |
| POST | /api/v1.0/poll/clone/{pollId} | Clone poll {pollId} | 201, 403, 404 |
| PUT | /api/v1.0/poll/{pollId} | Update poll | 200, 403, 404, 409 |
| DELETE | /api/v1.0/poll/{pollId} | Delete poll logical | 200, 403, 404 |
| DELETE | /api/v1.0/poll/permanent/{pollId} | Delete poll permanently | 200, 403, 404 |
| GET | /api/v1.0/poll/enum | Get valid enums | 200, 403, 404 |

## Add poll

## Default functions
| Method | Endpoint | Payload | Description | Return codes | Return value |
| --------- | ------------------------ | ------- | ---------------------- | ------------------ | -------------- |
| GET | /api/v1.0/polls | no | Get array of polls | 200, 403, 404 | array |
| GET | /api/v1.0/poll/{pollId} | no | Get poll with {pollId} | 200, 403, 404 | requested poll |
| POST | /api/v1.0/poll | yes | Add new poll | 201, 403, 404 | added poll |
| PUT | /api/v1.0/poll/{pollId} | yes | Update poll | 200, 403, 404, 409 | updated poll |
| DELETE | /api/v1.0/poll/{pollId} | no | Delete poll | 200, 403, 404 | deleted poll |


## Special functions
| Method | Endpoint | Payload | Description | Return codes | Return value |
| --------- | ------------------------------| ------- | ---------------------------- | ------------------ | -------------- |
| POST | /api/v1.0/poll/{pollId}/clone | no | Clone poll from {pollId} | 201, 403, 404 | cloned poll |
| POST | /api/v1.0/poll/{pollId}/trash | no | Move to/remome from trash | 200, 403, 404 | updated poll |
| GET | /api/v1.0/enum/poll | no | Get valid enums | 200, 403, 404 | array |

## Valid payloads
### Add new poll
```json
{
"type": "datePoll",
"title": "Test"
"title": "Poll Title"
}
```

## Update poll
### Update poll
send the full or a partial structure
```json
{
"poll": {
Expand All @@ -52,54 +59,50 @@ Example calls:
}
}
```

### Keys and values
| Key | Type | description |
| ------- | ------- | -------------------|
| expire | integer | unix timestamp |
| deleted | integer | unix timestamp |



# Options
| Method | Endpoint | Description | Return codes |
| --------- | ----------------------------------- | ---------------------------- | ------------------ |
| GET | /api/v1.0/poll/{pollId}/options | Get options as array | 200, 403, 404 |
| POST | /api/v1.0/option | Add new option with Payload | 201, 403, 404, 409 |
| PUT | /api/v1.0/option | Update option with Payload | 200, 403, 404 |
| DELETE | /api/v1.0/option/{optionId} | Delete option | 200, 403, 404 |
## Default functions
| Method | Endpoint | Payload | Description | Return codes | Return value |
| --------- | ------------------------------- | ------- | ----------------- | ------------------ | -------------- |
| GET | /api/v1.0/poll/{pollId}/options | no | Get poll options | 200, 403, 404 | array |
| POST | /api/v1.0/poll/{pollId}/option | yes | Add new option | 201, 403, 404, 409 | added option |
| PUT | /api/v1.0/option/{optionId} | yes | Update option | 200, 403, 404 | updated option |
| DELETE | /api/v1.0/option/{optionId} | no | Delete option | 200, 403, 404 | deleted option |

## Special functions (no payloads)
| Method | Endpoint | Description | Return codes | Return value |
| --------- | -------------------------------------------- | ----------------------------- | ------------------ | ---------------- |
| PUT | /api/v1.0/option/{optionId}/confirm | Confirm/unconfirm option | 200, 403, 404 | confirmed option |
| PUT | /api/v1.0/option/{optionId}/setorder/{order} | Set order (text poll) | 200, 403, 404 | array |

## Valid payloads
### Add/update option (text poll)

## add option
```json
{
"pollId": 139,
"pollOptionText": "19-06-2020 17:00:00",
"timestamp": 0,
"pollOptionText": "Text of new option"
}
```

## Update option
### Add/update option (date poll)
```json
{
"id": 17,
"pollId": 1,
"pollOptionText": "poll option",
"timestamp": 0,
"order": 1,
"confirmed": 1590762104
},
"timestamp": 1589195823
}
```

### Keys and values
| Key | Type | description |
| -------------- | ------- | ------------------------------------- |
| id | String | id overrides optionID if used |
| pollOptionText | String | poll text or date option in UTC |
| confirmed | Integer | unix timestamp |
| timestamp | Integer | unix timestamp for date option |
| order | Integer | position on option order for textpolls |
| Key | Type | description |
| -------------- | ------- | ----------------------- |
| pollOptionText | String | poll text |
| timestamp | Integer | 10 digit unix timestamp |


* if timestamp is given in a date poll, the poll option text is ignored

# Votes
| Method | Endpoint | Description | Return codes |
Expand All @@ -110,8 +113,7 @@ Example calls:
## set vote
```json
{
"pollId": 1,
"pollOptionText": "Saturn",
"optionId": 1,
"setTo" :"yes"
}
```
Expand Down
80 changes: 0 additions & 80 deletions lib/Controller/AclController.php

This file was deleted.

Loading