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

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

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

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

Node.js

  • บัญชี Google Workspace สำหรับธุรกิจหรือองค์กร ที่มีสิทธิ์เข้าถึง 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);
}

await main();

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

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