Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add create and set up space code samples #489

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions chat/advanced-service/Main.gs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,29 @@ function createMessageUserCredThreadName() {
}
// [END chat_create_message_user_cred_thread_name]

// [START chat_create_space_user_cred]
/**
* This sample shows how to create space with user credential
*
* It relies on the OAuth2 scope 'https://www.googleapis.com/auth/chat.spaces.create'
* referenced in the manifest file (appsscript.json).
*/
function createSpaceUserCred() {
// Initialize request argument(s)
const space = {
spaceType: 'SPACE',
// TODO(developer): Replace DISPLAY_NAME here
displayName: 'DISPLAY_NAME'
};

// Make the request
const response = Chat.Spaces.create(space);

// Handle the response
console.log(response);
}
// [END chat_create_space_user_cred]

// [START chat_delete_message_app_cred]
/**
* This sample shows how to delete a message with app credential
Expand Down Expand Up @@ -674,6 +697,38 @@ function listSpacesUserCred() {
}
// [END chat_list_spaces_user_cred]

// [START chat_set_up_space_user_cred]
/**
* This sample shows how to set up a named space with one initial member with
* user credential.
*
* It relies on the OAuth2 scope 'https://www.googleapis.com/auth/chat.spaces.create'
* referenced in the manifest file (appsscript.json).
*/
function setUpSpaceUserCred() {
// Initialize request argument(s)
const space = {
spaceType: 'SPACE',
// TODO(developer): Replace DISPLAY_NAME here
displayName: 'DISPLAY_NAME'
};
const memberships = [{
member: {
// TODO(developer): Replace USER_NAME here
name: 'users/USER_NAME',
// User type for the membership
type: 'HUMAN'
}
}];

// Make the request
const response = Chat.Spaces.setup({ space: space, memberships: memberships });

// Handle the response
console.log(response);
}
// [END chat_set_up_space_user_cred]

// [START chat_update_message_app_cred]
/**
* This sample shows how to update a message with app credential
Expand Down
1 change: 1 addition & 0 deletions chat/advanced-service/appsscript.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/chat.spaces",
"https://www.googleapis.com/auth/chat.spaces.create",
"https://www.googleapis.com/auth/chat.spaces.readonly",
"https://www.googleapis.com/auth/chat.memberships",
"https://www.googleapis.com/auth/chat.memberships.app",
Expand Down
Loading