listChannelMessages method

Future<ListChannelMessagesResponse> listChannelMessages({
  1. required String channelArn,
  2. int? maxResults,
  3. String? nextToken,
  4. DateTime? notAfter,
  5. DateTime? notBefore,
  6. SortOrder? sortOrder,
})

List all the messages in a channel. Returns a paginated list of ChannelMessages. Sorted in descending order by default, based on the creation timestamp.

May throw BadRequestException. May throw ForbiddenException. May throw UnauthorizedClientException. May throw ThrottledClientException. May throw ServiceUnavailableException. May throw ServiceFailureException.

Parameter channelArn : The ARN of the channel.

Parameter maxResults : The maximum number of messages that you want returned.

Parameter nextToken : The token passed by previous API calls until all requested messages are returned.

Parameter notAfter : The final or ending time stamp for your requested messages.

Parameter notBefore : The initial or starting time stamp for your requested messages.

Parameter sortOrder : The order in which you want messages sorted. Default is Descending, based on time created.

Implementation

Future<ListChannelMessagesResponse> listChannelMessages({
  required String channelArn,
  int? maxResults,
  String? nextToken,
  DateTime? notAfter,
  DateTime? notBefore,
  SortOrder? sortOrder,
}) async {
  ArgumentError.checkNotNull(channelArn, 'channelArn');
  _s.validateStringLength(
    'channelArn',
    channelArn,
    5,
    1600,
    isRequired: true,
  );
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    50,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    0,
    2048,
  );
  final $query = <String, List<String>>{
    if (maxResults != null) 'max-results': [maxResults.toString()],
    if (nextToken != null) 'next-token': [nextToken],
    if (notAfter != null)
      'not-after': [_s.iso8601ToJson(notAfter).toString()],
    if (notBefore != null)
      'not-before': [_s.iso8601ToJson(notBefore).toString()],
    if (sortOrder != null) 'sort-order': [sortOrder.toValue()],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/channels/${Uri.encodeComponent(channelArn)}/messages',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListChannelMessagesResponse.fromJson(response);
}