getChannels method

Future<ChatChannels?> getChannels()

Reports every chat channel this org can send through, and whether it can send through it right now.

Reports every chat channel this org can send through, and whether it can send through it right now. A channel appears here whether or not it is connected — an empty list would leave a caller unable to tell "this org has no Slack" from "Slack is down", which are different problems with different fixes. Each entry carries the connection behind it, so the answer to "why can I not post?" is in the same response as the channel that cannot post.

Implementation

Future<ChatChannels?> getChannels() async {
  final response = await getChannelsWithHttpInfo();
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(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), 'ChatChannels',) as ChatChannels;

  }
  return null;
}