* params - 'nome', 'endereco', 'telefone', 'email', 'empresa', 'tipo_entrega' */ $app->post('/update-user', function () use($app, $log) { // check for required params verifyRequiredParams(array('cd_usuario', 'nome', 'endereco', 'telefone', 'tipo_entrega')); $response = array(); // reading post params $cd_usuario = $_REQUEST["cd_usuario"]; $nome = $_REQUEST["nome"]; $endereco = $_REQUEST["endereco"]; $telefone = $_REQUEST["telefone"]; $email = $_REQUEST["email"]; $empresa = $_REQUEST["empresa"]; $tipo_entrega = $_REQUEST["tipo_entrega"]; $db = new DbHandler(); $res = $db->updateUser($cd_usuario, $nome, $endereco, $telefone, $email, $empresa, $tipo_entrega); if ($res) { $response["error"] = false; $response["cd_usuario"] = $res; echoResponse(201, $response); } else { $response["error"] = true; echoResponse(200, $response); } }); /** * Get user * url - /get-user * method - POST * params - email */
* url /users */ $app->post('/users', 'authenticate', function () use($app) { $db = new DbHandler(); global $user_id; $user = $db->getUserById($user_id); // reading post params $name = $app->request->post('Name'); $status = $app->request->post('Status'); if ($name == null) { $name = $user["name"]; } if ($status == null) { $status = $user["status"]; } $response = $db->updateUser($user_id, $name, $status); echoRespnse(200, $response); }); function createThumb($image, $size, $path) { $image->thumbnail($size, $size); $format = $image->get_original_info()['format']; $uniqid = uniqid(); $filename = $uniqid . '.' . $format; if ($image->save($path . $filename)) { return $filename; } else { return new Exception("Can not writeImage to " . $filename); } } /**