• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_rest.php
  • Класс: CVoxImplantRestService
  • Вызов: CVoxImplantRestService::updateExternalLine
static function updateExternalLine($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'];

	$updatingFields = [];
	if (isset($params['NAME']))
	{
		$updatingFields['NAME'] = (string)$params['NAME'];
	}
	if (isset($params['CRM_AUTO_CREATE']))
	{
		$updatingFields['CRM_AUTO_CREATE'] = $params['CRM_AUTO_CREATE'] === 'Y' ? 'Y' : 'N';
	}

	if (empty($updatingFields))
	{
		throw new BitrixRestRestException('There are no fields to update');
	}

	$result = RestHelper::updateExternalLine($params['NUMBER'], $updatingFields, $appId);
	if (!$result->isSuccess())
	{
		throw new BitrixRestRestException(implode('; ', $result->getErrorMessages()));
	}

	return $result->getData();
}