Files
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

100 lines
3.4 KiB
PHP

<?php
namespace SPVoipIntegration\api;
class ZebraClient {
private $url;
private $authToken;
private $accountId;
public function __construct() {
$this->url = \Settings_SPVoipIntegration_Record_Model::getZebraApiUrl();
$this->authenticate();
}
public function registerWebhook($params){
$method = 'accounts/' . $this->accountId . '/webhooks';
return $this->call($method, $params, 'PUT');
}
public function getWebhooks() {
$method = 'accounts/' . $this->accountId . '/webhooks';
return $this->call($method)['data'];
}
public function deleteWebhook($webhookId) {
$method = 'accounts/' . $this->accountId . '/webhooks/' . $webhookId;
return $this->call($method, array(), 'DELETE');
}
public function makeCall($from, $to) {
$method = 'accounts/' . $this->accountId . '/devices/' . $from . '/quickcall/' . $to;
return $this->call($method);
}
private function call($method, $params = array(), $requestType = 'GET') {
if (empty($this->authToken)) {
$this->authenticate();
}
$ch = curl_init();
$fullURL = $this->url . $method;
curl_setopt($ch, CURLOPT_URL, $fullURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $requestType);
if ($requestType != 'GET') {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
}
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "X-Auth-Token: {$this->authToken}";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
throw new \Exception($error);
}
$responseArr = json_decode($response, true);
$errorCode = $responseArr['error_code'];
if (!empty($errorCode)) {
throw new \Exception($responseArr['error_message']);
}
return $responseArr;
}
private function authenticate() {
$ch = curl_init();
$params = array( 'data' => array(
'login' => \Settings_SPVoipIntegration_Record_Model::getZebraLogin(),
'password' => \Settings_SPVoipIntegration_Record_Model::getZebraPassword(),
'realm' => \Settings_SPVoipIntegration_Record_Model::getZebraRealm()
));
curl_setopt($ch, CURLOPT_URL, $this->url . "user_auth");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
throw new \Exception($error);
}
$responseArr = json_decode($response, true);
$errorCode = $responseArr['error_code'];
if (!empty($errorCode)) {
throw new \Exception($responseArr['error_message']);
}
$this->authToken = $responseArr['data']['auth_token'];
$this->accountId = $responseArr['data']['account_id'];
return $response;
}
}