From 22e4b8aaeb88fddc698f1627ca8d894546ede0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=B1dvan=20Akca?= Date: Tue, 16 Jan 2024 17:10:27 +0300 Subject: [PATCH] feat(google-tasks): add create task list action --- .../actions/create-task-list/index.js | 31 +++++++++++++++++++ .../src/apps/google-tasks/actions/index.js | 3 +- .../docs/pages/apps/google-tasks/actions.md | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 packages/backend/src/apps/google-tasks/actions/create-task-list/index.js diff --git a/packages/backend/src/apps/google-tasks/actions/create-task-list/index.js b/packages/backend/src/apps/google-tasks/actions/create-task-list/index.js new file mode 100644 index 00000000..0d2571bd --- /dev/null +++ b/packages/backend/src/apps/google-tasks/actions/create-task-list/index.js @@ -0,0 +1,31 @@ +import defineAction from '../../../../helpers/define-action.js'; + +export default defineAction({ + name: 'Create task list', + key: 'createTaskList', + description: 'Creates a new task list.', + arguments: [ + { + label: 'List Title', + key: 'listTitle', + type: 'string', + required: true, + description: '', + variables: true, + }, + ], + + async run($) { + const listTitle = $.step.parameters.listTitle; + + const body = { + title: listTitle, + }; + + const { data } = await $.http.post('/tasks/v1/users/@me/lists', 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 768f9845..ed71df70 100644 --- a/packages/backend/src/apps/google-tasks/actions/index.js +++ b/packages/backend/src/apps/google-tasks/actions/index.js @@ -1,5 +1,6 @@ import createTask from './create-task/index.js'; +import createTaskList from './create-task-list/index.js'; import findTask from './find-task/index.js'; import updateTask from './update-task/index.js'; -export default [createTask, findTask, updateTask]; +export default [createTask, createTaskList, findTask, updateTask]; diff --git a/packages/docs/pages/apps/google-tasks/actions.md b/packages/docs/pages/apps/google-tasks/actions.md index 623d2c3e..30446b0d 100644 --- a/packages/docs/pages/apps/google-tasks/actions.md +++ b/packages/docs/pages/apps/google-tasks/actions.md @@ -3,6 +3,8 @@ favicon: /favicons/google-tasks.svg items: - name: Create task desc: Creates a new task. + - name: Create task list + desc: Creates a new task list. - name: Find task desc: Looking for an incomplete task. - name: Update task