listChannelMessages method
List all the messages in a channel. Returns a paginated list of
ChannelMessages. By default, sorted by creation timestamp in
descending order.
Also, the x-amz-chime-bearer request header is mandatory. Use
the ARN of the AppInstanceUser or AppInstanceBot
that makes the API call as the value in the header.
May throw BadRequestException.
May throw ForbiddenException.
May throw ServiceFailureException.
May throw ServiceUnavailableException.
May throw ThrottledClientException.
May throw UnauthorizedClientException.
Parameter channelArn :
The ARN of the channel.
Parameter chimeBearer :
The ARN of the AppInstanceUser or AppInstanceBot
that makes the API call.
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.
Parameter subChannelId :
The ID of the SubChannel in the request.
Implementation
Future<ListChannelMessagesResponse> listChannelMessages({
required String channelArn,
required String chimeBearer,
int? maxResults,
String? nextToken,
DateTime? notAfter,
DateTime? notBefore,
SortOrder? sortOrder,
String? subChannelId,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
1,
50,
);
final headers = <String, String>{
'x-amz-chime-bearer': chimeBearer.toString(),
};
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.value],
if (subChannelId != null) 'sub-channel-id': [subChannelId],
};
final response = await _protocol.send(
payload: null,
method: 'GET',
requestUri: '/channels/${Uri.encodeComponent(channelArn)}/messages',
queryParams: $query,
headers: headers,
exceptionFnMap: _exceptionFns,
);
return ListChannelMessagesResponse.fromJson(response);
}