• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat.php
  • Класс: BitrixImV2Chat
  • Вызов: Chat::toRestFormat
public function toRestFormat(array $option = []): array
{
	if ($option['CHAT_SHORT_FORMAT'] ?? false)
	{
		return [
			'avatar' => $this->getAvatar(),
			'color' => (string)$this->getColor() !== '' ? Color::getColor($this->getColor()) : Color::getColorByNumber($this->getChatId()),
			'description' => $this->getDescription() ?? '',
			'dialogId' => $this->getDialogId(),
			'diskFolderId' => $this->getDiskFolderId(),
			'entityData1' => $this->getEntityData1() ?? '',
			'entityData2' => $this->getEntityData2() ?? '',
			'entityData3' => $this->getEntityData3() ?? '',
			'entityId' => $this->getEntityId() ?? '',
			'entityType' => $this->getEntityType() ?? '',
			'extranet' => $this->getExtranet() ?? false,
			'id' => $this->getId(),
			'name' => $this->getTitle(),
			'owner' => (int)$this->getAuthorId(),
			'messageType' => $this->getType(),
			'role' => $this->getRole(),
			'type' => $this->getTypeForRest(),
			'manageUsers' => mb_strtolower($this->getManageUsers()),
			'manageUi' => mb_strtolower($this->getManageUI()),
			'manageSettings' => mb_strtolower($this->getManageSettings()),
			'canPost' => mb_strtolower($this->getCanPost()),
		];
	}

	return [
		'avatar' => $this->getAvatar(),
		'color' => (string)$this->getColor() !== '' ? Color::getColor($this->getColor()) : Color::getColorByNumber($this->getChatId()),
		'counter' => $this->getReadService()->getCounterService()->getByChat($this->getChatId()),
		'dateCreate' => $this->getDateCreate() === null ? null : $this->getDateCreate()->format('c'),
		'description' => $this->getDescription() ?? '',
		'dialogId' => $this->getDialogId(),
		'diskFolderId' => $this->getDiskFolderId(),
		'entityData1' => $this->getEntityData1() ?? '',
		'entityData2' => $this->getEntityData2() ?? '',
		'entityData3' => $this->getEntityData3() ?? '',
		'entityId' => $this->getEntityId() ?? '',
		'entityType' => $this->getEntityType() ?? '',
		'extranet' => $this->getExtranet() ?? false,
		'id' => $this->getId(),
		'lastMessageId' => $this->getLastMessageId(),
		'lastMessageViews' => ImCommon::toJson($this->getLastMessageViews()),
		'lastId' => $this->getLastId(),
		'managerList' => $this->getManagerList(),
		'markedId' => $this->getMarkedId(),
		'messageCount' => $this->getMessageCount(),
		'messageType' => $this->getType(),
		'muteList' => $this->getMuteList(),
		'name' => $this->getTitle(),
		'owner' => (int)$this->getAuthorId(),
		'public' => $this->getPublicOption() ?? '',
		'role' => mb_strtolower($this->getRole()),
		'type' => $this->getTypeForRest(),
		'unreadId' => $this->getUnreadId(),
		'userCounter' => $this->getUserCount(),
		'manageUsers' => mb_strtolower($this->getManageUsers()),
		'manageUi' => mb_strtolower($this->getManageUI()),
		'manageSettings' => mb_strtolower($this->getManageSettings()),
		'canPost' => mb_strtolower($this->getCanPost()),
	];
}