- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::departmentGet
static function departmentGet($arParams, $offset, CRestServer $server)
{
if (
BitrixImUser::getInstance()->isExtranet()
|| BitrixImUser::getInstance()->isBot()
)
{
throw new BitrixRestRestException("Only intranet users have access to this method.", "ACCESS_ERROR", CRestServer::STATUS_FORBIDDEN);
}
$arParams = array_change_key_case($arParams, CASE_UPPER);
$ids = Array();
if (is_string($arParams['ID']))
{
$arParams['ID'] = CUtil::JsObjectToPhp($arParams['ID']);
}
if (is_array($arParams['ID']))
{
foreach ($arParams['ID'] as $id)
{
$id = intval($id);
if ($id > 0)
{
$ids[$id] = $id;
}
}
}
if (empty($ids))
{
throw new BitrixRestRestException("A wrong format for the ID field is passed", "INVALID_FORMAT", CRestServer::STATUS_WRONG_REQUEST);
}
$options = Array(
'FILTER' => Array('ID' => $ids),
'USER_DATA' => $arParams['USER_DATA'] == 'Y'? 'Y': 'N',
'JSON' => 'Y',
);
$result = BitrixImDepartment::getStructure($options);
return $result;
}