searchChannels method

Future<SearchChannelsResponse> searchChannels({
  1. required List<SearchField> fields,
  2. String? chimeBearer,
  3. int? maxResults,
  4. String? nextToken,
})

Allows the ChimeBearer to search channels by channel members. Users or bots can search across the channels that they belong to. Users in the AppInstanceAdmin role can search across all channels.

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 fields : A list of the Field objects in the channel being searched.

Parameter chimeBearer : The AppInstanceUserArn of the user making the API call.

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

Parameter nextToken : The token returned from previous API requests until the number of channels is reached.

Implementation

Future<SearchChannelsResponse> searchChannels({
  required List<SearchField> fields,
  String? chimeBearer,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    50,
  );
  final headers = <String, String>{
    if (chimeBearer != null) 'x-amz-chime-bearer': chimeBearer.toString(),
  };
  final $query = <String, List<String>>{
    if (maxResults != null) 'max-results': [maxResults.toString()],
    if (nextToken != null) 'next-token': [nextToken],
  };
  final $payload = <String, dynamic>{
    'Fields': fields,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/channels?operation=search',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return SearchChannelsResponse.fromJson(response);
}