patch method
Updates a message.
There's a difference between the patch and update methods. The patch
method uses a patch request while the update method uses a put
request. We recommend using the patch method. For an example, see
Update a message.
Supports the following types of
authentication:
App authentication
with the authorization scope: - https://www.googleapis.com/auth/chat.bot
User authentication
with one of the following authorization scopes: -
https://www.googleapis.com/auth/chat.messages -
https://www.googleapis.com/auth/chat.import (import mode spaces only)
When using app authentication, requests can only update messages created
by the calling Chat app.
request - The metadata request object.
Request parameters:
name - Identifier. Resource name of the message. Format:
spaces/{space}/messages/{message} Where {space} is the ID of the space
where the message is posted and {message} is a system-assigned ID for
the message. For example,
spaces/AAAAAAAAAAA/messages/BBBBBBBBBBB.BBBBBBBBBBB. If you set a custom
ID when you create a message, you can use this ID to specify the message
in a request by replacing {message} with the value from the
clientAssignedMessageId field. For example,
spaces/AAAAAAAAAAA/messages/client-custom-name. For details, see
Name a message.
Value must have pattern ^spaces/\[^/\]+/messages/\[^/\]+$.
allowMissing - Optional. If true and the message isn't found, a new
message is created and updateMask is ignored. The specified message ID
must be
[client-assigned](https://developers.google.com/workspace/chat/create-messages#name_a_created_message)
or the request fails.
updateMask - Required. The field paths to update. Separate multiple
values with commas or use * to update all field paths. Currently
supported field paths: - text - attachment - cards (Requires [app
authentication](/chat/api/guides/auth/service-accounts).) - cards_v2
(Requires [app authentication](/chat/api/guides/auth/service-accounts).)
accessory_widgets(Requires [app authentication](/chat/api/guides/auth/service-accounts).) -quoted_message_metadata(Only allows removal of the quoted message.)
$fields - Selector specifying which fields to include in a partial
response.
Completes with a Message.
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<Message> patch(
Message request,
core.String name, {
core.bool? allowMissing,
core.String? updateMask,
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (allowMissing != null) 'allowMissing': ['${allowMissing}'],
if (updateMask != null) 'updateMask': [updateMask],
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v1/' + core.Uri.encodeFull('$name');
final response_ = await _requester.request(
url_,
'PATCH',
body: body_,
queryParams: queryParams_,
);
return Message.fromJson(response_ as core.Map<core.String, core.dynamic>);
}