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

fix: use requestBody instead of resource #345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions apps-script/execute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ async function callAppsScript() {
const script = google.script({version: 'v1', auth});

try {
// Make the API request. The request object is included here as 'resource'.
// Make the API request. The request object is included here as 'requestBody'.
const resp = await script.scripts.run({
auth: auth,
resource: {
requestBody: {
function: 'getFoldersUnderRoot',
},
scriptId: scriptId,
Expand Down
4 changes: 2 additions & 2 deletions apps-script/quickstart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ async function authorize() {
async function callAppsScript(auth) {
const script = google.script({version: 'v1', auth});
let res = await script.projects.create({
resource: {
requestBody: {
title: 'My Script',
},
});
res = await script.projects.updateContent({
scriptId: res.data.scriptId,
auth,
resource: {
requestBody: {
files: [
{
name: 'hello',
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/appdata_snippets/upload_appdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function uploadAppdata() {
};
try {
const file = await service.files.insert({
resource: fileMetadata,
requestBody: fileMetadata,
media: media,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/drive_snippets/create_drive.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function createDrive() {
const requestId = uuid.v4();
try {
const Drive = await service.drives.insert({
resource: driveMetadata,
requestBody: driveMetadata,
requestId: requestId,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/drive_snippets/recover_drives.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function recoverDrives(userEmail) {
drive.id,
);
await service.permissions.insert({
resource: newOrganizerPermission,
requestBody: newOrganizerPermission,
fileId: drive.id,
useDomainAdminAccess: true,
supportsAllDrives: true,
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/file snippets/create_folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function createFolder() {
};
try {
const file = await service.files.insert({
resource: fileMetadata,
requestBody: fileMetadata,
fields: 'id',
});
console.log('Folder Id:', file.data.id);
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/file snippets/create_shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function createShortcut() {

try {
const file = await service.files.insert({
resource: fileMetadata,
requestBody: fileMetadata,
fields: 'id',
});
console.log('File Id:', file.data.id);
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/file snippets/share_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function shareFile(fileId, targetUser, targetDomain) {
for (const permission of permissions) {
try {
const result = await service.permissions.insert({
resource: permission,
requestBody: permission,
fileId: fileId,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/file snippets/touch_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function touchFile(fileId, timestamp) {
const file = await service.files.update({
fileId: fileId,
setModifiedDate: true,
resource: fileMetadata,
requestBody: fileMetadata,
fields: 'id, modifiedDate',
});
console.log('Modified time:', file.data.modifiedDate);
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/file snippets/upload_basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function uploadBasic() {
};
try {
const file = await service.files.insert({
resource: fileMetadata,
requestBody: fileMetadata,
media: media,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/file snippets/upload_to_folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function uploadToFolder(folderId) {

try {
const file = await service.files.insert({
resource: fileMetadata,
requestBody: fileMetadata,
media: media,
fields: 'id',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function uploadWithConversion() {

try {
const file = await service.files.insert({
resource: fileMetadata,
requestBody: fileMetadata,
media: media,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/appdata_snippets/upload_appdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function uploadAppdata() {
};
try {
const file = await service.files.create({
resource: fileMetadata,
requestBody: fileMetadata,
media: media,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/drive_snippets/create_drive.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function createDrive() {
const requestId = uuid.v4();
try {
const Drive = await service.drives.create({
resource: driveMetadata,
requestBody: driveMetadata,
requestId: requestId,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/drive_snippets/recover_drives.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function recoverDrives(userEmail) {
drive.id,
);
await service.permissions.create({
resource: newOrganizerPermission,
requestBody: newOrganizerPermission,
fileId: drive.id,
useDomainAdminAccess: true,
supportsAllDrives: true,
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/file_snippets/create_folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function createFolder() {
};
try {
const file = await service.files.create({
resource: fileMetadata,
requestBody: fileMetadata,
fields: 'id',
});
console.log('Folder Id:', file.data.id);
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/file_snippets/create_shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function createShortcut() {

try {
const file = await service.files.create({
resource: fileMetadata,
requestBody: fileMetadata,
fields: 'id',
});
console.log('File Id:', file.data.id);
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/file_snippets/share_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function shareFile(fileId, targetUserEmail, targetDomainName) {
for (const permission of permissions) {
try {
const result = await service.permissions.create({
resource: permission,
requestBody: permission,
fileId: fileId,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/file_snippets/touch_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function touchFile(fileId, Timestamp) {
try {
const file = await service.files.update({
fileId: fileId,
resource: fileMetadata,
requestBody: fileMetadata,
fields: 'id, modifiedTime',
});
console.log('Modified time:', file.data.modifiedTime);
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v3/file_snippets/upload_to_folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function uploadToFolder(folderId) {

try {
const file = await service.files.create({
resource: fileMetadata,
requestBody: fileMetadata,
media: media,
fields: 'id',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function uploadWithConversion() {

try {
const file = await service.files.create({
resource: fileMetadata,
requestBody: fileMetadata,
media: media,
fields: 'id',
});
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Helpers {
*/
async createFile(fileMetadata, media) {
const file = await this.service.files.create({
resource: fileMetadata,
requestBody: fileMetadata,
media,
fields: 'id',
});
Expand Down
4 changes: 2 additions & 2 deletions sheets/snippets/sheets_append_values.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ async function appendValues(spreadsheetId, range, valueInputOption, _values) {
// [START_EXCLUDE silent]
values = _values;
// [END_EXCLUDE]
const resource = {
const requestBody = {
values,
};
try {
const result = await service.spreadsheets.values.append({
spreadsheetId,
range,
valueInputOption,
resource,
requestBody,
});
console.log(`${result.data.updates.updatedCells} cells appended.`);
return result;
Expand Down
2 changes: 1 addition & 1 deletion sheets/snippets/sheets_batch_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function batchUpdate(spreadsheetId, title, find, replacement) {
try {
const response = await service.spreadsheets.batchUpdate({
spreadsheetId,
resource: batchUpdateRequest,
requestBody: batchUpdateRequest,
});
const findReplaceResponse = response.data.replies[1].findReplace;
console.log(`${findReplaceResponse.occurrencesChanged} replacements made.`);
Expand Down
4 changes: 2 additions & 2 deletions sheets/snippets/sheets_batch_update_values.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ async function batchUpdateValues(
},
];
// Additional ranges to update ...
const resource = {
const requestBody = {
data,
valueInputOption,
};
try {
const result = await service.spreadsheets.values.batchUpdate({
spreadsheetId,
resource,
requestBody,
});
console.log('%d cells updated.', result.data.totalUpdatedCells);
return result;
Expand Down
4 changes: 2 additions & 2 deletions sheets/snippets/sheets_conditional_formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ async function conditionalFormatting(spreadsheetId) {
},
},
];
const resource = {
const requestBody = {
requests,
};
try {
const response = await service.spreadsheets.batchUpdate({
spreadsheetId,
resource,
requestBody,
});
console.log(`${response.data.replies.length} cells updated.`);
return response;
Expand Down
4 changes: 2 additions & 2 deletions sheets/snippets/sheets_create.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ async function create(title) {
});

const service = google.sheets({version: 'v4', auth});
const resource = {
const requestBody = {
properties: {
title,
},
};
try {
const spreadsheet = await service.spreadsheets.create({
resource,
requestBody,
fields: 'spreadsheetId',
});
console.log(`Spreadsheet ID: ${spreadsheet.data.spreadsheetId}`);
Expand Down
8 changes: 4 additions & 4 deletions sheets/snippets/sheets_pivot_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ async function pivotTable(spreadsheetId) {
addSheet: {},
},
];
let resource = {requests};
let requestBody = {requests};
let response = await service.spreadsheets.batchUpdate({
spreadsheetId,
resource,
requestBody,
});
const sourceSheetId = response.data.replies[0].addSheet.properties.sheetId;
const targetSheetId = response.data.replies[1].addSheet.properties.sheetId;
Expand Down Expand Up @@ -95,12 +95,12 @@ async function pivotTable(spreadsheetId) {
},
},
];
resource = {
requestBody = {
requests,
};
response = service.spreadsheets.batchUpdate({
spreadsheetId,
resource,
requestBody,
});
return response;
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions sheets/snippets/sheets_update_values.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ async function updateValues(spreadsheetId, range, valueInputOption, _values) {
// [START_EXCLUDE silent]
values = _values;
// [END_EXCLUDE]
const resource = {
const requestBody = {
values,
};
try {
const result = await service.spreadsheets.values.update({
spreadsheetId,
range,
valueInputOption,
resource,
requestBody,
});
console.log('%d cells updated.', result.data.updatedCells);
return result;
Expand Down
4 changes: 2 additions & 2 deletions sheets/snippets/test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Helpers {
*/
async createTestSpreadsheet() {
const res = await this.sheetsService.spreadsheets.create({
resource: {
requestBody: {
properties: {
title: 'Test Spreadsheet',
},
Expand All @@ -88,7 +88,7 @@ class Helpers {
async populateValues(spreadsheetId) {
await this.sheetsService.spreadsheets.batchUpdate({
spreadsheetId,
resource: {
requestBody: {
requests: [
{
repeatCell: {
Expand Down
2 changes: 1 addition & 1 deletion slides/snippets/slides_copy_presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function copyPresentation(presentationId, copyTitle) {
try {
const driveResponse = await service.files.copy({
fileId: presentationId,
resource: request,
requestBody: request,
});
const presentationCopyId = driveResponse.data.id;
console.log('Created copied presentation with ID: ' + presentationCopyId);
Expand Down
2 changes: 1 addition & 1 deletion slides/snippets/slides_create_bulleted_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function createBulletedText(presentationId, shapeId) {
try {
const batchUpdateResponse = await service.presentations.batchUpdate({
presentationId,
resource: {
requestBody: {
requests,
},
});
Expand Down
2 changes: 1 addition & 1 deletion slides/snippets/slides_create_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function createImage(presentationId, pageId) {
try {
const response = await service.presentations.batchUpdate({
presentationId,
resource: {requests},
requestBody: {requests},
});
const createImageResponse = response.data.replies;
console.log(
Expand Down
2 changes: 1 addition & 1 deletion slides/snippets/slides_create_sheets_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function createSheetsChart(
try {
const batchUpdateResponse = await service.presentations.batchUpdate({
presentationId,
resource: {
requestBody: {
requests,
},
});
Expand Down
2 changes: 1 addition & 1 deletion slides/snippets/slides_create_slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function createSlide(presentationId, pageId) {
try {
const res = await service.presentations.batchUpdate({
presentationId,
resource: {
requestBody: {
requests,
},
});
Expand Down
Loading