• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/imopenlines/gotochat.php
  • Класс: Bitrix\Crm\Integration\ImOpenLines\GoToChat
  • Вызов: GoToChat::send
public function send(
	Channel $channel,
	string $lineId,
	Channel\Correspondents\From $from,
	Channel\Correspondents\To $to
): Result
{
	$result = new Result();

	if (!Loader::includeModule('imopenlines'))
	{
		$result->addError(new Error(Loc::getMessage('CRM_IMOL_MODULE_NOT_INSTALLED')));

		return $result;
	}

	$url = $this->getUrl($lineId, $to);
	$senderChannelId = $channel->getSender()::getSenderCode();

	if ($senderChannelId === SmsManager::getSenderCode())
	{
		$facilitator = (new \Bitrix\Crm\MessageSender\SendFacilitator\Sms($channel))
			->setMessageBody($this->getSmsText($url))
		;
	}
	elseif ($senderChannelId === NotificationsManager::getSenderCode())
	{
		$facilitator = (new \Bitrix\Crm\MessageSender\SendFacilitator\Notifications($channel))
			->setTemplateCode(self::NOTIFICATIONS_MESSAGE_CODE)
			->setPlaceholders([
				'URL' => $url,
			])
		;
	}
	else
	{
		$result->addError(new Error(Loc::getMessage('CRM_IMOL_WRONG_CHANNEL')));

		return $result;
	}

	return $facilitator
		->setFrom($from)
		->setTo($to)
		->setAdditionalFields([
			'HIGHLIGHT_URL' => $url,
		])
		->send()
	;
}