From bd43a6021a7a0ad53e6742233c8b93e18a6eaf47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=B1dvan=20Akca?= Date: Tue, 16 Jan 2024 16:39:38 +0300 Subject: [PATCH] feat(google-tasks): add create task action --- .../google-tasks/actions/create-task/index.js | 70 +++++++++++++++++++ .../src/apps/google-tasks/actions/index.js | 3 +- .../docs/pages/apps/google-tasks/actions.md | 2 + 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 packages/backend/src/apps/google-tasks/actions/create-task/index.js diff --git a/packages/backend/src/apps/google-tasks/actions/create-task/index.js b/packages/backend/src/apps/google-tasks/actions/create-task/index.js new file mode 100644 index 00000000..2b03a20e --- /dev/null +++ b/packages/backend/src/apps/google-tasks/actions/create-task/index.js @@ -0,0 +1,70 @@ +import defineAction from '../../../../helpers/define-action.js'; + +export default defineAction({ + name: 'Create task', + key: 'createTask', + description: 'Creates a new task.', + arguments: [ + { + label: 'Task List', + key: 'taskListId', + type: 'dropdown', + required: true, + description: '', + variables: true, + source: { + type: 'query', + name: 'getDynamicData', + arguments: [ + { + name: 'key', + value: 'listTaskLists', + }, + ], + }, + }, + { + label: 'Title', + key: 'title', + type: 'string', + required: true, + description: '', + variables: true, + }, + { + label: 'Notes', + key: 'notes', + type: 'string', + required: false, + description: '', + variables: true, + }, + { + label: 'Due Date', + key: 'due', + type: 'string', + required: false, + description: 'RFC 3339 timestamp.', + variables: true, + }, + ], + + async run($) { + const { taskListId, title, notes, due } = $.step.parameters; + + const body = { + title, + notes, + due, + }; + + const { data } = await $.http.post( + `/tasks/v1/lists/${taskListId}/tasks`, + body + ); + + $.setActionItem({ + raw: data, + }); + }, +}); diff --git a/packages/backend/src/apps/google-tasks/actions/index.js b/packages/backend/src/apps/google-tasks/actions/index.js index 5a5941db..768f9845 100644 --- a/packages/backend/src/apps/google-tasks/actions/index.js +++ b/packages/backend/src/apps/google-tasks/actions/index.js @@ -1,4 +1,5 @@ +import createTask from './create-task/index.js'; import findTask from './find-task/index.js'; import updateTask from './update-task/index.js'; -export default [findTask, updateTask]; +export default [createTask, findTask, updateTask]; diff --git a/packages/docs/pages/apps/google-tasks/actions.md b/packages/docs/pages/apps/google-tasks/actions.md index f53be795..623d2c3e 100644 --- a/packages/docs/pages/apps/google-tasks/actions.md +++ b/packages/docs/pages/apps/google-tasks/actions.md @@ -1,6 +1,8 @@ --- favicon: /favicons/google-tasks.svg items: + - name: Create task + desc: Creates a new task. - name: Find task desc: Looking for an incomplete task. - name: Update task