Add 'action' to API docs

This commit is contained in:
Hillel Coren 2017-05-22 12:16:27 +03:00
parent c433661d11
commit 827b93e40c
2 changed files with 9 additions and 0 deletions

View File

@ -74,6 +74,10 @@ class BaseAPIController extends Controller
$entity = $request->entity(); $entity = $request->entity();
$action = $request->action; $action = $request->action;
if (! in_array($action, ['archive', 'delete', 'restore'])) {
return $this->errorResponse('Action is not supported');
}
$repo = Utils::toCamelCase($this->entityType) . 'Repo'; $repo = Utils::toCamelCase($this->entityType) . 'Repo';
$this->$repo->$action($entity); $this->$repo->$action($entity);

View File

@ -107,6 +107,11 @@ Updating Data
-d '{"name":"test", "contacts":[{"id": 1, "first_name": "test"}]}' \ -d '{"name":"test", "contacts":[{"id": 1, "first_name": "test"}]}' \
-H "X-Ninja-Token: TOKEN" -H "X-Ninja-Token: TOKEN"
You can archive, delete or restore an entity by setting ``action`` in the request
curl -X PUT ninja.dev/api/v1/invoices/1?action=archive \
-H "X-Ninja-Token: TOKEN"
Emailing Invoices Emailing Invoices
""""""""""""""""" """""""""""""""""