0
Import Tasks
One script reply has been approved by the moderators Verified

Import tasks into a selected project. See Docs

Created by paulys8ty1 1089 days ago Viewed 16699 times
0
Submitted by hugo697 Bun
Verified 389 days ago
1
import { TodoistApi } from '@doist/todoist-api-typescript'
2
import { v9 as Todoist } from 'todoist'
3

4
type Todoist = {
5
	Token: string
6
}
7

8
export async function main(
9
	resource: Todoist,
10
	tasks: {
11
		args: {
12
			content: string
13
			description?: string
14
			projectId?: string
15
			sectionId?: string
16
			parentId?: string
17
			order?: number
18
			labels?: string[]
19
			priority?: number
20
			dueLang?: string
21
			assigneeId?: string
22
			dueString?: string
23
			dueDate?: string
24
			dueDatetime?: string
25
			duration?: number
26
			durationUnit?: 'minute' | 'day'
27
		}
28
		requestId?: string
29
	}[]
30
) {
31
	const api = new TodoistApi(resource.Token)
32
	// @ts-ignore
33
	const taskPromises = tasks.map((task) => api.addTask(task.args, task.requestId))
34
	const taskResponses = await Promise.all(taskPromises)
35
	return taskResponses
36
}
37