<?php
header('Content-Type: application/json; charset=utf-8');

$placa = "PQA4703";
$email = "rickcooder@gmail.com";
$phone = "62996494518";
$fingerprint = "t9vF262pEP0uG0oFnk5q";
$terminal = "4068707027";

// 1. Consulta Inicial do Veículo (Pega ID e Renavam Criptografado)
$urlVehicle = "https://nfbti53lkd.execute-api.us-east-2.amazonaws.com/dev/site/vehicle/{$placa}?plate={$placa}&email={$email}&phone={$phone}&document=&renavam=&chassi=&uf=GO&skipDatacubeSearch=false&tpDebt=&fingerprintId={$fingerprint}";

$headers = [
    "accept: application/json, text/plain, */*",
    "origin: https://www.zignet.com.br",
    "referer: https://www.zignet.com.br/",
    "terminal: {$terminal}",
    "x-fingerprint-site-id: {$fingerprint}",
    "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"
];

$ch = curl_init($urlVehicle);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$responseVehicle = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo json_encode([
    "step" => "vehicle_lookup",
    "status_code" => $httpCode,
    "response" => json_decode($responseVehicle, true)
], JSON_PRETTY_PRINT);

// Se o veículo for encontrado, o próximo passo seria buscar os débitos:
// https://nfbti53lkd.execute-api.us-east-2.amazonaws.com/dev/site/debts/{id_veiculo}
