<?php
require_once '../classes/OMIE.php';

header('Content-Type: application/json; charset=utf-8');

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    http_response_code(405);
    echo json_encode(['error' => 'Metodo no permitido']);
    exit;
}

$fecha = $_POST['fecha'] ?? null;
$marketType = $_POST['market_type'] ?? 'omie';

if (!$fecha) {
    http_response_code(400);
    echo json_encode(['error' => 'Falta la fecha']);
    exit;
}

$omie = new OMIE();
echo json_encode($omie->getDashboardSummary($fecha, $marketType));
?>
