• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/rest.php
  • Класс: BitrixImOpenLinesRest
  • Вызов: Rest::widgetDialogGet
static function widgetDialogGet($params, $n, CRestServer $server)
{
	if ($server->getAuthType() != WidgetAuth::AUTH_TYPE)
	{
		throw new RestException('Access for this method allowed only by livechat authorization.', 'WRONG_AUTH_TYPE', CRestServer::STATUS_FORBIDDEN);
	}

	global $USER;
	if (!$USER->IsAuthorized())
	{
		throw new RestException('Access for this method allowed only for authorized users.', 'WRONG_AUTH_TYPE', CRestServer::STATUS_FORBIDDEN);
	}

	$params = array_change_key_case($params, CASE_UPPER);

	$params['CONFIG_ID'] = (int)$params['CONFIG_ID'];
	if ($params['CONFIG_ID'] <= 0)
	{
		throw new RestException('Config id is not specified.', 'WRONG_REQUEST', CRestServer::STATUS_WRONG_REQUEST);
	}

	WidgetCache::set($USER->GetId(), [
 		'TRACE_DATA' => (string)$params['TRACE_DATA'],
 		'CUSTOM_DATA' => (string)$params['CUSTOM_DATA'],
	]);

	$chatId = isset($params['CHAT_ID']) ? (int)$params['CHAT_ID'] : 0;
	$result = WidgetDialog::get($USER->GetID(), $params['CONFIG_ID'], $chatId);
	if (!$result)
	{
		throw new RestException(
			WidgetDialog::getError()->msg,
			WidgetDialog::getError()->code,
			CRestServer::STATUS_WRONG_REQUEST
		);
	}

	return self::objectEncode($result);
}