2019-01-13 13:06:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace AirQuality\Actions;
|
|
|
|
|
|
|
|
|
2019-01-14 20:17:36 +00:00
|
|
|
class FetchData {
|
2019-01-13 13:06:32 +00:00
|
|
|
private $settings;
|
2019-01-14 20:41:25 +00:00
|
|
|
private $validator;
|
2019-01-13 13:06:32 +00:00
|
|
|
|
|
|
|
public function __construct(
|
2019-01-14 21:33:30 +00:00
|
|
|
\SBRL\TomlConfig $in_settings) {
|
2019-01-13 13:06:32 +00:00
|
|
|
$this->settings = $in_settings;
|
2019-01-14 20:41:25 +00:00
|
|
|
$this->validator = new \AirQuality\Validator($_GET);
|
2019-01-13 13:06:32 +00:00
|
|
|
}
|
|
|
|
|
2019-01-14 22:18:30 +00:00
|
|
|
public function handle() : Boolean {
|
|
|
|
global $start_time;
|
|
|
|
|
|
|
|
// 1: Validate params
|
2019-01-14 20:41:25 +00:00
|
|
|
$this->validator->is_datetime("datetime");
|
|
|
|
$this->validator->run();
|
|
|
|
|
2019-01-14 22:18:30 +00:00
|
|
|
// 2: Pull data from database
|
|
|
|
|
|
|
|
// 2.5: Validate data from database
|
|
|
|
|
|
|
|
// 3: Serialise data
|
|
|
|
$response = json_encode("Coming soon");
|
|
|
|
|
|
|
|
// 4: Send response
|
|
|
|
header("x-time-taken: " . (microtime(true) - $start_time) . "ms");
|
|
|
|
header("content-type: application/json");
|
|
|
|
echo($response);
|
|
|
|
return true;
|
2019-01-13 13:06:32 +00:00
|
|
|
}
|
|
|
|
}
|