$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($fit, $demand, $margin, $cost, $risk, $customer) { return [ "assign_rental_vehicle_customer_fit_score" => $fit, "assign_rental_vehicle_vehicle_or_resource_fit" => $demand, "assign_rental_vehicle_operational_readiness" => $margin, "assign_rental_vehicle_financial_impact" => $cost, "assign_rental_vehicle_risk_exposure" => $risk, "assign_rental_vehicle_time_sensitivity" => $customer ]; } 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-rent-008-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-RENT-008", null, $token, $correlationId); $result = request_json("POST", "$decisionServiceUrl/api/v1/decide", [ "decisionId" => "AUTO-RENT-008", "profileId" => "balanced", "scenarioId" => "standard_rental", "algorithm" => "TOPSIS", "weightStrategy" => "Expert", "runSensitivity" => false, "requestContext" => ["correlationId" => $correlationId], "options" => [ ["optionId" => "OPTION-001", "name" => "Compact SUV Unit", "values" => values(88, 91, 84, 76, 20, 26)], ["optionId" => "OPTION-002", "name" => "Standard Sedan Unit", "values" => values(79, 85, 92, 70, 18, 34)], ["optionId" => "OPTION-003", "name" => "Premium SUV Unit", "values" => values(92, 73, 68, 88, 42, 50)] ] ], $token, $correlationId); echo json_encode($result, JSON_PRETTY_PRINT) . PHP_EOL; } catch (Exception $ex) { fwrite(STDERR, $ex->getMessage() . PHP_EOL); exit(1); } ?>