<?php
// Test API endpoint for strategy call bookings
$testPayload = [
    'name'             => 'Elon Musk',
    'email'            => 'elon@x.com',
    'phone'            => '+1 555 123 4567',
    'company'          => 'X Corp',
    'country'          => 'United States',
    'subject'          => 'Fintech Infrastructure',
    'interests'        => ['Fintech Infrastructure', 'Enterprise Systems & OS'],
    'timeline'         => 'Ready to start immediately',
    'budget'           => '$50k – $100k',
    'meeting_platform' => 'Google Meet',
    'preferred_date'   => '2026-08-25',
    'preferred_time'   => '02:00 PM',
    'timezone'         => 'EST (UTC-5)',
    'description'      => 'Need to launch instant crypto and fiat wallet systems.'
];

$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';

// Simulate POST to submit-strategy-call.php
ob_start();
$_POST = $testPayload;
include __DIR__ . '/../api/submit-strategy-call.php';
$response = ob_get_clean();

echo "API Response:\n" . $response . "\n";

$dataFile = __DIR__ . '/../data/strategy_leads.json';
if (file_exists($dataFile)) {
    $leads = json_decode(file_get_contents($dataFile), true);
    echo "Saved Leads Count: " . count($leads) . "\n";
    echo "Latest Lead ID: " . $leads[0]['id'] . "\n";
    echo "Latest Lead Name: " . $leads[0]['name'] . "\n";
} else {
    echo "Data file not found!\n";
}
