fetchChatRoomAttributes method

Future<Map<String, String>?> fetchChatRoomAttributes({
  1. required String roomId,
  2. List<String>? keys,
})

~english Gets the list of custom chat room attributes based on the attribute key list.

Param roomId The chat room ID.

Param keys The key list of attributes to get. If you set it as null or leave it empty, this method retrieves all custom attributes.

Return The chat room attributes in key-value pairs.

Throws A description of the exception. See ChatError. ~end

~chinese 根据属性键列表获取自定义聊天室属性的列表。

Param roomId 聊天室 ID。

Param keys 要获取的属性的键列表。如果将其设置为“null”或留空,此方法将检索所有自定义属性。

Return 键值对应的聊天室属性。

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError。 ~end

Implementation

Future<Map<String, String>?> fetchChatRoomAttributes({
  required String roomId,
  List<String>? keys,
}) async {
  Map req = {
    "roomId": roomId,
  };

  if (keys != null) {
    req['keys'] = keys;
  }

  Map result = await _channel.invokeMethod(
    ChatMethodKeys.fetchChatRoomAttributes,
    req,
  );
  try {
    ChatError.hasErrorFromResult(result);
    return result[ChatMethodKeys.fetchChatRoomAttributes]
        ?.cast<String, String>();
  } on ChatError catch (e) {
    throw e;
  }
}