diff --git a/app/Http/Controllers/BaseAPIController.php b/app/Http/Controllers/BaseAPIController.php index ef7460b6480c..640c7b44e1cd 100644 --- a/app/Http/Controllers/BaseAPIController.php +++ b/app/Http/Controllers/BaseAPIController.php @@ -74,6 +74,10 @@ class BaseAPIController extends Controller $entity = $request->entity(); $action = $request->action; + if (! in_array($action, ['archive', 'delete', 'restore'])) { + return $this->errorResponse('Action is not supported'); + } + $repo = Utils::toCamelCase($this->entityType) . 'Repo'; $this->$repo->$action($entity); diff --git a/docs/api.rst b/docs/api.rst index 9d8fbb062045..3801322ad38f 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -107,6 +107,11 @@ Updating Data -d '{"name":"test", "contacts":[{"id": 1, "first_name": "test"}]}' \ -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 """""""""""""""""