getChannelMembersForUser method

Future<List<MmChannelMember>?> getChannelMembersForUser(
  1. String userId,
  2. String teamId
)

Get channel memberships and roles for a user

Get all channel memberships and associated membership roles (i.e. channel_user, channel_admin) for a user on a specific team. ##### Permissions Logged in as the user and view_team permission for the team. Having manage_system permission voids the previous requirements.

Parameters:

  • String userId (required): User GUID

  • String teamId (required): Team GUID

Implementation

Future<List<MmChannelMember>?> getChannelMembersForUser(
  String userId,
  String teamId,
) async {
  final response = await getChannelMembersForUserWithHttpInfo(
    userId,
    teamId,
  );
  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<MmChannelMember>') as List)
        .cast<MmChannelMember>()
        .toList();
  }
  return null;
}