api_login();
$req = $rest->request();
define("RESULTS_PER_PAGE", 2);
// API Routes
// ------------------------------- Items -------------------------------
// Get Items
$rest->get('/inventory/', function () use($rest) {
    global $req;
    include_once API_ROOT . "/inventory.inc";
    $page = $req->get("page");
    if ($page == null) {
        inventory_all();
    } else {
        // If page = 1 the value will be 0, if page = 2 the value will be 1, ...
        $from = --$page * RESULTS_PER_PAGE;
        inventory_all($from);
    }
});
// Get Specific Item by Stock Id
$rest->get('/inventory/:id', function ($id) use($rest) {
    include_once API_ROOT . "/inventory.inc";
    inventory_get($id);
});
// Add Item
$rest->post('/inventory/', function () use($rest) {
    include_once API_ROOT . "/inventory.inc";
    inventory_add();
});
// Edit Specific Item
$rest->put('/inventory/:id', function ($id) use($rest) {
    include_once API_ROOT . "/inventory.inc";
Beispiel #2
0
include_once $path_to_root . "/modules/api/Slim/Slim.php";
\Slim\Slim::registerAutoloader();
include_once $path_to_root . "/modules/api/util.php";
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/includes/data_checks.inc";
$rest = new \Slim\Slim(array('log.enabled' => true, 'mode' => 'debug', 'debug' => true));
$rest->setName('SASYS');
// API Login Hook
api_login();
// API Routes
// ------------------------------- Items -------------------------------
// Get Items
$rest->get('/inventory/', function () use($rest) {
    global $path_to_root;
    include_once $path_to_root . "/modules/api/inventory.inc";
    inventory_all();
});
// Get Specific Item by Stock Id
$rest->get('/inventory/:id', function ($id) use($rest) {
    global $path_to_root;
    include_once $path_to_root . "/modules/api/inventory.inc";
    inventory_get($id);
});
// Add Item
$rest->post('/inventory/', function () use($rest) {
    global $path_to_root;
    include_once $path_to_root . "/modules/api/inventory.inc";
    inventory_add();
});
// Edit Specific Item
$rest->put('/inventory/:id', function ($id) use($rest) {