Skip to content

Commit

Permalink
feat: update message with app creds (#1166)
Browse files Browse the repository at this point in the history
Co-authored-by: pierrick <pierrick@google.com>
  • Loading branch information
PierrickVoulet and pierrick authored Oct 3, 2024
1 parent cfb3a31 commit 26cb124
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
package com.google.workspace.api.chat.samples;

import com.google.protobuf.util.JsonFormat;

import java.util.List;

// [START chat_update_message_app_cred]
import com.google.apps.card.v1.Card;
import com.google.apps.card.v1.Card.CardHeader;
import com.google.chat.v1.CardWithId;
import com.google.chat.v1.ChatServiceClient;
import com.google.chat.v1.UpdateMessageRequest;
import com.google.chat.v1.Message;
Expand All @@ -33,10 +39,14 @@ public static void main(String[] args) throws Exception {
.setMessage(Message.newBuilder()
// replace SPACE_NAME and MESSAGE_NAME here
.setName("spaces/SPACE_NAME/messages/MESSAGE_NAME")
.setText("Updated with app credential!"))
.setText("Text updated with app credential!")
.addCardsV2(CardWithId.newBuilder().setCard(Card.newBuilder()
.setHeader(CardHeader.newBuilder()
.setTitle("Card updated with app credential!")
.setImageUrl("https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/24px.svg")))))
.setUpdateMask(FieldMask.newBuilder()
// The field paths to update.
.addPaths("text"));
.addAllPaths(List.of("text", "cards_v2")));
Message response = chatServiceClient.updateMessage(request.build());

System.out.println(JsonFormat.printer().print(response));
Expand Down

0 comments on commit 26cb124

Please sign in to comment.