Skip to content

Commit fca588a

Browse files
committed
Add People Advanced Service
1 parent 22af15b commit fca588a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

advanced/people.gs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
// [START apps_script_people_get_connections]
17+
/**
18+
* Gets a list of people in the user's contacts.
19+
*/
20+
function getConnections() {
21+
var people = People.People.Connections.list('people/me', {
22+
personFields: 'names,emailAddresses'
23+
});
24+
Logger.log('Connections: %s', JSON.stringify(people, null, 2));
25+
}
26+
// [END apps_script_people_get_connections]
27+
28+
// [START apps_script_people_get_self]
29+
/**
30+
* Gets the own user's profile.
31+
*/
32+
function getSelf() {
33+
var people = People.People.getBatchGet({
34+
resourceNames: ['people/me'],
35+
personFields: 'names,emailAddresses'
36+
});
37+
Logger.log('Myself: %s', JSON.stringify(people, null, 2));
38+
}
39+
// [END apps_script_people_get_self]
40+
41+
// [START apps_script_people_get_account]
42+
/**
43+
* Gets the person information for any Google Account.
44+
* @param {string} accountId The account ID.
45+
*/
46+
function getAccount(accountId) {
47+
var people = People.People.get('people/' + accountId, {
48+
personFields: 'names,emailAddresses'
49+
});
50+
Logger.log('Public Profile: %s', JSON.stringify(people, null, 2));
51+
}
52+
// [END apps_script_people_get_account]

0 commit comments

Comments
 (0)