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

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

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

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

Node.js

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

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

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

  • ระบุขอบเขตการให้สิทธิ์ chat.users.spacesettings
  • เรียกใช้เมธอด GetSpaceNotificationSetting() โดยส่ง name ของการตั้งค่าการแจ้งเตือนของพื้นที่ทำงานเพื่อรับ ซึ่งมีรหัสผู้ใช้หรือชื่อแทนและรหัสพื้นที่ทำงาน คุณจะได้รับการตั้งค่าการแจ้งเตือน สำหรับผู้ใช้ที่โทรเท่านั้น หากต้องการระบุการตั้งค่า ให้ใช้วิธีใดวิธีหนึ่งต่อไปนี้
    • อีเมลแทนของ me เช่น users/me/spaces/SPACE_ID/spaceNotificationSetting
    • อีเมล Google Workspace ของผู้ใช้ที่โทร เช่น users/user@example.com/spaces/SPACE_ID/spaceNotificationSetting
    • รหัสผู้ใช้ของผู้ใช้ที่โทร เช่น users/USER/spaces/SPACE/spaceNotificationSetting

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

Node.js

chat/client-libraries/cloud/get-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 get 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 = {
    name: 'users/me/spaces/SPACE_NAME/spaceNotificationSetting',
  };

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

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

await main();

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

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