Refactor entry API: consolidate entry handling, update naming conventions, and enhance error reporting
This commit is contained in:
1 parent
205f2e2f73
commit
ad9290d2ad
9 files changed
+72
-12
No files matched your search
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// Set internal to false so that the answer goes to the client
|
||||
if (!isset($internal)) {
|
||||
$internal = false;
|
||||
define("API_DIR", "../");
|
||||
}
|
||||
|
||||
// Load Main Library
|
||||
require_once API_DIR . "api.php";
|
||||
|
||||
$api = new gbAPI(true, $internal);
|
||||
|
||||
$input = $api->getInput();
|
||||
|
||||
|
||||
// Check given Status
|
||||
if (!isset($input["status"])) {
|
||||
$api->answer(400, [
|
||||
"error" => "missing_fields",
|
||||
"error_text" => "Some fields are missing"
|
||||
], true);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($status !== 0 && $status !== 1 && $status !== 2) {
|
||||
$api->answer(400, [
|
||||
"error" => "status_invalid",
|
||||
"error_text" => "The given status is invalid."
|
||||
], true);
|
||||
}
|
||||
|
||||
$command = "SELECT * FROM entrys WHERE status = :status";
|
||||
|
||||
$response = $api->dbCommand($command, true, true, [
|
||||
":status" => $status
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user