}); $app->get('/oauth2callback', function () use($helper) { $helper->callBackLogic(); die; }); // GET TASKS $app->get('/tasks-json', function () use($service, $helper) { // sleep(2); $data = $service->getListsArray(true); return new Response(json_encode($data), 200, array('Content-Type' => 'application/json')); }); $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')); //});