fetchMemberAttributes method

Future<Map<String, String>> fetchMemberAttributes({
  1. required String groupId,
  2. String? userId,
})

~english Gets all custom attributes of a group member.

Param groupId The group ID.

Param userId The user ID of the group member whose all custom attributes are retrieved. The default value is the current user ID.

Return The user attributes of the group member.

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

~chinese 获取单个群成员所有自定义属性。

Param groupId 群组 ID。

Param userId 要获取的自定义属性的群成员的用户 ID, 默认为当前用户 ID。

Return 需要查询的用户属性。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 ChatError。 ~end

Implementation

Future<Map<String, String>> fetchMemberAttributes({
  required String groupId,
  String? userId,
}) async {
  Map req = {'groupId': groupId};
  if (userId != null) {
    req.putIfNotNull('userId', userId);
  }
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.fetchMemberAttributesFromGroup, req);
  try {
    ChatError.hasErrorFromResult(result);
    Map<String, String> ret = {};
    result[ChatMethodKeys.fetchMemberAttributesFromGroup]
        .forEach((key, value) {
      ret[key] = value;
    });
    return ret;
  } on ChatError catch (e) {
    throw e;
  }
}