<?php
// TEMP DEBUG - upload to ajax/smsman_pricedebug.php, visit, then DELETE
define('VALID_ACCESS', true);
require_once dirname(__DIR__) . '/include/config.php';
require_once dirname(__DIR__) . '/include/SMSMan.php';
header('Content-Type: text/plain; charset=utf-8');

$token    = $site_data['smsman_api_token'] ?? '';
$base_url = $site_data['smsman_api_url']   ?? 'https://api.sms-man.com/control';
$sm = new SMSMan($token, $base_url);

// Test with Nigeria (id=103) - common test country
$country_id = (int)($_GET['cid'] ?? 103);
echo "=== getPrices($country_id) ===\n";
$r = $sm->getPrices($country_id);
echo "success: " . ($r['success'] ? 'true' : 'false') . "\n";
if ($r['success']) {
    $data = $r['data'];
    echo "Top-level keys: " . implode(', ', array_keys(array_slice($data, 0, 5, true))) . " ...\n";
    echo "Total entries: " . count($data) . "\n\n";
    echo "=== FIRST 3 ENTRIES ===\n";
    $i = 0;
    foreach ($data as $k => $v) {
        echo "[$k] => " . json_encode($v) . "\n";
        if (++$i >= 3) break;
    }
} else {
    echo "Error: " . $r['error_msg'] . "\n";
}

echo "\n\n=== getLimits($country_id) ===\n";
$r2 = $sm->getLimits($country_id);
echo "success: " . ($r2['success'] ? 'true' : 'false') . "\n";
if ($r2['success']) {
    $data2 = $r2['data'];
    echo "Total entries: " . count($data2) . "\n";
    echo "Is sequential: " . (isset($data2[0]) ? 'YES' : 'NO') . "\n\n";
    echo "=== FIRST 3 ENTRIES ===\n";
    $i = 0;
    foreach ($data2 as $k => $v) {
        echo "[$k] => " . json_encode($v) . "\n";
        if (++$i >= 3) break;
    }
} else {
    echo "Error: " . $r2['error_msg'] . "\n";
}
echo "\nDELETE THIS FILE AFTER USE\n";