<?php
declare(strict_types=1);

header('Content-Type: application/json');

require_once __DIR__ . '/_bootstrap.php';

try {
    // TODO: v0.2.0 - wire to real IMAP getQuota()
    $usedBytes = 2200000000;
    $totalBytes = 5368709120;
    $percent = 41;
    $breakdown = [
        'sent' => 500000000,
        'drafts' => 50000000,
        'inbox' => 1500000000,
        'other' => 150000000
    ];

    echo json_encode([
        'used_bytes' => $usedBytes,
        'total_bytes' => $totalBytes,
        'percent' => $percent,
        'breakdown' => $breakdown
    ]);
} catch (\Throwable $e) {
    http_response_code(500);
    echo json_encode(['error' => $e->getMessage()]);
}