sendAnnouncement method

Future<SendAnnouncementResponse> sendAnnouncement({
  1. required Content content,
  2. required List<Filter> roomFilters,
  3. String? clientRequestToken,
  4. int? timeToLiveInSeconds,
})

Triggers an asynchronous flow to send text, SSML, or audio announcements to rooms that are identified by a search or filter.

May throw LimitExceededException. May throw AlreadyExistsException.

Parameter content : The announcement content. This can contain only one of the three possible announcement types (text, SSML or audio).

Parameter roomFilters : The filters to use to send an announcement to a specified list of rooms. The supported filter keys are RoomName, ProfileName, RoomArn, and ProfileArn. To send to all rooms, specify an empty RoomFilters list.

Parameter clientRequestToken : The unique, user-specified identifier for the request that ensures idempotency.

Parameter timeToLiveInSeconds : The time to live for an announcement. Default is 300. If delivery doesn't occur within this time, the announcement is not delivered.

Implementation

Future<SendAnnouncementResponse> sendAnnouncement({
  required Content content,
  required List<Filter> roomFilters,
  String? clientRequestToken,
  int? timeToLiveInSeconds,
}) async {
  ArgumentError.checkNotNull(content, 'content');
  ArgumentError.checkNotNull(roomFilters, 'roomFilters');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    10,
    150,
  );
  _s.validateNumRange(
    'timeToLiveInSeconds',
    timeToLiveInSeconds,
    1,
    3600,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AlexaForBusiness.SendAnnouncement'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Content': content,
      'RoomFilters': roomFilters,
      'ClientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (timeToLiveInSeconds != null)
        'TimeToLiveInSeconds': timeToLiveInSeconds,
    },
  );

  return SendAnnouncementResponse.fromJson(jsonResponse.body);
}