Business-Logik flexibel auslagern und erweitern
<?php
use EnneoSDK\Api;
use EnneoSDK\IntentInfo;
use EnneoSDK\IntentOption;
use EnneoSDK\Interaction;
require(getenv()['SDK'] ?? 'sdk.php');
/** @var stdClass $in */
// Create a mocked API response:
//{
// "data": {
// "_action": null
// },
// "options": [
// {
// "type": "success",
// "name": "Ok",
// "icon": "check",
// "recommended": true,
// "order": 0,
// "handler": ""
// }
// ],
// "infos": [
// {
// "type": "success",
// "message": "API-Aufruf erfolgreich",
// "extraInfo": null,
// "code": null
// }
// ]
//}
$interaction = new Interaction($in);
$interaction->infos[] = new IntentInfo(
type: 'success',
message: 'API-Aufruf erfolgreich'
);
$interaction->options[] = new IntentOption(
type: 'success',
name: 'Ok',
recommended: true
);
// TODO: replace this "echo" API call by your own API call. Use ApiEnneo::executeUdf to use custom code.
// E.g.:
//ApiEnneo::executeUdf(
// 'customApiCall',
// [
// "method" => "POST",
// "api" => sprintf('contract/%s/anyApi', $in->_metadata->inputParameters->contractId),
// "params" => (array) $in
// ]
//);
$response = Api::call(
method: 'POST',
url: 'https://echo.enneo.ai',// echo.enneo.ai
params: json_decode(json_encode($interaction), true)
);
$result = $response;
echo json_encode($result);
exit();