<?php

use Simulador\Tables\Simulacao;

$response = ['success' => true];

try {
    $data = json_decode(file_get_contents('php://input'), true);

    if ($_SERVER['REQUEST_METHOD'] === 'GET') {
        $response['data'] = Simulacao::get($_GET);
    }

} catch (Exception $e) {
    header("HTTP/1.1 422 Unprocessable Entity");
    $response['success'] = false;
    $response['message'] = ucfirst($e->getMessage());
}

echo json_encode($response, JSON_PRETTY_PRINT);
