<?php
declare(strict_types=1);
require_once __DIR__.'/common.php';
apiMethod('POST');
$cfg=apiCfg($mysqli);$device=apiAuth($mysqli);
apiOut(200,[
    'ok'=>true,
    'agent_id'=>$device['agent_id'],
    'status'=>$device['status'],
    'server_time'=>date(DATE_ATOM),
    'last_communication'=>$device['ultima_comunicacao'],
    'sync_interval_min'=>(int)($cfg['sync_interval_min']??30),
    'collect_apps'=>(bool)($cfg['collect_apps']??1),
    'current_app_version'=>(string)($cfg['current_app_version']??'1.0.0'),
    'current_app_version_code'=>(int)($cfg['current_app_version_code']??1),
    'tracked_apps'=>apiTrackedApps($mysqli)
]);
?>
