Air-Quality-Web/logic/Actions/FetchData.php

37 lines
739 B
PHP
Raw Normal View History

<?php
namespace AirQuality\Actions;
2019-01-14 20:17:36 +00:00
class FetchData {
private $settings;
2019-01-14 20:41:25 +00:00
private $validator;
public function __construct(
\SBRL\TomlConfig $in_settings) {
$this->settings = $in_settings;
2019-01-14 20:41:25 +00:00
$this->validator = new \AirQuality\Validator($_GET);
}
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();
// 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;
}
}