public function moveTaskToList($listId, $taskId, $newListId)
 {
     unset($this->db[$listId]);
     unset($this->db[$newListId]);
     return parent::moveTaskToList($listId, $taskId, $newListId);
 }
$app->get('/tasks-json/{listId}', function ($listId) use($service) {
    if ($service instanceof GtaskHelperCached) {
        $service->resetListCache($listId);
    }
    $data = $service->getTasksInListArray($listId);
    return new Response(json_encode($data), 200, array('Content-Type' => 'application/json'));
});
// ADD TASK
$app->post('/list/{listId}/tasks', function (Request $request, $listId) use($service) {
    $task = json_decode($request->getContent());
    $addedTask = $service->addTask($listId, $task->title);
    /* @var $task \Google_Service_Tasks_Task */
    return new Response(json_encode(GtaskHelper::taskToArray($addedTask)), 200, array('Content-Type' => 'application/json'));
});
// EDIT TASK TITLE
//$app->put('/list/{listId}/task/{taskId}/edit-title/{title}', function (Request $request, $listId, $taskId, $newTitle) use ($service) {
//    $service->editTaskTitle($listId, $taskId, $newTitle);
//
//    return new Response(json_encode('ok'), 200, array('Content-Type' => 'application/json'));
//});
// EDIT TASK LIST
$app->put('/list/{listId}/task/{taskId}/change-list/{newListId}', function (Request $request, $listId, $taskId, $newListId) use($service) {
    $service->moveTaskToList($listId, $taskId, $newListId);
    return new Response(json_encode('ok'), 200, array('Content-Type' => 'application/json'));
});
// DELETE
$app->delete('/list/{listId}/tasks/{taskId}', function ($listId, $taskId) use($service) {
    $ret = $service->deleteTasks($listId, [$taskId]);
    return new Response(json_encode($ret), 200, array('Content-Type' => 'application/json'));
});
$app->run();