function api_error($error = null) { http_response_code(400); if (is_null($error)) { $error = array("success" => false); } api_done($error); }
<?php require_once "../php/main.php"; $id = argreq("id"); $code = argreq("code"); if (check_ticker_passcode($id, $code)) { api_done(array("ticker" => get_ticker($id))); } api_error();
<?php require_once "../php/main.php"; $id = argreq("id"); $time = get_current_time($id); if (is_null($time)) { api_error(); } api_done(array("half" => $time[0], "time" => $time[1], "overtime" => $time[2]));
<?php require_once "../php/main.php"; $id = argreq("id"); $ticker = get_ticker($id); if ($ticker) { api_done(array("ticker" => $ticker)); } api_error();
<?php require_once "../php/main.php"; $id = argreq("id"); $events = get_ticker_events($id); if (is_null($events) || empty($events)) { api_error(); } api_done(array("events" => $events));
function api_error($err) { //Return other response code than 200 http_response_code(400); api_done($err); }
<?php require_once "../php/main.php"; $id = argreq("id"); $players = get_ticker_players($id); //TODO: distinguish between invalid ticker and empty set if (empty($players) || is_null($players)) { api_error(); } api_done(array("players" => $players));
<?php require_once "../php/main.php"; $id = argreq("id"); $event = argreq("event"); $code = argreq("code"); $result = remove_ticker_event($id, $event_id, $code); if (!result) { api_error(); } api_done();
<?php require_once "../php/main.php"; $id = argreq("id"); $code = argreq("code"); $running = toggle_ticker_running($id, $code); if (is_null($running)) { api_error(); } api_done(array("running" => $running));
<?php require_once "../php/main.php"; api_done(array("durations" => get_valid_durations()));