= 300) { throw new RuntimeException("{$method} {$url} failed with HTTP {$status}: {$body}"); } return $body === '' ? [] : json_decode($body, true, flags: JSON_THROW_ON_ERROR); } $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-auct-006-php-' . bin2hex(random_bytes(8)); $tokenResponse = json_request($identityUrl, 'POST', null, [ "clientId" => required_env("DECISIOQ_CLIENT_ID"), "clientSecret" => required_env("DECISIOQ_CLIENT_SECRET"), "audience" => getenv("DECISIOQ_AUDIENCE") ?: "vinquery:api:decisioq", ]); $jwtToken = $tokenResponse['jwtToken'] ?? null; if (!is_string($jwtToken) || trim($jwtToken) === '') { throw new RuntimeException('Token response did not contain jwtToken.'); } json_request($catalogUrl . '/decisioncatalog/decisions/AUTO-AUCT-006', 'GET', $jwtToken, null, $correlationId); $executionRequest = [ 'decisionId' => 'AUTO-AUCT-006', 'profileId' => 'balanced', 'scenarioId' => 'standard', 'algorithm' => 'TOPSIS', 'weightStrategy' => 'Expert', 'runSensitivity' => false, 'requestContext' => ['correlationId' => $correlationId], 'options' => [ [ 'optionId' => 'MANHEIM-TORONTO', 'name' => 'Manheim Toronto', 'values' => [ 'vehicle_availability_score' => 88, 'buyer_fee_level' => 1250, 'average_vehicle_quality' => 88, 'distance_to_facility' => 54, 'auction_reputation_score' => 88, 'title_processing_speed' => 88, ], ], [ 'optionId' => 'ADESA-TORONTO', 'name' => 'ADESA Toronto', 'values' => [ 'vehicle_availability_score' => 81, 'buyer_fee_level' => 1750, 'average_vehicle_quality' => 81, 'distance_to_facility' => 71, 'auction_reputation_score' => 81, 'title_processing_speed' => 81, ], ], ], ]; $result = json_request($decisionServiceUrl . '/api/v1/decide', 'POST', $jwtToken, $executionRequest, $correlationId); echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;