Эх сурвалжийг харах

fix: standardize HTTP status codes and error messages

Fernando 4 сар өмнө
parent
commit
dafe03c62f

+ 2 - 2
controllers/CategoryCreateController.php

@@ -26,7 +26,7 @@ class CategoryCreateController
              ->key('category_name', v::stringType()->notEmpty()->alnum(' '))
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = $body['company_id'];
@@ -36,6 +36,6 @@ class CategoryCreateController
 
         return $created
             ? ResponseLib::sendOk(['created' => true])
-            : ResponseLib::sendFail("Failed to Create Category", [], "E_VALIDATE")->withStatus(402);
+            : ResponseLib::sendFail("Failed to Create Category", [], "E_VALIDATE")->withStatus(500);
     }
 }

+ 2 - 2
controllers/CategoryDeleteController.php

@@ -26,7 +26,7 @@ class CategoryDeleteController
              ->key('category_name', v::stringType()->notEmpty()->alnum(' '))
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = $body['company_id'];
@@ -36,6 +36,6 @@ class CategoryDeleteController
 
         return $deleted
             ? ResponseLib::sendOk(['deleted' => true])
-            : ResponseLib::sendFail("Failed to Delete Category", [], "E_VALIDATE")->withStatus(204);
+            : ResponseLib::sendFail("Failed to Delete Category", [], "E_VALIDATE")->withStatus(500);
     }
 }

+ 2 - 2
controllers/CategoryGetController.php

@@ -25,7 +25,7 @@ class CategoryGetController
             v::key('company_id', v::intType()->positive())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -35,6 +35,6 @@ class CategoryGetController
             return ResponseLib::sendOk($categories);
         }
 
-        return ResponseLib::sendFail("Failed to retrieve categories", [], "E_DATABASE")->withStatus(500);
+        return ResponseLib::sendFail("Failed to Retrieve Categories", [], "E_DATABASE")->withStatus(500);
     }
 }

+ 2 - 2
controllers/CategoryUpdateFlagController.php

@@ -27,7 +27,7 @@ class CategoryUpdateFlagController
              ->key('category_flag', v::stringType()->notEmpty())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = $body['company_id'];
@@ -38,6 +38,6 @@ class CategoryUpdateFlagController
 
         return $deleted
             ? ResponseLib::sendOk(['updated flag' => true])
-            : ResponseLib::sendFail("Failed to Update Category Flag", [], "E_VALIDATE")->withStatus(204);
+            : ResponseLib::sendFail("Failed to Update Category Flag", [], "E_VALIDATE")->withStatus(500);
     }
 }

+ 2 - 2
controllers/DescriptionCreateController.php

@@ -20,7 +20,7 @@ class DescriptionCreateController
              ->key('description_text', v::stringType()->notEmpty())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $model = new DescriptionModel();
@@ -32,6 +32,6 @@ class DescriptionCreateController
 
         return $result
             ? ResponseLib::sendOk(['created' => true])
-            : ResponseLib::sendFail("Erro ao inserir descrição", [], "E_DB")->withStatus(500);
+            : ResponseLib::sendFail("Failed to Create Description", [], "E_DB")->withStatus(500);
     }
 }

+ 2 - 2
controllers/DescriptionUpdateController.php

@@ -20,7 +20,7 @@ class DescriptionUpdateController
              ->key('description_text', v::stringType()->notEmpty())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $productId = (int) $body['product_id'];
@@ -32,6 +32,6 @@ class DescriptionUpdateController
 
         return $success
             ? ResponseLib::sendOk(['updated' => true])
-            : ResponseLib::sendFail("Erro ao atualizar descrição", [], "E_DB")->withStatus(500);
+            : ResponseLib::sendFail("Failed to Update Description", [], "E_DB")->withStatus(500);
     }
 }

+ 2 - 2
controllers/LoginController.php

@@ -20,7 +20,7 @@ class LoginController
              ->key('password', v::stringType()->notEmpty())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(401);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $username = $body['username'];
@@ -30,7 +30,7 @@ class LoginController
         $user = $userModel->validateLogin($username, $password);
 
         if (!$user) {
-            return ResponseLib::sendFail("Invalid credentials", [], "E_VALIDATE")->withStatus(401);
+            return ResponseLib::sendFail("Invalid Credentials", [], "E_VALIDATE")->withStatus(400);
         }
 
         // Gera JWT

+ 2 - 2
controllers/MenuGetController.php

@@ -20,13 +20,13 @@ class MenuGetController
         $companyId = $request->getAttribute('id');
 
         if (!is_numeric($companyId) || (int)$companyId <= 0) {
-            return ResponseLib::sendFail("Parâmetro company_id inválido na URL", [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Invalid company_id", [], "E_VALIDATE")->withStatus(400);
         }
 
         $menuItems = $this->model->getMenu((int)$companyId);
 
         if (!$menuItems) {
-            return ResponseLib::sendFail("Failed to retrieve menu", [], "E_DATABASE")->withStatus(500);
+            return ResponseLib::sendFail("Failed to Retrieve Menu", [], "E_DATABASE")->withStatus(500);
         }
 
         $cardapio = [];

+ 4 - 4
controllers/OrderCreateController.php

@@ -33,7 +33,7 @@ class OrderCreateController
              ->key('status_status', v::stringType()->notEmpty()->in(['Aberta', 'Finalizada', 'Cancelada']))
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $tableId = (int) $body['table_id'];
@@ -47,13 +47,13 @@ class OrderCreateController
         $userId = $this->getUserIdByUserName($userName, $companyId);
 
         if (!$userId) {
-            return ResponseLib::sendFail("Usuário '{$userName}' não encontrado", [], "E_USER_NOT_FOUND")->withStatus(404);
+            return ResponseLib::sendFail("User '{$userName}' Not Found", [], "E_USER_NOT_FOUND")->withStatus(404);
         }
 
         $statusId = $this->model->getStatusIdByName($statusStatus);
 
         if ($statusId === null) {
-            return ResponseLib::sendFail("Invalid status_status provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Invalid status_status Provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
         }
 
         $created = $this->model->createOrder(
@@ -67,7 +67,7 @@ class OrderCreateController
 
         return $created
             ? ResponseLib::sendOk(['created' => true, 'order_id' => $created])
-            : ResponseLib::sendFail("Failed to create order", [], "E_DATABASE")->withStatus(500);
+            : ResponseLib::sendFail("Failed to Create Order", [], "E_DATABASE")->withStatus(500);
     }
 
     private function getUserIdByUserName(string $username, int $companyId): ?int

+ 2 - 2
controllers/OrderDeleteController.php

@@ -26,7 +26,7 @@ class OrderDeleteController
                 ->key('company_id', v::intType()->positive())
                 ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
     
         $orderId = (int) $body['order_id'];
@@ -37,6 +37,6 @@ class OrderDeleteController
     
         return $deleted
             ? ResponseLib::sendOk(['deleted' => true, 'hard' => $hardDelete])
-            : ResponseLib::sendFail("Failed to delete order or order not found", [], "E_DATABASE")->withStatus(404);
+            : ResponseLib::sendFail("Failed to Delete Order or Order Not Found", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 3 - 3
controllers/OrderGetController.php

@@ -30,7 +30,7 @@ class OrderGetController
                 ->key('table_id', v::optional(v::intType()->positive()), false) // Adicionado table_id como opcional
                 ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -44,7 +44,7 @@ class OrderGetController
         if ($statusStatus !== null) {
             $statusId = $this->model->getStatusIdByName($statusStatus);
             if ($statusId === null) {
-                return ResponseLib::sendFail("Invalid status_status provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
+                return ResponseLib::sendFail("Invalid status_status Provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
             }
         }
 
@@ -74,6 +74,6 @@ class OrderGetController
             return ResponseLib::sendOk($orders);
         }
 
-        return ResponseLib::sendFail("No orders found for the given criteria", [], "E_DATABASE")->withStatus(404);
+        return ResponseLib::sendFail("No Orders Found for the Given Criteria", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 2 - 2
controllers/OrderItemCreateController.php

@@ -28,7 +28,7 @@ class OrderItemCreateController
               ->key('kitchen_note', v::optional(v::stringType()), false)
               ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -40,6 +40,6 @@ class OrderItemCreateController
 
         return $created
             ? ResponseLib::sendOk(['created' => true, 'order_item_id' => $created])
-            : ResponseLib::sendFail("Failed to create order item", [], "E_DATABASE")->withStatus(500);
+            : ResponseLib::sendFail("Failed to Create Order Item", [], "E_DATABASE")->withStatus(500);
     }
 }

+ 2 - 2
controllers/OrderItemDeleteController.php

@@ -27,7 +27,7 @@ class OrderItemDeleteController
                 ->key('company_id', v::intType()->positive()) 
                 ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $orderItemId = (int) $body['order_item_id'];
@@ -37,6 +37,6 @@ class OrderItemDeleteController
 
         return $deleted
             ? ResponseLib::sendOk(['deleted' => true])
-            : ResponseLib::sendFail("Failed to delete order item or item not found for this company", [], "E_DATABASE")->withStatus(404);
+            : ResponseLib::sendFail("Failed to Delete Order Item or Item Not Found for this Company", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 2 - 2
controllers/OrderItemGetController.php

@@ -32,7 +32,7 @@ class OrderItemGetController
                 }
             }
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -55,6 +55,6 @@ class OrderItemGetController
             return ResponseLib::sendOk($orderItems);
         }
 
-        return ResponseLib::sendFail("No order items found for the given data", [], "E_DATABASE")->withStatus(404);
+        return ResponseLib::sendFail("No Order Items Found for the Given Data", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 3 - 3
controllers/OrderUpdateController.php

@@ -29,7 +29,7 @@ class OrderUpdateController
                 ->key('status_status', v::stringType()->notEmpty()->in(['Aberta', 'Finalizada', 'Cancelada']), true) // Adicione aqui todos os status possíveis para atualização
                 ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -41,13 +41,13 @@ class OrderUpdateController
 
         if ($statusId === null) {
             // Isso pode acontecer se o status_status enviado não for mapeado no banco
-            return ResponseLib::sendFail("Invalid status_status provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Invalid status_status Provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
         }
 
         $updated = $this->model->updateOrderStatus($orderId, $companyId, $statusId);
 
         return $updated
             ? ResponseLib::sendOk(['updated' => true])
-            : ResponseLib::sendFail("Failed to update order status or order not found", [], "E_DATABASE")->withStatus(404);
+            : ResponseLib::sendFail("Failed to Update Order Status or Order Not Found", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 3 - 3
controllers/ProductCreateController.php

@@ -37,7 +37,7 @@ class ProductCreateController
         }
 
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = $body['company_id'];
@@ -56,7 +56,7 @@ class ProductCreateController
         );
 
         if (!$productId) {
-            return ResponseLib::sendFail("Failed to Create Product", [], "E_DATABASE")->withStatus(402);
+            return ResponseLib::sendFail("Failed to Create Product", [], "E_DATABASE")->withStatus(500);
         }
 
         if ($descriptionText !== null) {
@@ -67,7 +67,7 @@ class ProductCreateController
             );
 
             if (!$descriptionCreated) {
-                return ResponseLib::sendFail("Product created, but failed to create description.", [], "E_DATABASE")->withStatus(500);
+                return ResponseLib::sendFail("Product Created, but Failed to Create Description.", [], "E_DATABASE")->withStatus(500);
             }
         }
 

+ 2 - 2
controllers/ProductDeleteController.php

@@ -26,7 +26,7 @@ class ProductDeleteController
              ->key('product_name', v::stringType()->notEmpty()->alnum(' '))
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -36,6 +36,6 @@ class ProductDeleteController
 
         return $deleted
             ? ResponseLib::sendOk(['deleted' => true])
-            : ResponseLib::sendFail("Failed to Delete Product or Product Not Found", [], "E_DATABASE")->withStatus(403);
+            : ResponseLib::sendFail("Failed to Delete Product or Product Not Found", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 2 - 2
controllers/ProductGetController.php

@@ -26,7 +26,7 @@ class ProductGetController
              ->key('show_description', v::optional(v::boolType()), false)
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(401);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -38,6 +38,6 @@ class ProductGetController
             return ResponseLib::sendOk($products);
         }
 
-        return ResponseLib::sendFail("Failed to retrieve products", [], "E_DATABASE")->withStatus(500);
+        return ResponseLib::sendFail("Failed to Retrieve Products", [], "E_DATABASE")->withStatus(500);
     }
 }

+ 1 - 1
controllers/ProductUpdateController.php

@@ -30,7 +30,7 @@ class ProductUpdateController
              ->key('product_is_kitchen', v::optional(v::boolType()), false)
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $hasProductName = isset($body['product_name']) && $body['product_name'] !== null;

+ 2 - 2
controllers/RegisterController.php

@@ -22,7 +22,7 @@ class RegisterController
              ->key('role_id', v::intType()->positive())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $username = $body['username'];
@@ -35,7 +35,7 @@ class RegisterController
         $userData = $userModel->createUser($username, $email, $password, $company_id, $role_id);
 
         if (!$userData) {
-            return ResponseLib::sendFail("Username already exists or creation failed", [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Username Already Exists or Creation Failed", [], "E_VALIDATE")->withStatus(400);
         }
 
         return ResponseLib::sendOk($userData, "S_CREATED");

+ 2 - 2
controllers/TableCreateController.php

@@ -28,7 +28,7 @@ class TableCreateController
              ->key('status_id', v::intVal()->positive())
              ->assert($body);
         } catch (NestedValidationException $e) {
-            return ResponseLib::sendFail($e->getMessages(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail($e->getMessages(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -47,6 +47,6 @@ class TableCreateController
 
         return $created
             ? ResponseLib::sendOk(['created' => true])
-            : ResponseLib::sendFail("Failed to create table", [], "E_DATABASE")->withStatus(500);
+            : ResponseLib::sendFail("Failed to Create Table", [], "E_DATABASE")->withStatus(500);
     }
 }

+ 2 - 2
controllers/TableDeleteController.php

@@ -30,13 +30,13 @@ class TableDeleteController
              ->key('company_id', v::intType()->positive())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $deleted = $this->model->deleteTableByNumber((string)$tableNumber, (int)$companyId);
 
         return $deleted
             ? ResponseLib::sendOk(['deleted' => true])
-            : ResponseLib::sendFail("Table not found or already deleted", [], "E_DATABASE")->withStatus(404);
+            : ResponseLib::sendFail("Table Not Found or Already Deleted", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 2 - 2
controllers/TableGetController.php

@@ -26,7 +26,7 @@ class TableGetController
             v::key('company_id', v::intType()->positive())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = $body['company_id'];
@@ -37,6 +37,6 @@ class TableGetController
             return ResponseLib::sendOk($tables);
         }
 
-        return ResponseLib::sendFail("No tables found", [], "E_DATABASE")->withStatus(404);
+        return ResponseLib::sendFail("Table Not Found", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 2 - 2
controllers/TableUpdateController.php

@@ -28,7 +28,7 @@ class TableUpdateController
              ->key('status_status', v::stringType()->notEmpty())
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $tableNumber = $body['table_number'];
@@ -45,6 +45,6 @@ class TableUpdateController
 
         return $updated
             ? ResponseLib::sendOk(['updated' => true])
-            : ResponseLib::sendFail("Failed to update status or table not found", [], "E_DATABASE")->withStatus(404);
+            : ResponseLib::sendFail("Failed to Update Status or Table Not Found", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 2 - 3
controllers/UserDeleteController.php

@@ -26,8 +26,7 @@ class UserDeleteController
              ->key('user_name', v::stringType()->notEmpty()->alnum(' _'))  // permite espaço e underline
              ->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")
-                             ->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -37,6 +36,6 @@ class UserDeleteController
 
         return $deleted
             ? ResponseLib::sendOk(['deleted' => true])
-            : ResponseLib::sendFail("Failed to delete user or user not found", [], "E_DATABASE")->withStatus(403);
+            : ResponseLib::sendFail("Failed to Delete User or User Not Found", [], "E_DATABASE")->withStatus(404);
     }
 }

+ 2 - 3
controllers/UserGetController.php

@@ -24,8 +24,7 @@ class UserGetController
         try {
             v::key('company_id', v::intType()->positive())->assert($body);
         } catch (ValidationException $e) {
-            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")
-                             ->withStatus(400);
+            return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
         }
 
         $companyId = (int) $body['company_id'];
@@ -33,6 +32,6 @@ class UserGetController
 
         return $users
             ? ResponseLib::sendOk($users)
-            : ResponseLib::sendFail("No users found", [], "E_DATABASE")->withStatus(404);
+            : ResponseLib::sendFail("User Not Found", [], "E_DATABASE")->withStatus(404);
     }
 }