17
17
package com .google .workspace .api .chat .samples ;
18
18
19
19
import com .google .protobuf .util .JsonFormat ;
20
+
21
+ import java .util .List ;
22
+
20
23
// [START chat_update_message_app_cred]
24
+ import com .google .apps .card .v1 .Card ;
25
+ import com .google .apps .card .v1 .Card .CardHeader ;
26
+ import com .google .chat .v1 .CardWithId ;
21
27
import com .google .chat .v1 .ChatServiceClient ;
22
28
import com .google .chat .v1 .UpdateMessageRequest ;
23
29
import com .google .chat .v1 .Message ;
@@ -33,10 +39,14 @@ public static void main(String[] args) throws Exception {
33
39
.setMessage (Message .newBuilder ()
34
40
// replace SPACE_NAME and MESSAGE_NAME here
35
41
.setName ("spaces/SPACE_NAME/messages/MESSAGE_NAME" )
36
- .setText ("Updated with app credential!" ))
42
+ .setText ("Text updated with app credential!" )
43
+ .addCardsV2 (CardWithId .newBuilder ().setCard (Card .newBuilder ()
44
+ .setHeader (CardHeader .newBuilder ()
45
+ .setTitle ("Card updated with app credential!" )
46
+ .setImageUrl ("https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/24px.svg" )))))
37
47
.setUpdateMask (FieldMask .newBuilder ()
38
48
// The field paths to update.
39
- .addPaths ( "text" ));
49
+ .addAllPaths ( List . of ( "text" , "cards_v2" ) ));
40
50
Message response = chatServiceClient .updateMessage (request .build ());
41
51
42
52
System .out .println (JsonFormat .printer ().print (response ));
0 commit comments