- Модуль: voximplant
- Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_outgoing.php
- Класс: CVoxImplantOutgoing
- Вызов: CVoxImplantOutgoing::StartInfoCallWithText
static function StartInfoCallWithText($outputNumber, $number, $text, $voiceLanguage = '', $voiceSpeed = '', $voiceVolume = '')
{
$result = new Result();
CVoxImplantHistory::WriteToLog(Array($outputNumber, $number, $text, $voiceLanguage, $voiceSpeed, $voiceVolume), 'StartInfoCallWithText');
if ($outputNumber === CVoxImplantConfig::LINK_BASE_NUMBER)
{
$result->addError(new Error('Making infocall using LINK_BASE_NUMBER is not allowed'));
return $result;
}
$numberConfig = CVoxImplantConfig::GetConfigBySearchId($outputNumber);
if (isset($numberConfig['ERROR']))
{
$result->addError(new Error('Could not find config for number '.$outputNumber));
return $result;
}
$limitRemainder = VILimits::getInfocallsLimitRemainder($numberConfig['PORTAL_MODE']);
if($limitRemainder === 0)
{
$result->addError(new Error('Infocall limit for this month is exceeded'));
return $result;
}
if($numberConfig['PORTAL_MODE'] === CVoxImplantConfig::MODE_SIP)
$phoneNormalized = $number;
else
$phoneNormalized = CVoxImplantPhone::stripLetters($number);
if (!$phoneNormalized)
{
$result->addError(new Error('Phone number is not correct'));
return $result;
}
$voiceLanguage = $voiceLanguage ?: TtsLanguage::getDefaultVoice(BitrixMainContext::getCurrent()->getLanguage());
$voiceSpeed = $voiceSpeed ?: TtsSpeed::getDefault();
$voiceVolume = $voiceVolume ?: TtsVolume::getDefault();
$options = array(
'MODE' => self::INFOCALL_MODE_TEXT,
'VOICE_LANGUAGE' => $voiceLanguage,
'VOICE_SPEED' => $voiceSpeed,
'VOICE_VOLUME' => $voiceVolume
);
$httpClient = new CVoxImplantHttp();
$infoCallResult = $httpClient->StartInfoCall($phoneNormalized, $text, $options, $numberConfig);
if($infoCallResult === false)
{
$result->addError(new Error('Infocall failure'));
return $result;
}
CVoxImplantHistory::WriteToLog($result, 'Infocall started');
if($limitRemainder > 0)
{
VILimits::addInfocall($numberConfig['PORTAL_MODE']);
}
$result->setData(array(
'CALL_ID' => $infoCallResult->call_id
));
return $result;
}