<?php
declare(strict_types=1);

require_once dirname(__DIR__) . '/_bootstrap.php';

golder_require_method('GET');
$ctx = golder_api_auth('desktop_sync');

$devices = golder_list_customer_devices($ctx['master'], (int)$ctx['customer_id']);
$devices = array_values(array_filter($devices, static function ($d): bool {
    return (int)($d['is_blocked'] ?? 0) === 0
        && (int)($d['is_active_device'] ?? 0) === 1;
}));

golder_json_response([
    'status' => 'ok',
    'devices' => $devices,
]);


