getUserGroups method

Future<List<GroupName>> getUserGroups({
  1. required String accountId,
  2. String? username,
  3. String? key,
})

Returns the groups to which a user belongs.

Permissions required: Browse users and groups global permission.

Implementation

Future<List<GroupName>> getUserGroups(
    {required String accountId, String? username, String? key}) async {
  return (await _client.send(
    'get',
    'rest/api/3/user/groups',
    queryParameters: {
      'accountId': accountId,
      if (username != null) 'username': username,
      if (key != null) 'key': key,
    },
  ) as List<Object?>)
      .map((i) => GroupName.fromJson(i as Map<String, Object?>? ?? const {}))
      .toList();
}