Пример #1
0
        $response["message"] = "Place added successfully";
        $response["place_id"] = $result;
        echoResponse(200, $response);
    }
});
/**
 * Listing score
 * url /place/:id
 * method GET
 * Will return 404 if the score doesn't exist
 */
$app->get('/score/:id', function ($place_id) {
    $response = array();
    $db = new db_handler();
    // fetch task
    $result = $db->getScoreByPlaceId($place_id);
    if ($result != NULL) {
        $response["error"] = false;
        $response["paper"] = $result["paper"];
        $response["size"] = $result["size"];
        $response["wait_time"] = $result["wait_time"];
        $response["cleanliness"] = $result["cleanliness"];
        $response["smell"] = $result["smell"];
        echoResponse(200, $response);
    } else {
        $response["error"] = true;
        $response["message"] = "The requested place doesn't have any score";
        echoResponse(404, $response);
    }
});
/**