feat(google-drive): list shared drives for new files trigger

This commit is contained in:
Rıdvan Akca
2023-04-06 14:28:57 +03:00
committed by Ali BARIN
parent 5570687957
commit 9ad7de56a3
4 changed files with 59 additions and 1 deletions

View File

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

View File

@@ -0,0 +1,35 @@
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(`/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;
},
};