<?php
require __DIR__.'/_bootstrap.php';
use Zoo\Database;
use Zoo\Auth\PlayerAuthService;
use Zoo\Wager\WithdrawalEligibilityService;
use Zoo\Wallet\WalletQuery;


try {
    $db=Database::connect();
    $user=(new PlayerAuthService($db))->authenticate([]);
    $eligibility=(new WithdrawalEligibilityService($db))->evaluate((int)$user['user_id']);
    $wallet=(new WalletQuery($db))->get((int)$user['user_id']);
    json_out(['ok'=>true,'eligibility'=>$eligibility,'wallet'=>$wallet]);
} catch(Throwable $e) {
    json_out(['ok'=>false,'error'=>$e->getMessage()],422);
}
