getGroups method

Future<List<MmGroup>?> getGroups(
  1. String notAssociatedToTeam,
  2. String notAssociatedToChannel, {
  3. int? page,
  4. int? perPage,
  5. String? q,
  6. bool? includeMemberCount,
  7. int? since,
  8. bool? filterAllowReference,
})

Get groups

Retrieve a list of all groups not associated to a particular channel or team. not_associated_to_team OR not_associated_to_channel is required. If you use not_associated_to_team, you must be a team admin for that particular team (permission to manage that team). If you use not_associated_to_channel, you must be a channel admin for that particular channel (permission to manage that channel). Minimum server version: 5.11

Parameters:

  • String notAssociatedToTeam (required): Team GUID which is used to return all the groups not associated to this team

  • String notAssociatedToChannel (required): Group GUID which is used to return all the groups not associated to this channel

  • int page: The page to select.

  • int perPage: The number of groups per page.

  • String q: String to pattern match the name and display_name field. Will return all groups whose name and display_name field match any of the text.

  • bool includeMemberCount: Boolean which adds the member_count attribute to each group JSON object

  • int since: Only return groups that have been modified since the given Unix timestamp (in milliseconds). All modified groups, including deleted and created groups, will be returned. Minimum server version: 5.24

  • bool filterAllowReference: Boolean which filters the group entries with the allow_reference attribute set.

Implementation

Future<List<MmGroup>?> getGroups(
  String notAssociatedToTeam,
  String notAssociatedToChannel, {
  int? page,
  int? perPage,
  String? q,
  bool? includeMemberCount,
  int? since,
  bool? filterAllowReference,
}) async {
  final response = await getGroupsWithHttpInfo(
    notAssociatedToTeam,
    notAssociatedToChannel,
    page: page,
    perPage: perPage,
    q: q,
    includeMemberCount: includeMemberCount,
    since: since,
    filterAllowReference: filterAllowReference,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<MmGroup>') as List).cast<MmGroup>().toList();
  }
  return null;
}