<?php
require __DIR__.'/_bootstrap.php';

use Zoo\Database;
use Zoo\Auth\PlayerAuthService;
use Zoo\Reward\VipMinuteGiftService;
use Zoo\Wallet\WalletQuery;

try{
    $db=Database::connect();
    $player=(new PlayerAuthService($db))->authenticate([]);
    $uid=(int)$player['user_id'];

    $svc=new VipMinuteGiftService($db);

    json_out([
      'ok'=>true,
      'status'=>$svc->status($uid),
      'recent_minutes'=>$svc->recentMinutes($uid,20),
      'wallet'=>(new WalletQuery($db))->get($uid)
    ]);
}catch(Throwable $e){
    json_out(['ok'=>false,'error'=>$e->getMessage()],422);
}
