feat(google-sheets): add new spreadsheets trigger

This commit is contained in:
Rıdvan Akca
2023-04-04 16:25:38 +03:00
parent f88f05cd46
commit 287f299b94
17 changed files with 121 additions and 7 deletions

View File

@@ -0,0 +1,3 @@
import listDrives from './list-drives';
export default [listDrives];

View File

@@ -0,0 +1,38 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
export default {
name: 'List drives',
key: 'listDrives',
async run($: IGlobalVariable) {
const drives: {
data: IJSONObject[];
} = {
data: [{ value: null, name: 'My Google Drive' }],
};
const params = {
pageSize: 100,
pageToken: undefined as unknown as string,
};
do {
const { data } = await $.http.get(
`https://www.googleapis.com/drive/v3/drives`,
{ params }
);
params.pageToken = data.nextPageToken;
if (data.drives) {
for (const drive of data.drives) {
drives.data.push({
value: drive.id,
name: drive.name,
});
}
}
} while (params.pageToken);
return drives;
},
};