removeUserFromChannel method

Future<MmStatusOK?> removeUserFromChannel(
  1. String channelId,
  2. String userId
)

Remove user from channel

Delete a channel member, effectively removing them from a channel. In server version 5.3 and later, channel members can only be deleted from public or private channels. ##### Permissions manage_public_channel_members permission if the channel is public. manage_private_channel_members permission if the channel is private.

Parameters:

  • String channelId (required): Channel GUID

  • String userId (required): User GUID

Implementation

Future<MmStatusOK?> removeUserFromChannel(
  String channelId,
  String userId,
) async {
  final response = await removeUserFromChannelWithHttpInfo(
    channelId,
    userId,
  );
  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) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'MmStatusOK',
    ) as MmStatusOK;
  }
  return null;
}