feat(google-forms): add list forms dynamic data
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
import listForms from './list-forms';
|
||||||
|
|
||||||
|
export default [listForms];
|
@@ -0,0 +1,34 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List forms',
|
||||||
|
key: 'listForms',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const forms: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
q: `mimeType='application/vnd.google-apps.form'`,
|
||||||
|
spaces: 'drive',
|
||||||
|
pageToken: undefined as unknown as string,
|
||||||
|
};
|
||||||
|
|
||||||
|
do {
|
||||||
|
const { data } = await $.http.get(`https://www.googleapis.com/drive/v3/files`, { params });
|
||||||
|
params.pageToken = data.nextPageToken;
|
||||||
|
|
||||||
|
for (const file of data.files) {
|
||||||
|
forms.data.push({
|
||||||
|
value: file.id,
|
||||||
|
name: file.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} while (params.pageToken);
|
||||||
|
|
||||||
|
return forms;
|
||||||
|
},
|
||||||
|
};
|
@@ -1,6 +1,7 @@
|
|||||||
import defineApp from '../../helpers/define-app';
|
import defineApp from '../../helpers/define-app';
|
||||||
import addAuthHeader from './common/add-auth-header';
|
import addAuthHeader from './common/add-auth-header';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
|
import dynamicData from './dynamic-data';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Google Forms',
|
name: 'Google Forms',
|
||||||
@@ -13,4 +14,5 @@ export default defineApp({
|
|||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user