replaceCards method

Future<Empty> replaceCards(
  1. ReplaceMessageCardsRequest request,
  2. String name, {
  3. String? $fields,
})

Replaces the cards included in a message.

A Chat app can only replace cards on a human-created message if the message already contains cards, and the cards were created by the app. If the app replaces the cards with an empty list, the cards are removed. After removing the cards, the app cannot add cards back to the message. Requires app authentication with the authorization scope:

  • https://www.googleapis.com/auth/chat.bot

request - The metadata request object.

Request parameters:

name - Required. The resource name of the message. Format: spaces/{space}/messages/{message} Value must have pattern ^spaces/\[^/\]+/messages/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a ReplaceMessageCardsResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<ReplaceMessageCardsResponse> replaceCards(
  ReplaceMessageCardsRequest request,
  core.String name, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    'fields': ?$fields == null ? null : [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$name') + ':replaceCards';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return ReplaceMessageCardsResponse.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}