feat(google-tasks): add new completed tasks trigger

This commit is contained in:
Rıdvan Akca
2024-01-16 17:30:25 +03:00
parent cab040c74a
commit 06b040412a
3 changed files with 63 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import newCompletedTasks from './new-completed-tasks/index.js';
import newTaskLists from './new-task-lists/index.js'; import newTaskLists from './new-task-lists/index.js';
import newTasks from './new-tasks/index.js'; import newTasks from './new-tasks/index.js';
export default [newTaskLists, newTasks]; export default [newCompletedTasks, newTaskLists, newTasks];

View File

@@ -0,0 +1,59 @@
import defineTrigger from '../../../../helpers/define-trigger.js';
export default defineTrigger({
name: 'New completed tasks',
key: 'newTasks',
pollInterval: 15,
description: 'Triggers when a task is finished within a specified task list.',
arguments: [
{
label: 'Task List',
key: 'taskListId',
type: 'dropdown',
required: true,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTaskLists',
},
],
},
},
],
async run($) {
const taskListId = $.step.parameters.taskListId;
const params = {
maxResults: 100,
showCompleted: true,
showHidden: true,
pageToken: undefined,
};
do {
const { data } = await $.http.get(`/tasks/v1/lists/${taskListId}/tasks`, {
params,
});
params.pageToken = data.nextPageToken;
if (data.items?.length) {
for (const task of data.items) {
if (task.status === 'completed') {
$.pushTriggerItem({
raw: task,
meta: {
internalId: task.etag,
},
});
}
}
}
} while (params.pageToken);
},
});

View File

@@ -1,6 +1,8 @@
--- ---
favicon: /favicons/google-tasks.svg favicon: /favicons/google-tasks.svg
items: items:
- name: New completed tasks
desc: Triggers when a task is finished within a specified task list.
- name: New task lists - name: New task lists
desc: Triggers when a new task list is created. desc: Triggers when a new task list is created.
- name: New tasks - name: New tasks