/** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Agents\Calls\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ // Router::add([ Controller::class, "getAll" ]); // Router::add([ Controller::class, "get" ]); // Router::add([ Controller::class, "getTypeAsOptions" ]); // // Router::add([ Controller::class, "create" ]); // Router::add([ Controller::class, "save" ]); // Router::add([ Controller::class, "delete" ]); // Router::add([ Controller::class, "toggleStatus" ]); // // /* ### REST ROUTES ############################## # */ // Router::add([ Controller::class, "restConfigDetails" ]); // Router::add([ Controller::class, "restConfigCreate" ]); // Router::add([ Controller::class, "restConfigDelete" ]); // // Router::add([ Controller::class, "restResponseCreate" ]); // Router::add([ Controller::class, "restResponseSave" ]); // Router::add([ Controller::class, "restResponseDelete" ]); // Router::add([ Controller::class, "restResponseToggleStatus" ]); } } /** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Agents\Calls\API\v1; use ARUNOX\HTTP; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Agents; use ARUNOX\API\BaseController; class Controller extends BaseController { /* ### VARIABLES ################################################ # */ protected static array $NOTIFY = [ "notfound" => "Call nicht gefunden", "saved" => "Call wurde erfolgreich gespeichert", "deleted" => "Call wurde erfolgreich gelöscht", "created" => "Call wurde erfolgreich erstellt", "statuschanged.0" => "Call wurde erfolgreich deaktiviert", "statuschanged.1" => "Call wurde erfolgreich aktiviert", "notcreated" => "Call konnte nicht erstellt werden", "notsaved" => "Call konnte nicht gespeichert werden", ]; /* ### PUBLIC FUNCTIONS ######################################### # */ /** * @api * @method GET * * @route.path /agents/{id}/calls/{id} * @route.description Listet alle Calls eines Chats auf */ public static function getAllOwn( string $agentHashId, string $chatHashId, array $where = [] ) : array { return Agents\Calls\Model::getByAgent( $agentHashId, $chatHashId, $where ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /agents/{id}/tools/{id} * @route.description Aktualisiert die Eigenschaften eines Tools */ public static function save( string $agentHashId, string $chatHashId, array $data ) : HTTP\Response { if( $result = Calls\Tools\Model::get([ "id" => $id, "origin_id" => $origin ]) ) { if( $result->save( $data ) ) { return REST\Response::jsonResponse( 200, static::getNotify("saved") ); } return REST\Response::jsonResponse( 500, static::getNotify("notsaved") ); } return REST\Response::jsonResponse( 404, static::getNotify("notfound") ); } /** * @api * @method POST * * @route.path /agents/{id}/calls/{id} * @route.description Erstellt einen neuen Call für einen Chat */ public static function create( string $agentHashId, string $chatHashId, array $data ) : HTTP\Response { $data[ "origin_id" ] = Agents\Model::getValue( $agentHashId ); $data[ "chat_hashid" ] = $chatHashId; if( $hashid = Agents\Calls\Model::save( $data ) ) { $result = Agents\Calls\Model::get( $hashid ); return REST\Response::jsonResponse( 200, static::getNotify("created"), [ "data" => $result ] ); } return REST\Response::jsonResponse( 500, static::getNotify("notfound") ); } /** * @api * @method DELETE * * @route.path /agents/{id}/calls/{id} * @route.description Löscht ein Tool eines Agenten */ public static function delete( string $agentHashId, string $callHashId ) : HTTP\Response { $agent = Agents\Model::getValue( $agentHashId ); if( Agents\Calls\Model::delete([ "hashid" => $callHashId, "origin_id" => $agent ]) ) { return REST\Response::jsonResponse( 200, static::getNotify("deleted") ); } return REST\Response::jsonResponse( 500, static::getNotify("notfound") ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST FUNCTIONS #################################### # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /* ### PUBLIC REST TYPE FUNCTIONS ############################### # */ }