64 lines
1.9 KiB
PHP
Executable File
64 lines
1.9 KiB
PHP
Executable File
<?php
|
|
$initialDir = getcwd();
|
|
chdir(__DIR__ . '/../');
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use Ubnt\UcrmPluginSdk\Service\UcrmApi;
|
|
use Ubnt\UcrmPluginSdk\Service\PluginConfigManager;
|
|
use GuzzleHttp\Client;
|
|
|
|
$config = PluginConfigManager::create()->loadConfig();
|
|
$ipServer = $config['ipserver'] ?? 'localhost';
|
|
$apiUrl = "https://$ipServer/crm/api/v1.0/";
|
|
$token = $config['apitoken'] ?? '';
|
|
|
|
$client = new Client([
|
|
'base_uri' => $apiUrl,
|
|
'verify' => false,
|
|
'headers' => [
|
|
'X-Auth-App-Key' => $token,
|
|
'Content-Type' => 'application/json',
|
|
],
|
|
]);
|
|
$ucrmApi = new UcrmApi($client, $token);
|
|
|
|
$ids = [18, 20];
|
|
$customAttributeKey = 'passwordAntenaCliente';
|
|
|
|
foreach ($ids as $id) {
|
|
try {
|
|
$data = $ucrmApi->get("clients/$id");
|
|
echo "Client ID: $id\n";
|
|
echo "IsArchived: " . ($data['isArchived'] ? 'Yes' : 'No') . "\n";
|
|
|
|
echo "All Attributes:\n";
|
|
foreach ($data['attributes'] as $attr) {
|
|
echo " - {$attr['key']} (ID: {$attr['customAttributeId']}): [{$attr['value']}]\n";
|
|
}
|
|
flush();
|
|
|
|
$passVal = null;
|
|
$foundKey = false;
|
|
foreach ($data['attributes'] as $attr) {
|
|
if ($attr['key'] === $customAttributeKey) {
|
|
$passVal = $attr['value'];
|
|
$foundKey = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($foundKey) {
|
|
echo "Attribute '$customAttributeKey' FOUND.\n";
|
|
echo "Value: [" . $passVal . "]\n";
|
|
echo "Type: " . gettype($passVal) . "\n";
|
|
echo "Empty? " . (empty($passVal) ? 'Yes' : 'No') . "\n";
|
|
} else {
|
|
echo "Attribute '$customAttributeKey' NOT FOUND in attributes list.\n";
|
|
}
|
|
echo "--------------------------------------\n";
|
|
} catch (\Exception $e) {
|
|
echo "Error fetching $id: " . $e->getMessage() . "\n";
|
|
}
|
|
}
|