
<?php
// Router updates in api.php or index.php
require_once 'controllers/CallAnalyticsController.php';
require_once 'helpers/auth_helper.php';
require_once 'helpers/response_helper.php';

$callAnalyticsController = new CallAnalyticsController();


// Authenticate
$decoded = authenticate();
$user_id = $decoded->user_id ?? null;
$user_role = $decoded->user_type ?? null;


// Routes
if ($method === 'GET' && $uri === '/call-analytics-overall') {
    $response = $callAnalyticsController->getOverallMetrics($_GET, $user_id, $user_role);
    logAndRespond($user_id, $user_role, '/call-analytics-overall', $response, 'GET', $_GET);
}

if ($method === 'GET' && $uri === '/call-analytics-ipo-performance') {
    $response = $callAnalyticsController->getIpoPerformance($_GET, $user_id, $user_role);
    logAndRespond($user_id, $user_role, '/call-analytics-ipo-performance', $response, 'GET', $_GET);
}

if ($method === 'GET' && $uri === '/call-analytics-outcomes') {
    $response = $callAnalyticsController->getCallOutcomes($_GET, $user_id, $user_role);
    logAndRespond($user_id, $user_role, '/call-analytics-outcomes', $response, 'GET', $_GET);
}

if ($method === 'GET' && $uri === '/call-analytics-trends') {
    $response = $callAnalyticsController->getDailyTrends($_GET, $user_id, $user_role);
    logAndRespond($user_id, $user_role, '/call-analytics-trends', $response, 'GET', $_GET);
}

