- Модуль: voximplant
- Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_rest.php
- Класс: CVoxImplantRestService
- Вызов: CVoxImplantRestService::addExternalLine
static function addExternalLine($params, $n, $server)
{
if ($server->getAuthType() !== OAuthAuth::AUTH_TYPE && $server->getAuthType() !== APAuthAuth::AUTH_TYPE)
{
throw new BitrixRestAuthTypeException();
}
$clientId = $server->getClientId();
$row = BitrixRestAppTable::getByClientId($clientId);
$appId = $row['ID'];
$newExternalLine = [
'NAME' => (string)($params['NAME'] ?? ''),
'NUMBER' => (string)($params['NUMBER'] ?? ''),
'CRM_AUTO_CREATE' => ($params['CRM_AUTO_CREATE'] ?? 'Y') === 'Y' ? 'Y' : 'N',
];
$result = RestHelper::addExternalLine($newExternalLine, $appId);
if (!$result->isSuccess())
{
throw new BitrixRestRestException(implode('; ', $result->getErrorMessages()));
}
$code = $row['CODE'] ? : 'webHook' . $server->getPasswordId();
if ($code)
{
AddEventToStatFile(
'voximplant',
'addExternalLine',
uniqid($code, true),
$code,
'type' . $params['TYPE']
);
}
return $result->getData();
}