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

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

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

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

Node.js

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

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

  • ระบุขอบเขตการให้สิทธิ์ 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