- Created `quick-replies.blade.php` for managing quick replies. - Added `settings.blade.php` for admin settings management. - Implemented `ticket-show.blade.php` to display ticket details. - Introduced `timeline-card.blade.php` component for displaying timeline information. Enhance quick reply management functionality - Developed `quick-reply-manager.blade.php` for creating and editing quick replies. - Integrated Livewire for dynamic interaction and validation. Implement settings page for AI configuration - Created `settings-page.blade.php` for managing AI settings, including prompts and provider instances. - Added functionality for managing models and embeddings. Add ticket show functionality with real-time updates - Implemented ticket details view with processing status and tool call logs. - Added support for displaying article suggestions and error messages. Create unit tests for AI classifier and domain info tool - Added `AIClassifierServiceTest.php` to validate AI classifier functionality. - Implemented `DomainInfoToolTest.php` for domain parameter validation. - Created `OxxaClientTest.php` to test API interactions and password hashing.
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Tools;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
class DomainInfoTool
|
|
{
|
|
public const ACTION = 'domain_inf';
|
|
|
|
public function __construct(private readonly OxxaClient $client) {}
|
|
|
|
public function execute(array $parameters, array $credentials): array
|
|
{
|
|
$parameters = $this->validateParameters($parameters);
|
|
|
|
return $this->client->request(self::ACTION, [
|
|
'apiuser' => (string) ($credentials['apiuser'] ?? ''),
|
|
'apipassword' => (string) ($credentials['apipassword'] ?? ''),
|
|
'sld' => $parameters['sld'],
|
|
'tld' => $parameters['tld'],
|
|
]);
|
|
}
|
|
|
|
public function validateParameters(array $parameters): array
|
|
{
|
|
$sld = mb_strtolower(trim((string) ($parameters['sld'] ?? '')));
|
|
$tld = mb_strtolower(trim((string) ($parameters['tld'] ?? '')));
|
|
|
|
if ($sld === '' || $tld === '') {
|
|
throw new InvalidArgumentException('domain_inf requires both sld and tld parameters.');
|
|
}
|
|
|
|
if (preg_match('/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/', $sld) !== 1) {
|
|
throw new InvalidArgumentException('domain_inf parameter sld is invalid.');
|
|
}
|
|
|
|
if (preg_match('/^[a-z0-9-]{2,63}(?:\.[a-z0-9-]{2,63})*$/', $tld) !== 1) {
|
|
throw new InvalidArgumentException('domain_inf parameter tld is invalid.');
|
|
}
|
|
|
|
return [
|
|
'sld' => $sld,
|
|
'tld' => $tld,
|
|
];
|
|
}
|
|
}
|