อัปเดตการตั้งค่าการแจ้งเตือนพื้นที่ทำงานของผู้ใช้

คู่มือนี้จะอธิบายวิธีใช้วิธี patch() ในทรัพยากร SpaceNotificationSetting ของ Google Chat API เพื่ออัปเดตการตั้งค่าการแจ้งเตือนของพื้นที่ทำงานของผู้ใช้

SpaceNotificationSetting ทรัพยากรเป็นทรัพยากรแบบ Singleton ที่แสดงรายละเอียดเกี่ยวกับการตั้งค่าการแจ้งเตือนของพื้นที่ทำงานของผู้ใช้ที่ระบุ

ข้อกำหนดเบื้องต้น

Node.js

  • บัญชี Google Workspace รุ่น Business หรือ Enterprise ที่มีสิทธิ์เข้าถึง Google Chat

อัปเดตการตั้งค่าการแจ้งเตือนพื้นที่ทำงานของผู้ใช้ที่โทร

หากต้องการอัปเดตการตั้งค่าการแจ้งเตือนของพื้นที่ทำงานของผู้ใช้ ให้ระบุข้อมูลต่อไปนี้ในคำขอ

  • ระบุchat.users.spacesettingsขอบเขตการให้สิทธิ์
  • เรียกใช้เมธอด UpdateSpaceNotificationSetting() โดยส่งคําขอ UpdateSpaceNotificationSetting ที่มีการเปลี่ยนแปลงการตั้งค่าการแจ้งเตือน คำขอประกอบด้วยข้อมูลต่อไปนี้
    • spaceNotificationSetting ที่มีพร็อพเพอร์ตี้ต่อไปนี้
      • พร็อพเพอร์ตี้ name จะระบุการตั้งค่าการแจ้งเตือนของพื้นที่ทำงานที่จะอัปเดต ซึ่งรวมถึงรหัสผู้ใช้หรืออีเมลแทน และรหัสพื้นที่ทำงาน การอัปเดตการตั้งค่าการแจ้งเตือนของพื้นที่ทำงานจะรองรับเฉพาะการอัปเดตการตั้งค่าการแจ้งเตือนของผู้ใช้ที่โทร ซึ่งระบุได้โดยการตั้งค่าอย่างใดอย่างหนึ่งต่อไปนี้
        • ชื่อแทน me เช่น users/me/spaces/SPACE/spaceNotificationSetting
        • อีเมล Workspace ของผู้ใช้ที่โทร เช่น users/user@example.com/spaces/SPACE/spaceNotificationSetting
        • รหัสผู้ใช้ของผู้ใช้ที่โทร เช่น users/USER/spaces/SPACE/spaceNotificationSetting
      • notificationSetting: กำหนดระดับการแจ้งเตือน เช่น ALL, OFF
      • muteSetting: เปิดหรือปิดการปิดเสียง ค่าอาจเป็น MUTED หรือ UNMUTED
    • updateMask: ตั้งค่าช่องอัปเดต ซึ่งอาจรวมถึง notification_setting, mute_setting

ตัวอย่างต่อไปนี้จะอัปเดตการตั้งค่าการแจ้งเตือนพื้นที่ทำงานของผู้ใช้ที่โทร

Node.js
chat/client-libraries/cloud/update-space-notification-setting-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.users.spacesettings'];

// This sample shows how to update the space notification setting for the calling user
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);

  // Initialize request argument(s), replace the SPACE_NAME with an actual space name.
  const request = {
    spaceNotificationSetting : {
    	name : 'users/me/spaces/SPACE_NAME/spaceNotificationSetting',
    	notificationSetting : 'ALL',
    	muteSetting : 'UNMUTED'
    },
    updateMask : { paths: ['notification_setting','mute_setting']}
  };

  // Make the request
  const response = await chatClient.updateSpaceNotificationSetting(request);

  // Handle the response
  console.log(response);
}

main().catch(console.error);

หากต้องการเรียกใช้ตัวอย่างนี้ ให้แทนที่ SPACE_NAME ด้วยรหัสจาก name ของพื้นที่ทำงาน คุณรับรหัสได้โดยเรียกใช้เมธอด ListSpaces() หรือจาก URL ของพื้นที่ทำงาน

Google Chat API จะอัปเดตการตั้งค่าการแจ้งเตือนของพื้นที่ทำงานที่ระบุและแสดงผลอินสแตนซ์ของ SpaceNotificationSetting