Skip to content

Commit a9f6c4f

Browse files
Merge pull request googleworkspace#1 from gsuitedevs/master
Catch up
2 parents 89a24d7 + 171487c commit a9f6c4f

File tree

21 files changed

+648
-101
lines changed

21 files changed

+648
-101
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
"camelcase": "off", // Off for destructuring
1313
"async-await/space-after-async": 2,
1414
"async-await/space-after-await": 2,
15+
"eqeqeq": 2,
1516
"guard-for-in": "off",
1617
"no-var": "off", // ES3
1718
"no-unused-vars": "off" // functions aren't used.

advanced/gmail.gs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function logRecentHistory() {
8383
if (history && history.length > 0) {
8484
history.forEach(function(record) {
8585
record.messages.forEach(function(message) {
86-
if (changed.indexOf(message.id) == -1) {
86+
if (changed.indexOf(message.id) === -1) {
8787
changed.push(message.id);
8888
}
8989
});

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]

advanced/youtube.gs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function retrieveMyUploads() {
5151
// Channel resource: https://developers.google.com/youtube/v3/docs/channels
5252
var playlistId = item.contentDetails.relatedPlaylists.uploads;
5353
var nextPageToken;
54-
while (nextPageToken != null) {
54+
while (nextPageToken !== null) {
5555
var playlistResponse = YouTube.PlaylistItems.list('snippet', {
5656
playlistId: playlistId,
5757
maxResults: 25,

classroom/snippets/courseUpdate.gs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 classroom_update_course]
17+
/**
18+
* Updates the section and room of Google Classroom.
19+
*/
20+
function courseUpdate() {
21+
var courseId = '123456';
22+
var course = Classroom.Courses.get(courseId);
23+
course.section = 'Period 3';
24+
course.room = '302';
25+
var course = Classroom.Courses.update(course, courseId);
26+
Logger.log('Course "%s" updated.', course.name);
27+
}
28+
// [END classroom_update_course]

classroom/snippets/createCourse.gs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 classroom_create_course]
17+
/**
18+
* Creates 10th Grade Biology Course.
19+
*/
20+
function createCourse() {
21+
var course = {
22+
name: '10th Grade Biology',
23+
section: 'Period 2',
24+
descriptionHeading: 'Welcome to 10th Grade Biology',
25+
description: "We'll be learning about about the structure of living creatures from a combination of textbooks, guest lectures, and lab work. Expect to be excited!",
26+
room: '301',
27+
ownerId: 'me',
28+
courseState: 'PROVISIONED'
29+
};
30+
var course = Classroom.Courses.create(course);
31+
Logger.log('Course created: %s (%s)', course.name, course.id)
32+
}
33+
// [END classroom_create_course]

classroom/snippets/getCourse.gs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 classroom_get_course]
17+
/**
18+
* Retrieves course by id.
19+
*/
20+
function getCourse() {
21+
var courseId = '123456';
22+
try {
23+
var course = Classroom.Courses.get(courseId);
24+
Logger.log('Course "%s" found. ', course.name);
25+
} catch (err) {
26+
Logger.log("Course with id "%s" not found", courseId);
27+
}
28+
}
29+
// [END classroom_get_course]

classroom/snippets/listCourses.gs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 classroom_list_courses]
17+
/**
18+
* Lists all course names and ids.
19+
*/
20+
function listCourses() {
21+
var courses = [];
22+
var pageToken = null;
23+
var optionalArgs = {
24+
pageToken: pageToken,
25+
pageSize: 100
26+
};
27+
while (true) {
28+
var response = Classroom.Courses.list(optionalArgs);
29+
var courses = response.courses;
30+
if (!pageToken) {
31+
break;
32+
}
33+
}
34+
if (courses.length === 0) {
35+
Logger.log("No courses found.");
36+
} else {
37+
Logger.log("Courses:");
38+
for (course in courses) {
39+
Logger.log('%s (%s)', courses[course].name, courses[course].id);
40+
}
41+
}
42+
}
43+
// [END classroom_list_courses]

0 commit comments

Comments
 (0)