}); $app->get("/pokemon", function () use($app) { sendResponse(Pokemon::getAll()); }); $app->get("/pokemon/:id", function ($id) use($app) { $pokemon = Pokemon::getById($id); sendResponse($pokemon->serialize()); }); $app->get("/pokemon/:id/owners", function ($pokemonId) use($app) { $pokemon = Pokemon::getById($pokemonId); sendResponse($pokemon->getTrainers()); }); $app->post('/trainers/create', function () use($app) { $body = $app->request->getBody(); $json = json_decode($body); $trainer = Trainer::create($json->name, $json->rivalId, $json->pokemon, $json->badgeIds); sendResponse($trainer); }); $app->post('/trainers/delete', function () use($app) { $body = $app->request->getBody(); $json = json_decode($body); $trainer = Trainer::delete($json->id); sendResponse($trainer); }); $app->get('/trainers', function () use($app) { sendResponse(Trainer::getAll()); }); $app->post('/trainers/:id/pokemon/add', function ($id) use($app) { $body = $app->request->getBody(); $json = json_decode($body); $trainer = Trainer::getById($id);