<?php
require_once __DIR__ . '/../bootstrap.php';

use Gestoreasy\Core\Kernel;
use Gestoreasy\Core\Http\Request;
use Gestoreasy\Core\Auth\Jwt;

$kernel = new Kernel();
$payload = [ 'sub' => 1, 'email' => 'admin@local', 'name' => 'Admin', 'tenant' => 'default', 'roles' => ['admin'] ];
$token = Jwt::sign($payload);
$headers = [ 'x-tenant-id' => 'default', 'authorization' => 'Bearer ' . $token ];
$body = [
  'company' => 'Empresa Debug CRM',
  'contact_name' => 'Debug',
  'email' => 'debug@example.com',
  'phone' => '11999990000',
  'source' => 'debug',
  'stage_id' => 1,
  'status' => 'ativo',
  'value_cents' => 50000,
  'notes' => 'Script debug'
];
$req = new Request($headers, [], $body, [], 'POST', '/api/vendas/crm/leads');
$res = $kernel->handle($req);
echo "Status: {$res->status}\n";
var_dump($res->body);
?>