fetchMembersAttributes method
Gets custom attributes of multiple group members by attribute key.
Param groupId
The group ID.
Param userIds
The array of user IDs of group members whose custom attributes are retrieved. You can pass in a maximum of 10 user IDs.
Param keys
The array of keys of custom attributes to be retrieved.
Return The users attributes.
Throws A description of the exception. See ChatError.
Implementation
Future<Map<String, Map<String, String>>> fetchMembersAttributes({
required String groupId,
required List<String> userIds,
List<String>? keys,
}) async {
Map req = {'groupId': groupId, 'userIds': userIds};
req.putIfNotNull("keys", keys);
Map result = await _channel.invokeMethod(
ChatMethodKeys.fetchMembersAttributesFromGroup, req);
try {
ChatError.hasErrorFromResult(result);
var map = result[ChatMethodKeys.fetchMembersAttributesFromGroup];
Map<String, Map<String, String>> ret = {};
if (map is Map) {
map.keys.forEach((element) {
if (map[element] is Map) {
Map<String, String> value =
Map<String, String>.from(map[element] ?? {});
ret[element] = value;
}
});
}
return ret;
} on ChatError catch (e) {
throw e;
}
}