사용자의 스페이스 알림 설정 가져오기

이 가이드에서는 Google Chat API의 SpaceNotificationSetting 리소스에서 get() 메서드를 사용하여 사용자의 스페이스 알림 설정을 가져오는 방법을 설명합니다.

SpaceNotificationSetting 리소스는 지정된 사용자의 스페이스 알림 설정에 관한 세부정보를 나타내는 싱글톤 리소스입니다.

기본 요건

Node.js

통화하는 사용자의 스페이스 알림 설정 가져오기

사용자의 스페이스 알림 설정에 관한 세부정보를 가져오려면 요청에 다음을 포함합니다.

  • chat.users.spacesettings 승인 범위를 지정합니다.
  • GetSpaceNotificationSetting() 메서드를 호출하여 스페이스 알림 설정의 name를 전달하여 사용자 ID 또는 별칭과 스페이스 ID가 포함된 값을 가져옵니다. 발신자의 알림 설정만 가져올 수 있습니다. 설정을 지정하려면 다음 중 하나를 사용하세요.
    • me 별칭입니다. 예를 들면 users/me/spaces/SPACE_ID/spaceNotificationSetting입니다.
    • 발신자의 Google Workspace 이메일 주소입니다. 예를 들면 다음과 같습니다. users/user@example.com/spaces/SPACE_ID/spaceNotificationSetting
    • 호출 사용자의 사용자 ID입니다. 예를 들면 다음과 같습니다. 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);
}

main().catch(console.error);

이 샘플을 실행하려면 SPACE_ID를 스페이스의 name에 있는 ID로 바꿉니다. ListSpaces() 메서드를 호출하거나 스페이스의 URL에서 ID를 가져올 수 있습니다.

Google Chat API는 지정된 스페이스 알림 설정을 가져와 SpaceNotificationSetting의 인스턴스를 반환합니다.