<?php
$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$payload = [
    'form_type' => 'newsletter_subscription',
    'email'     => 'newsletter.subscriber@example.com'
];
ob_start();
$_POST = $payload;
include __DIR__ . '/../api/submit-lead.php';
$response = ob_get_clean();

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

$dataFile = __DIR__ . '/../data/leads.json';
if (file_exists($dataFile)) {
    $leads = json_decode(file_get_contents($dataFile), true);
    echo "Leads Count: " . count($leads) . "\n";
    echo "Latest Lead Type: " . $leads[0]['form_type'] . "\n";
    echo "Latest Email: " . $leads[0]['email'] . "\n";
}
