From fa39434ac95e4f77b713b1e24f8ebabdf43166b6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Nov 2016 20:43:10 +1100 Subject: [PATCH] Tasks via API (#1152) * revert error reporting * Add Task attributes --- app/Http/Controllers/TaskApiController.php | 35 ++++++++++++++++++++++ app/Ninja/Transformers/TaskTransformer.php | 9 +++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/TaskApiController.php b/app/Http/Controllers/TaskApiController.php index 02ac417cf089..5ded99e382dc 100644 --- a/app/Http/Controllers/TaskApiController.php +++ b/app/Http/Controllers/TaskApiController.php @@ -1,5 +1,6 @@ response($data); } + + + /** + * @SWG\Put( + * path="/task/{task_id}", + * tags={"task"}, + * summary="Update a task", + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/Task") + * ), + * @SWG\Response( + * response=200, + * description="Update task", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Task")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ + + public function update(UpdateTaskRequest $request) + { + $task = $request->entity(); + + $task = $this->taskRepo->save($task->public_id, \Illuminate\Support\Facades\Input::all()); + + return $this->itemResponse($task); + + } + } diff --git a/app/Ninja/Transformers/TaskTransformer.php b/app/Ninja/Transformers/TaskTransformer.php index 86dcea068677..0571185e4022 100644 --- a/app/Ninja/Transformers/TaskTransformer.php +++ b/app/Ninja/Transformers/TaskTransformer.php @@ -41,7 +41,14 @@ class TaskTransformer extends EntityTransformer return array_merge($this->getDefaults($task), [ 'id' => (int) $task->public_id, 'description' => $task->description, - 'duration' => $task->getDuration() + 'duration' => $task->getDuration(), + 'updated_at' => (int) $this->getTimestamp($task->updated_at), + 'archived_at' => (int) $this->getTimestamp($task->deleted_at), + 'invoice_id' => (int) $task->invoice->public_id, + 'client_id' => (int) $task->client->public_id, + 'is_deleted' => (bool) $task->is_deleted, + 'time_log' => $task->time_log, + 'is_running' => (bool) $task->is_running, ]); } } \ No newline at end of file