<?php
require_once __DIR__ . '/bootstrap_api.php';

try {
    api_install_schema($pdo);

    api_json([
        'ok' => true,
        'message' => 'RoomZ Outlook API is operational.',
        'php_version' => PHP_VERSION,
        'database' => (string)$pdo->query('SELECT DATABASE()')->fetchColumn(),
        'tables' => [
            'communication_outlook_tokens' => api_table_exists($pdo, 'communication_outlook_tokens'),
            'communication_addin_sessions' => api_table_exists($pdo, 'communication_addin_sessions'),
            'communication_log' => api_table_exists($pdo, 'communication_log'),
        ],
    ]);
} catch (Throwable $exception) {
    api_json([
        'ok' => false,
        'message' => $exception->getMessage(),
    ], 500);
}
