Skip to content
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
66 changes: 33 additions & 33 deletions advanced/adsense.gs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function listAccounts() {
let pageToken;
do {
const response = AdSense.Accounts.list({pageToken: pageToken});
if (response.accounts) {
for (const account of response.accounts) {
Logger.log('Found account with resource name "%s" and display name "%s".',
account.name, account.displayName);
}
} else {
if (!response.accounts) {
Logger.log('No accounts found.');
return;
}
for (const account of response.accounts) {
Logger.log('Found account with resource name "%s" and display name "%s".',
account.name, account.displayName);
}
pageToken = response.nextPageToken;
} while (pageToken);
Expand All @@ -47,15 +47,15 @@ function listAdClients(accountName) {
const response = AdSense.Accounts.Adclients.list(accountName, {
pageToken: pageToken
});
if (response.adClients) {
for (const adClient of response.adClients) {
Logger.log('Found ad client for product "%s" with resource name "%s".',
adClient.productCode, adClient.name);
Logger.log('Reporting dimension ID: %s',
adClient.reportingDimensionId ?? 'None');
}
} else {
if (!response.adClients) {
Logger.log('No ad clients found for this account.');
return;
}
for (const adClient of response.adClients) {
Logger.log('Found ad client for product "%s" with resource name "%s".',
adClient.productCode, adClient.name);
Logger.log('Reporting dimension ID: %s',
adClient.reportingDimensionId ?? 'None');
}
pageToken = response.nextPageToken;
} while (pageToken);
Expand All @@ -75,13 +75,13 @@ function listAdUnits(adClientName) {
pageSize: 50,
pageToken: pageToken
});
if (response.adUnits) {
for (const adUnit of response.adUnits) {
Logger.log('Found ad unit with resource name "%s" and display name "%s".',
adUnit.name, adUnit.displayName);
}
} else {
if (!response.adUnits) {
Logger.log('No ad units found for this ad client.');
return;
}
for (const adUnit of response.adUnits) {
Logger.log('Found ad unit with resource name "%s" and display name "%s".',
adUnit.name, adUnit.displayName);
}

pageToken = response.nextPageToken;
Expand Down Expand Up @@ -114,22 +114,22 @@ function generateReport(accountName, adClientReportingDimensionId) {
orderBy: ['+DATE']
});

if (report.rows) {
const spreadsheet = SpreadsheetApp.create('AdSense Report');
const sheet = spreadsheet.getActiveSheet();
if (!report.rows) {
Logger.log('No rows returned.');
return;
}
const spreadsheet = SpreadsheetApp.create('AdSense Report');
const sheet = spreadsheet.getActiveSheet();

// Append the headers.
sheet.appendRow(report.headers.map((header) => header.name));
// Append the headers.
sheet.appendRow(report.headers.map((header) => header.name));

// Append the results.
sheet.getRange(2, 1, report.rows.length, report.headers.length)
.setValues(report.rows.map((row) => row.cells.map((cell) => cell.value)));
// Append the results.
sheet.getRange(2, 1, report.rows.length, report.headers.length)
.setValues(report.rows.map((row) => row.cells.map((cell) => cell.value)));

Logger.log('Report spreadsheet created: %s',
spreadsheet.getUrl());
} else {
Logger.log('No rows returned.');
}
Logger.log('Report spreadsheet created: %s',
spreadsheet.getUrl());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions advanced/classroom.gs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START classroom_list_courses]
// [START apps_script_classroom_list_courses]
/**
* Lists 10 course names and IDs.
*/
Expand Down Expand Up @@ -41,4 +41,4 @@ function listCourses() {
Logger.log('Failed with error %s', err.message);
}
}
// [END classroom_list_courses]
// [END apps_script_classroom_list_courses]
24 changes: 12 additions & 12 deletions advanced/slides.gs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

// [START slides_create_presentation]
// [START apps_script_slides_create_presentation]
/**
* Create a new presentation.
* @return {string} presentation Id.
Expand All @@ -31,9 +31,9 @@ function createPresentation() {
Logger.log('Failed with error %s', e.message);
}
}
// [END slides_create_presentation]
// [END apps_script_slides_create_presentation]

// [START slides_create_slide]
// [START apps_script_slides_create_slide]
/**
* Create a new slide.
* @param {string} presentationId The presentation to add the slide to.
Expand Down Expand Up @@ -63,9 +63,9 @@ function createSlide(presentationId) {
Logger.log('Failed with error %s', e.message);
}
}
// [END slides_create_slide]
// [END apps_script_slides_create_slide]

// [START slides_read_page]
// [START apps_script_slides_read_page]
/**
* Read page element IDs.
* @param {string} presentationId The presentation to read from.
Expand All @@ -86,9 +86,9 @@ function readPageElementIds(presentationId, pageId) {
Logger.log('Failed with error %s', e.message);
}
}
// [END slides_read_page]
// [END apps_script_slides_read_page]

// [START slides_add_text_box]
// [START apps_script_slides_add_text_box]
/**
* Add a new text box with text to a page.
* @param {string} presentationId The presentation ID.
Expand Down Expand Up @@ -144,9 +144,9 @@ function addTextBox(presentationId, pageId) {
Logger.log('Failed with error %s', e.message);
}
}
// [END slides_add_text_box]
// [END apps_script_slides_add_text_box]

// [START slides_format_shape_text]
// [START apps_script_slides_format_shape_text]
/**
* Format the text in a shape.
* @param {string} presentationId The presentation ID.
Expand Down Expand Up @@ -188,9 +188,9 @@ function formatShapeText(presentationId, shapeId) {
Logger.log('Failed with error %s', e.message);
}
}
// [END slides_format_shape_text]
// [END apps_script_slides_format_shape_text]

// [START slides_save_thumbnail]
// [START apps_script_slides_save_thumbnail]
/**
* Saves a thumbnail image of the current Google Slide presentation in Google Drive.
* Logs the image URL.
Expand All @@ -215,4 +215,4 @@ function saveThumbnailImage(i) {
Logger.log('Failed with error %s', e.message);
}
}
// [END slides_save_thumbnail]
// [END apps_script_slides_save_thumbnail]
15 changes: 15 additions & 0 deletions apps-script/execute/target.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START apps_script_api_execute]
/**
* Return the set of folder names contained in the user's root folder as an
Expand Down