<?php

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();

$apiKey = env('VIPRESELLER_API_KEY');
$apiId = env('VIPRESELLER_API_ID');
$sign = md5($apiId . $apiKey);

echo "🧪 Testing Free Fire Nickname Check\n\n";

$variations = [
    'free-fire',
    'freefire',
    'ff',
    'FF',
    'FreeFire',
];

foreach ($variations as $code) {
    echo "Testing code: $code\n";
    
    $response = \Illuminate\Support\Facades\Http::asForm()
        ->post('https://vip-reseller.co.id/api/game-feature', [
            'key' => $apiKey,
            'sign' => $sign,
            'type' => 'get-nickname',
            'code' => $code,
            'target' => '619166319',
        ]);
    
    $result = $response->json();
    
    if (isset($result['result']) && $result['result'] === true) {
        echo "✅ SUCCESS with code: $code\n";
        echo "Nickname: " . ($result['data'] ?? 'N/A') . "\n\n";
        break;
    } else {
        echo "❌ Failed: " . ($result['message'] ?? 'Unknown error') . "\n\n";
    }
}