$method, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 45 ]); if ($payload !== null) { curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); } $body = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($body === false || $status < 200 || $status >= 300) { throw new Exception("HTTP $status: " . ($body ?: curl_error($ch))); } curl_close($ch); return json_decode($body, true); } function values($proximity, $certification, $load, $safety, $rating) { return [ "proximity_score" => $proximity, "certification_match_score" => $certification, "current_job_load" => $load, "safety_history_score" => $safety, "customer_rating_score" => $rating ]; } try { $identityUrl = getenv("DECISIOQ_IDENTITY_URL") ?: "https://identity.vinquery.com/connect/token"; $catalogUrl = rtrim(getenv("DECISIOQ_DKS_URL") ?: "https://dks.vinquery.com", "/"); $decisionServiceUrl = rtrim(getenv("DECISIOQ_DDE_URL") ?: "https://dde.vinquery.com", "/"); $correlationId = "auto-tow-019-php-" . bin2hex(random_bytes(8)); $tokenResponse = request_json("POST", $identityUrl, [ "clientId" => required_env("DECISIOQ_CLIENT_ID"), "clientSecret" => required_env("DECISIOQ_CLIENT_SECRET"), "audience" => getenv("DECISIOQ_AUDIENCE") ?: "vinquery:api:decisioq" ]); $token = $tokenResponse["jwtToken"]; request_json("GET", "$catalogUrl/decisioncatalog/decisions/AUTO-TOW-019", null, $token, $correlationId); $result = request_json("POST", "$decisionServiceUrl/api/v1/decide", [ "decisionId" => "AUTO-TOW-019", "profileId" => "balanced", "scenarioId" => "standard", "algorithm" => "TOPSIS", "weightStrategy" => "Expert", "runSensitivity" => false, "requestContext" => ["correlationId" => $correlationId], "options" => [ ["optionId" => "OPTION-001", "name" => "Operator North Zone", "values" => values(88, 88, 1, 88, 88)], ["optionId" => "OPTION-002", "name" => "Operator Central Zone", "values" => values(80, 80, 3, 80, 80)], ["optionId" => "OPTION-003", "name" => "Operator East Zone", "values" => values(72, 72, 5, 72, 72)] ] ], $token, $correlationId); echo json_encode($result, JSON_PRETTY_PRINT) . PHP_EOL; } catch (Exception $ex) { fwrite(STDERR, $ex->getMessage() . PHP_EOL); exit(1); } ?>