2022-02-26 02:10:40 -08:00
import { IExecuteFunctions } from 'n8n-core' ;
2020-09-08 05:00:54 -07:00
2019-06-23 03:35:23 -07:00
import {
IDataObject ,
2022-02-05 13:55:43 -08:00
IHttpRequestMethods ,
2019-06-23 03:35:23 -07:00
ILoadOptionsFunctions ,
INodeExecutionData ,
2020-09-08 05:00:54 -07:00
INodePropertyOptions ,
2019-06-23 03:35:23 -07:00
INodeType ,
2020-09-08 05:00:54 -07:00
INodeTypeDescription ,
2021-04-16 09:33:36 -07:00
NodeApiError ,
NodeOperationError ,
2019-06-23 03:35:23 -07:00
} from 'n8n-workflow' ;
2022-02-26 02:10:40 -08:00
import {
asanaApiRequest ,
asanaApiRequestAllItems ,
getColorOptions ,
getTaskFields ,
getWorkspaces ,
} from './GenericFunctions' ;
2019-06-23 03:35:23 -07:00
2022-04-08 14:32:08 -07:00
import moment from 'moment-timezone' ;
2020-12-22 14:44:31 -08:00
2022-02-26 02:10:40 -08:00
import { snakeCase } from 'change-case' ;
2020-12-25 11:41:48 -08:00
2019-06-23 03:35:23 -07:00
export class Asana implements INodeType {
description : INodeTypeDescription = {
displayName : 'Asana' ,
name : 'asana' ,
2021-03-25 09:10:02 -07:00
icon : 'file:asana.svg' ,
2019-06-23 03:35:23 -07:00
group : [ 'input' ] ,
version : 1 ,
2019-07-12 09:35:35 -07:00
subtitle : '={{$parameter["operation"] + ": " + $parameter["resource"]}}' ,
2020-09-08 05:00:54 -07:00
description : 'Consume Asana REST API' ,
2019-06-23 03:35:23 -07:00
defaults : {
name : 'Asana' ,
} ,
inputs : [ 'main' ] ,
outputs : [ 'main' ] ,
credentials : [
{
name : 'asanaApi' ,
required : true ,
2020-09-16 09:20:27 -07:00
displayOptions : {
show : {
authentication : [
'accessToken' ,
] ,
} ,
} ,
2022-02-05 13:55:43 -08:00
testedBy : {
request : {
method : 'GET' ,
url : '/users/me' ,
} ,
} ,
2020-09-16 09:20:27 -07:00
} ,
{
name : 'asanaOAuth2Api' ,
required : true ,
displayOptions : {
show : {
authentication : [
'oAuth2' ,
] ,
} ,
} ,
2020-09-08 05:00:54 -07:00
} ,
2019-06-23 03:35:23 -07:00
] ,
2022-02-05 13:55:43 -08:00
requestDefaults : {
baseURL : 'https://app.asana.com/api/1.0' ,
url : '' ,
} ,
2019-06-23 03:35:23 -07:00
properties : [
2020-09-16 09:20:27 -07:00
{
displayName : 'Authentication' ,
name : 'authentication' ,
type : 'options' ,
options : [
{
name : 'Access Token' ,
value : 'accessToken' ,
} ,
{
name : 'OAuth2' ,
value : 'oAuth2' ,
} ,
] ,
default : 'accessToken' ,
} ,
2019-07-12 09:35:35 -07:00
{
displayName : 'Resource' ,
name : 'resource' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-12 09:35:35 -07:00
options : [
2020-09-08 05:00:54 -07:00
{
name : 'Project' ,
value : 'project' ,
} ,
2020-12-22 14:44:31 -08:00
{
name : 'Subtask' ,
value : 'subtask' ,
} ,
2019-07-12 09:35:35 -07:00
{
name : 'Task' ,
value : 'task' ,
} ,
2020-09-08 05:00:54 -07:00
{
name : 'Task Comment' ,
value : 'taskComment' ,
} ,
2021-01-30 09:34:49 -08:00
{
name : 'Task Project' ,
value : 'taskProject' ,
} ,
2022-06-03 10:23:49 -07:00
{
name : 'Task Tag' ,
value : 'taskTag' ,
} ,
2019-07-12 09:35:35 -07:00
{
name : 'User' ,
value : 'user' ,
} ,
] ,
default : 'task' ,
} ,
2020-12-22 14:44:31 -08:00
// ----------------------------------
// subtask
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-12-22 14:44:31 -08:00
displayOptions : {
show : {
resource : [
'subtask' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a subtask' ,
2022-07-10 13:50:51 -07:00
action : 'Create a subtask' ,
2020-12-22 14:44:31 -08:00
} ,
2020-12-25 11:41:48 -08:00
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all substasks' ,
2022-07-10 13:50:51 -07:00
action : 'Get all subtasks' ,
2020-12-25 11:41:48 -08:00
} ,
2020-12-22 14:44:31 -08:00
] ,
default : 'create' ,
} ,
// ----------------------------------
// subtask:create
// ----------------------------------
{
displayName : 'Parent Task ID' ,
name : 'taskId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'subtask' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The task to operate on' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'subtask' ,
] ,
} ,
} ,
description : 'The name of the subtask to create' ,
} ,
{
displayName : 'Additional Fields' ,
name : 'otherProperties' ,
type : 'collection' ,
displayOptions : {
show : {
resource : [
'subtask' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
default : { } ,
placeholder : 'Add Field' ,
options : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Assignee Name or ID' ,
2020-12-22 14:44:31 -08:00
name : 'assignee' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getUsers' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'Set Assignee on the subtask. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Assignee Status' ,
name : 'assignee_status' ,
type : 'options' ,
options : [
{
name : 'Inbox' ,
value : 'inbox' ,
} ,
{
name : 'Today' ,
value : 'today' ,
} ,
{
name : 'Upcoming' ,
value : 'upcoming' ,
} ,
{
name : 'Later' ,
value : 'later' ,
} ,
] ,
default : 'inbox' ,
description : 'Set Assignee status on the subtask (requires Assignee)' ,
} ,
{
displayName : 'Completed' ,
name : 'completed' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether the subtask should be marked completed' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Due On' ,
name : 'due_on' ,
type : 'dateTime' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Date on which the time is due' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Liked' ,
name : 'liked' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether the task is liked by the authorized user' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Notes' ,
name : 'notes' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
rows : 5 ,
} ,
default : '' ,
description : 'The task notes' ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2020-12-22 14:44:31 -08:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The workspace to create the subtask in. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-22 14:44:31 -08:00
} ,
] ,
} ,
2020-12-25 11:41:48 -08:00
// ----------------------------------
// subtask:getAll
// ----------------------------------
{
displayName : 'Parent Task ID' ,
name : 'taskId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'subtask' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The task to operate on' ,
2020-12-25 11:41:48 -08:00
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'subtask' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-12-25 11:41:48 -08:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'subtask' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 500 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-12-25 11:41:48 -08:00
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'subtask' ,
] ,
} ,
} ,
default : { } ,
placeholder : 'Add Field' ,
options : [
{
2022-06-20 07:54:01 -07:00
displayName : 'Field Names or IDs' ,
2020-12-25 11:41:48 -08:00
name : 'opt_fields' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getTaskFields' ,
} ,
default : [
'gid' ,
'name' ,
'resource_type' ,
] ,
2022-07-14 13:05:11 -07:00
description : 'Defines fields to return. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-25 11:41:48 -08:00
} ,
{
displayName : 'Pretty' ,
name : 'opt_pretty' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to provide “pretty” output' ,
2020-12-25 11:41:48 -08:00
} ,
] ,
} ,
2019-07-12 09:35:35 -07:00
// ----------------------------------
// task
// ----------------------------------
2019-06-23 03:35:23 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-12 09:35:35 -07:00
displayOptions : {
show : {
resource : [
'task' ,
] ,
} ,
} ,
2019-06-23 03:35:23 -07:00
options : [
{
2019-07-12 09:35:35 -07:00
name : 'Create' ,
value : 'create' ,
description : 'Create a task' ,
2022-07-10 13:50:51 -07:00
action : 'Create a task' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-12 09:35:35 -07:00
name : 'Delete' ,
value : 'delete' ,
2019-06-23 03:35:23 -07:00
description : 'Delete a task' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a task' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-12 09:35:35 -07:00
name : 'Get' ,
value : 'get' ,
2020-09-08 05:00:54 -07:00
description : 'Get a task' ,
2022-07-10 13:50:51 -07:00
action : 'Get a task' ,
2019-06-23 03:35:23 -07:00
} ,
2020-12-22 14:44:31 -08:00
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all tasks' ,
2022-07-10 13:50:51 -07:00
action : 'Get all tasks' ,
2020-12-22 14:44:31 -08:00
} ,
2019-06-23 03:35:23 -07:00
{
2020-09-08 05:00:54 -07:00
name : 'Move' ,
value : 'move' ,
description : 'Move a task' ,
2022-07-10 13:50:51 -07:00
action : 'Move a task' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-12 09:35:35 -07:00
name : 'Search' ,
value : 'search' ,
description : 'Search for tasks' ,
2022-07-10 13:50:51 -07:00
action : 'Search a task' ,
2019-06-23 03:35:23 -07:00
} ,
2020-09-08 05:00:54 -07:00
{
name : 'Update' ,
value : 'update' ,
description : 'Update a task' ,
2022-07-10 13:50:51 -07:00
action : 'Update a task' ,
2020-09-08 05:00:54 -07:00
} ,
2019-06-23 03:35:23 -07:00
] ,
2019-07-12 09:35:35 -07:00
default : 'create' ,
2019-06-23 03:35:23 -07:00
} ,
// ----------------------------------
2019-07-12 09:35:35 -07:00
// task:create
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2019-06-23 03:35:23 -07:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
options : [ ] ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2019-07-12 09:35:35 -07:00
'create' ,
] ,
resource : [
'task' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The workspace to create the task in. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Name' ,
2019-07-12 09:35:35 -07:00
name : 'name' ,
2019-06-23 03:35:23 -07:00
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2019-07-12 09:35:35 -07:00
'create' ,
] ,
resource : [
'task' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
description : 'The name of the task to create' ,
} ,
// ----------------------------------
2020-09-08 05:00:54 -07:00
// task:delete
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
displayName : 'Task ID' ,
2019-07-12 09:35:35 -07:00
name : 'id' ,
2019-06-23 03:35:23 -07:00
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2019-07-12 09:35:35 -07:00
'delete' ,
] ,
resource : [
'task' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the task to delete' ,
2019-06-23 03:35:23 -07:00
} ,
// ----------------------------------
2020-09-08 05:00:54 -07:00
// task:get
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
displayName : 'Task ID' ,
2019-07-12 09:35:35 -07:00
name : 'id' ,
2019-06-23 03:35:23 -07:00
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2019-07-12 09:35:35 -07:00
'get' ,
] ,
resource : [
'task' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the task to get the data of' ,
2019-06-23 03:35:23 -07:00
} ,
2020-12-22 14:44:31 -08:00
// ----------------------------------
// task:getAll
// ----------------------------------
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'task' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'task' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 500 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Filters' ,
name : 'filters' ,
type : 'collection' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'task' ,
] ,
} ,
} ,
default : { } ,
description : 'Properties to search for' ,
placeholder : 'Add Filter' ,
options : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Assignee Name or ID' ,
2020-12-22 14:44:31 -08:00
name : 'assignee' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getUsers' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The assignee to filter tasks on. Note: If you specify assignee, you must also specify the workspace to filter on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-22 14:44:31 -08:00
} ,
{
2022-06-20 07:54:01 -07:00
displayName : 'Field Names or IDs' ,
2020-12-22 14:44:31 -08:00
name : 'opt_fields' ,
2020-12-25 11:41:48 -08:00
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getTaskFields' ,
} ,
default : [
'gid' ,
'name' ,
'resource_type' ,
] ,
2022-07-14 13:05:11 -07:00
description : 'Defines fields to return. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Pretty' ,
name : 'opt_pretty' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to provide “pretty” output' ,
2020-12-22 14:44:31 -08:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Project Name or ID' ,
2020-12-22 14:44:31 -08:00
name : 'project' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getProjects' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The project to filter tasks on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-22 14:44:31 -08:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Section Name or ID' ,
2020-12-22 14:44:31 -08:00
name : 'section' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getSections' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The section to filter tasks on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-22 14:44:31 -08:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2020-12-22 14:44:31 -08:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The workspace to filter tasks on. Note: If you specify workspace, you must also specify the assignee to filter on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Completed Since' ,
name : 'completed_since' ,
type : 'dateTime' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Only return tasks that are either incomplete or that have been completed since this time' ,
2020-12-22 14:44:31 -08:00
} ,
{
displayName : 'Modified Since' ,
name : 'modified_since' ,
type : 'dateTime' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Only return tasks that have been modified since the given time' ,
2020-12-22 14:44:31 -08:00
} ,
] ,
} ,
2019-06-23 03:35:23 -07:00
// ----------------------------------
2020-09-08 05:00:54 -07:00
// task:move
// ----------------------------------
{
displayName : 'Task ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'move' ,
] ,
resource : [
'task' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the task to be moved' ,
2020-09-08 05:00:54 -07:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Project Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'projectId' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getProjects' ,
} ,
options : [ ] ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'move' ,
] ,
resource : [
'task' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'Project to show the sections of. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Section Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'section' ,
type : 'options' ,
typeOptions : {
loadOptionsDependsOn : [
'projectId' ,
] ,
2020-09-08 05:01:16 -07:00
loadOptionsMethod : 'getSections' ,
2020-09-08 05:00:54 -07:00
} ,
options : [ ] ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'move' ,
] ,
resource : [
'task' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The Section to move the task to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
// ----------------------------------
// task:update
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
displayName : 'Task ID' ,
2019-07-12 09:35:35 -07:00
name : 'id' ,
2019-06-23 03:35:23 -07:00
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2019-07-12 09:35:35 -07:00
'update' ,
] ,
resource : [
'task' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the task to update the data of' ,
2019-06-23 03:35:23 -07:00
} ,
// ----------------------------------
2020-09-08 05:00:54 -07:00
// task:search
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2019-06-23 03:35:23 -07:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
options : [ ] ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2019-07-12 09:35:35 -07:00
'search' ,
] ,
resource : [
'task' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The workspace in which the task is searched. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2019-06-23 03:35:23 -07:00
} ,
{
2020-09-08 05:00:54 -07:00
displayName : 'Filters' ,
2019-06-23 03:35:23 -07:00
name : 'searchTaskProperties' ,
type : 'collection' ,
displayOptions : {
show : {
operation : [
2019-07-12 09:35:35 -07:00
'search' ,
] ,
resource : [
'task' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
default : { } ,
description : 'Properties to search for' ,
2020-09-08 05:00:54 -07:00
placeholder : 'Add Filter' ,
2019-06-23 03:35:23 -07:00
options : [
2020-09-08 05:00:54 -07:00
{
displayName : 'Completed' ,
name : 'completed' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether the task is marked completed' ,
2020-09-08 05:00:54 -07:00
} ,
2019-06-23 03:35:23 -07:00
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
rows : 5 ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Text to search for in name or notes' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
} ,
// ----------------------------------
2020-09-08 05:00:54 -07:00
// task:create/update
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
2020-09-08 05:00:54 -07:00
displayName : 'Additional Fields' ,
2019-06-23 03:35:23 -07:00
name : 'otherProperties' ,
type : 'collection' ,
displayOptions : {
2019-07-12 09:35:35 -07:00
show : {
resource : [
'task' ,
] ,
2019-06-23 03:35:23 -07:00
operation : [
2019-07-12 09:35:35 -07:00
'create' ,
'update' ,
2019-06-23 03:35:23 -07:00
] ,
} ,
} ,
default : { } ,
2020-09-08 05:00:54 -07:00
placeholder : 'Add Field' ,
2019-06-23 03:35:23 -07:00
options : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Assignee Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'assignee' ,
type : 'options' ,
2019-06-23 03:35:23 -07:00
typeOptions : {
2020-09-08 05:00:54 -07:00
loadOptionsMethod : 'getUsers' ,
2019-06-23 03:35:23 -07:00
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'Set Assignee on the task. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
{
displayName : 'Assignee Status' ,
name : 'assignee_status' ,
type : 'options' ,
options : [
{
name : 'Inbox' ,
value : 'inbox' ,
} ,
{
name : 'Today' ,
value : 'today' ,
} ,
{
name : 'Upcoming' ,
value : 'upcoming' ,
} ,
{
name : 'Later' ,
value : 'later' ,
} ,
] ,
default : 'inbox' ,
description : 'Set Assignee status on the task (requires Assignee)' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Completed' ,
name : 'completed' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether the task should be marked completed' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Due On' ,
name : 'due_on' ,
type : 'dateTime' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Date on which the time is due' ,
2019-06-23 03:35:23 -07:00
} ,
2020-09-08 05:00:54 -07:00
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
'/operation' : [
'update' ,
] ,
} ,
} ,
description : 'The new name of the task' ,
} ,
2019-06-23 03:35:23 -07:00
{
displayName : 'Liked' ,
name : 'liked' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether the task is liked by the authorized user' ,
2019-06-23 03:35:23 -07:00
} ,
2020-09-08 05:00:54 -07:00
{
displayName : 'Notes' ,
name : 'notes' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
rows : 5 ,
} ,
default : '' ,
description : 'The task notes' ,
} ,
2021-01-30 09:34:49 -08:00
{
2022-06-20 07:54:01 -07:00
displayName : 'Project Names or IDs' ,
2021-01-30 09:34:49 -08:00
name : 'projects' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getProjects' ,
} ,
default : [ ] ,
2022-07-14 13:05:11 -07:00
description : 'The project to filter tasks on. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-01-30 09:34:49 -08:00
} ,
2019-06-23 03:35:23 -07:00
] ,
} ,
2019-07-12 09:35:35 -07:00
// ----------------------------------
2020-09-08 05:00:54 -07:00
// taskComment
2019-07-12 09:35:35 -07:00
// ----------------------------------
2020-09-08 05:00:54 -07:00
2019-07-12 09:35:35 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-12 09:35:35 -07:00
displayOptions : {
show : {
resource : [
2020-09-08 05:00:54 -07:00
'taskComment' ,
2019-07-12 09:35:35 -07:00
] ,
} ,
} ,
options : [
{
2020-09-08 05:00:54 -07:00
name : 'Add' ,
value : 'add' ,
description : 'Add a comment to a task' ,
2022-07-10 13:50:51 -07:00
action : 'Add a task comment' ,
2019-07-12 09:35:35 -07:00
} ,
{
2020-09-08 05:00:54 -07:00
name : 'Remove' ,
value : 'remove' ,
description : 'Remove a comment from a task' ,
2022-07-10 13:50:51 -07:00
action : 'Remove a task comment' ,
2019-07-12 09:35:35 -07:00
} ,
] ,
2020-09-08 05:00:54 -07:00
default : 'add' ,
2019-07-12 09:35:35 -07:00
} ,
// ----------------------------------
2020-09-08 05:00:54 -07:00
// taskComment:add
2019-07-12 09:35:35 -07:00
// ----------------------------------
2020-09-08 05:00:54 -07:00
2019-07-12 09:35:35 -07:00
{
2020-09-08 05:00:54 -07:00
displayName : 'Task ID' ,
name : 'id' ,
2019-07-12 09:35:35 -07:00
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-09-08 05:00:54 -07:00
'add' ,
2019-07-12 09:35:35 -07:00
] ,
resource : [
2020-09-08 05:00:54 -07:00
'taskComment' ,
2019-07-12 09:35:35 -07:00
] ,
} ,
} ,
2020-09-08 05:00:54 -07:00
description : 'The ID of the task to add the comment to' ,
2019-07-12 09:35:35 -07:00
} ,
{
2020-09-08 05:00:54 -07:00
displayName : 'Is Text HTML' ,
name : 'isTextHtml' ,
type : 'boolean' ,
displayOptions : {
show : {
operation : [
'add' ,
] ,
resource : [
'taskComment' ,
] ,
} ,
} ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether body is HTML or simple text' ,
2020-09-08 05:00:54 -07:00
} ,
{
displayName : 'Text' ,
name : 'text' ,
type : 'string' ,
default : '' ,
required : true ,
2019-07-12 09:35:35 -07:00
typeOptions : {
2020-09-08 05:00:54 -07:00
alwaysOpenEditWindow : true ,
2019-07-12 09:35:35 -07:00
} ,
2020-09-08 05:00:54 -07:00
displayOptions : {
show : {
operation : [
'add' ,
] ,
resource : [
'taskComment' ,
] ,
isTextHtml : [
false ,
] ,
} ,
} ,
description : 'The plain text of the comment to add' ,
} ,
{
displayName : 'HTML Text' ,
2020-09-08 05:01:16 -07:00
name : 'text' ,
2020-09-08 05:00:54 -07:00
type : 'string' ,
2019-07-12 09:35:35 -07:00
default : '' ,
required : true ,
2020-09-08 05:00:54 -07:00
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
2019-07-12 09:35:35 -07:00
displayOptions : {
show : {
operation : [
2020-09-08 05:00:54 -07:00
'add' ,
2019-07-12 09:35:35 -07:00
] ,
resource : [
2020-09-08 05:00:54 -07:00
'taskComment' ,
] ,
isTextHtml : [
true ,
2019-07-12 09:35:35 -07:00
] ,
} ,
} ,
2020-09-08 05:00:54 -07:00
description : 'Comment as HTML string. Do not use together with plain text.' ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
displayOptions : {
show : {
operation : [
'add' ,
] ,
resource : [
'taskComment' ,
] ,
} ,
} ,
default : { } ,
description : 'Properties of the task comment' ,
placeholder : 'Add Field' ,
options : [
{
displayName : 'Pinned' ,
name : 'is_pinned' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to pin the comment' ,
2020-09-08 05:00:54 -07:00
} ,
] ,
2019-07-12 09:35:35 -07:00
} ,
2019-06-23 03:35:23 -07:00
2020-09-08 05:00:54 -07:00
// ----------------------------------
// taskComment:remove
// ----------------------------------
2019-06-23 03:35:23 -07:00
2020-09-08 05:00:54 -07:00
{
displayName : 'Comment ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'remove' ,
] ,
resource : [
'taskComment' ,
] ,
} ,
} ,
description : 'The ID of the comment to be removed' ,
} ,
2019-06-23 03:35:23 -07:00
2021-01-30 09:34:49 -08:00
// ----------------------------------
// taskProject
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-01-30 09:34:49 -08:00
displayOptions : {
show : {
resource : [
'taskProject' ,
] ,
} ,
} ,
options : [
{
name : 'Add' ,
value : 'add' ,
description : 'Add a task to a project' ,
2022-07-10 13:50:51 -07:00
action : 'Add a task project' ,
2021-01-30 09:34:49 -08:00
} ,
{
name : 'Remove' ,
value : 'remove' ,
description : 'Remove a task from a project' ,
2022-07-10 13:50:51 -07:00
action : 'Remove a task project' ,
2021-01-30 09:34:49 -08:00
} ,
] ,
default : 'add' ,
} ,
// ----------------------------------
// taskProject:add
// ----------------------------------
{
displayName : 'Task ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'add' ,
] ,
resource : [
'taskProject' ,
] ,
} ,
} ,
description : 'The ID of the task to add the project to' ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Project Name or ID' ,
2021-01-30 09:34:49 -08:00
name : 'project' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getProjects' ,
} ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'add' ,
] ,
resource : [
'taskProject' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The project where the task will be added. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-01-30 09:34:49 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
displayOptions : {
show : {
resource : [
'taskProject' ,
] ,
operation : [
'add' ,
] ,
} ,
} ,
default : { } ,
description : 'Other properties to set' ,
placeholder : 'Add Field' ,
options : [
{
displayName : 'Insert After' ,
name : 'insert_after' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'A task in the project to insert the task after, or null to insert at the beginning of the list' ,
2021-01-30 09:34:49 -08:00
} ,
{
displayName : 'Insert Before' ,
name : 'insert_before' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'A task in the project to insert the task before, or null to insert at the end of the list' ,
2021-01-30 09:34:49 -08:00
} ,
{
displayName : 'Section' ,
name : 'section' ,
type : 'string' ,
default : '' ,
description : 'A section in the project to insert the task into. The task will be inserted at the bottom of the section.' ,
} ,
] ,
} ,
// ----------------------------------
// taskProject:remove
// ----------------------------------
{
displayName : 'Task ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'remove' ,
] ,
resource : [
'taskProject' ,
] ,
} ,
} ,
description : 'The ID of the task to add the project to' ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Project Name or ID' ,
2021-01-30 09:34:49 -08:00
name : 'project' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getProjects' ,
} ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'remove' ,
] ,
resource : [
'taskProject' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The project where the task will be removed from. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-01-30 09:34:49 -08:00
} ,
2020-09-08 05:00:54 -07:00
// ----------------------------------
// taskTag
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-09-08 05:00:54 -07:00
displayOptions : {
show : {
resource : [
'taskTag' ,
] ,
} ,
} ,
options : [
{
name : 'Add' ,
value : 'add' ,
description : 'Add a tag to a task' ,
2022-07-10 13:50:51 -07:00
action : 'Add a task tag' ,
2020-09-08 05:00:54 -07:00
} ,
{
name : 'Remove' ,
value : 'remove' ,
description : 'Remove a tag from a task' ,
2022-07-10 13:50:51 -07:00
action : 'Remove a task tag' ,
2020-09-08 05:00:54 -07:00
} ,
] ,
default : 'add' ,
} ,
// ----------------------------------
// taskTag:add
// ----------------------------------
{
displayName : 'Task ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'add' ,
] ,
resource : [
'taskTag' ,
] ,
} ,
} ,
description : 'The ID of the task to add the tag to' ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Tags Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'tag' ,
type : 'options' ,
typeOptions : {
2020-09-08 05:01:16 -07:00
loadOptionsDependsOn : [
'id' ,
] ,
2020-09-08 05:00:54 -07:00
loadOptionsMethod : 'getTags' ,
} ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'add' ,
] ,
resource : [
'taskTag' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The tag that should be added. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
// ----------------------------------
// taskTag:remove
// ----------------------------------
{
displayName : 'Task ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'remove' ,
] ,
resource : [
'taskTag' ,
] ,
} ,
} ,
description : 'The ID of the task to add the tag to' ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Tags Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'tag' ,
type : 'options' ,
typeOptions : {
2020-09-08 05:01:16 -07:00
loadOptionsDependsOn : [
'id' ,
] ,
2020-09-08 05:00:54 -07:00
loadOptionsMethod : 'getTags' ,
} ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'remove' ,
] ,
resource : [
'taskTag' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The tag that should be added. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
// ----------------------------------
// user
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-09-08 05:00:54 -07:00
displayOptions : {
show : {
resource : [
'user' ,
] ,
} ,
} ,
options : [
{
name : 'Get' ,
value : 'get' ,
description : 'Get a user' ,
2022-07-10 13:50:51 -07:00
action : 'Get a user' ,
2020-09-08 05:00:54 -07:00
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all users' ,
2022-07-10 13:50:51 -07:00
action : 'Get all users' ,
2020-09-08 05:00:54 -07:00
} ,
] ,
default : 'get' ,
} ,
// ----------------------------------
// user:get
// ----------------------------------
{
displayName : 'User ID' ,
name : 'userId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'get' ,
] ,
resource : [
'user' ,
] ,
} ,
} ,
2021-10-27 13:00:13 -07:00
description : 'An identifier for the user to get data of. Can be one of an email address,the globally unique identifier for the user, or the keyword me to indicate the current user making the request.' ,
2020-09-08 05:00:54 -07:00
} ,
// ----------------------------------
// user:getAll
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
options : [ ] ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'user' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The workspace in which to get users. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
// ----------------------------------
// Project
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-09-08 05:00:54 -07:00
displayOptions : {
show : {
resource : [
'project' ,
] ,
} ,
} ,
options : [
2021-12-07 08:55:20 -08:00
{
name : 'Create' ,
value : 'create' ,
description : 'Create a new project' ,
2022-07-10 13:50:51 -07:00
action : 'Create a project' ,
2021-12-07 08:55:20 -08:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a project' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a project' ,
2021-12-07 08:55:20 -08:00
} ,
2020-09-08 05:00:54 -07:00
{
name : 'Get' ,
value : 'get' ,
description : 'Get a project' ,
2022-07-10 13:50:51 -07:00
action : 'Get a project' ,
2020-09-08 05:00:54 -07:00
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all projects' ,
2022-07-10 13:50:51 -07:00
action : 'Get all projects' ,
2020-09-08 05:00:54 -07:00
} ,
2021-12-07 08:55:20 -08:00
{
2022-01-09 21:44:18 -08:00
name : 'Update' ,
2021-12-07 08:55:20 -08:00
value : 'update' ,
description : 'Update a project' ,
2022-07-10 13:50:51 -07:00
action : 'Update a project' ,
2021-12-07 08:55:20 -08:00
} ,
2020-09-08 05:00:54 -07:00
] ,
default : 'get' ,
} ,
2021-12-07 08:55:20 -08:00
// ----------------------------------
// project:create
// ----------------------------------
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'project' ,
] ,
} ,
} ,
description : 'The name of the project to create' ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2021-12-07 08:55:20 -08:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'project' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The workspace to create the project in. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-12-07 08:55:20 -08:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Team Name or ID' ,
2021-12-07 08:55:20 -08:00
name : 'team' ,
type : 'options' ,
typeOptions : {
loadOptionsDependsOn : [
'workspace' ,
] ,
loadOptionsMethod : 'getTeams' ,
} ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'project' ,
] ,
} ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The team this project will be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-12-07 08:55:20 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
displayOptions : {
show : {
resource : [
'project' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
default : { } ,
description : 'Other properties to set' ,
placeholder : 'Add Property' ,
options : [
{
displayName : 'Color' ,
name : 'color' ,
2022-02-26 02:10:40 -08:00
type : 'options' ,
options : getColorOptions ( ) ,
default : 'none' ,
2022-05-06 14:01:25 -07:00
description : 'Color of the project' ,
2021-12-07 08:55:20 -08:00
} ,
{
displayName : 'Due On' ,
name : 'due_on' ,
type : 'dateTime' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The day on which this project is due. This takes a date with format YYYY-MM-DD.' ,
2021-12-07 08:55:20 -08:00
} ,
{
displayName : 'Notes' ,
name : 'notes' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Basic description or notes for the project' ,
2021-12-07 08:55:20 -08:00
} ,
] ,
} ,
// ----------------------------------
// project:delete
// ----------------------------------
{
displayName : 'Project ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'delete' ,
] ,
resource : [
'project' ,
] ,
} ,
} ,
} ,
2020-09-08 05:00:54 -07:00
// ----------------------------------
// project:get
// ----------------------------------
{
displayName : 'Project ID' ,
name : 'id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'get' ,
] ,
resource : [
'project' ,
] ,
} ,
} ,
} ,
// ----------------------------------
// project:getAll
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
options : [ ] ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'project' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The workspace in which to get users. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'project' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-09-08 05:00:54 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'project' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 500 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-09-08 05:00:54 -07:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
displayOptions : {
show : {
resource : [
'project' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : { } ,
description : 'Other properties to set' ,
placeholder : 'Add Property' ,
options : [
{
displayName : 'Archived' ,
name : 'archived' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to only return projects whose archived field takes on the value of this parameter' ,
2020-09-08 05:00:54 -07:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Teams Name or ID' ,
2020-09-08 05:00:54 -07:00
name : 'team' ,
type : 'options' ,
typeOptions : {
loadOptionsDependsOn : [
'workspace' ,
] ,
loadOptionsMethod : 'getTeams' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The new name of the task. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2020-09-08 05:00:54 -07:00
} ,
] ,
} ,
2021-12-07 08:55:20 -08:00
// ----------------------------------
// project:update
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Workspace Name or ID' ,
2021-12-07 08:55:20 -08:00
name : 'workspace' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getWorkspaces' ,
} ,
2022-01-09 21:44:18 -08:00
options : [ ] ,
default : '' ,
required : true ,
2021-12-07 08:55:20 -08:00
displayOptions : {
show : {
operation : [
'update' ,
] ,
2022-01-09 21:44:18 -08:00
resource : [
'project' ,
] ,
2021-12-07 08:55:20 -08:00
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'The workspace in which to get users. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-12-07 08:55:20 -08:00
} ,
{
2022-02-26 02:10:40 -08:00
displayName : 'Project ID' ,
name : 'id' ,
2022-01-09 21:44:18 -08:00
type : 'string' ,
default : '' ,
required : true ,
2021-12-07 08:55:20 -08:00
displayOptions : {
show : {
operation : [
'update' ,
] ,
2022-01-09 21:44:18 -08:00
resource : [
'project' ,
] ,
2021-12-07 08:55:20 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the project to update the data of' ,
2021-12-07 08:55:20 -08:00
} ,
{
2022-01-09 21:44:18 -08:00
displayName : 'Update Fields' ,
name : 'updateFields' ,
2021-12-07 08:55:20 -08:00
type : 'collection' ,
displayOptions : {
show : {
resource : [
'project' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
default : { } ,
description : 'Other properties to set' ,
placeholder : 'Add Property' ,
options : [
{
displayName : 'Color' ,
name : 'color' ,
2022-02-26 02:10:40 -08:00
type : 'options' ,
options : getColorOptions ( ) ,
default : 'none' ,
2022-05-06 14:01:25 -07:00
description : 'Color of the project' ,
2021-12-07 08:55:20 -08:00
} ,
{
displayName : 'Due On' ,
name : 'due_on' ,
type : 'dateTime' ,
default : '' ,
2022-01-09 21:44:18 -08:00
description : 'The day on which this project is due. This takes a date with format YYYY-MM-DD.' ,
2021-12-07 08:55:20 -08:00
} ,
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the project' ,
2021-12-07 08:55:20 -08:00
} ,
{
displayName : 'Notes' ,
name : 'notes' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Basic description or notes for the project' ,
2021-12-07 08:55:20 -08:00
} ,
{
displayName : 'Owner' ,
name : 'owner' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The new assignee/cardinal for this project' ,
2021-12-07 08:55:20 -08:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Team Name or ID' ,
2021-12-07 08:55:20 -08:00
name : 'team' ,
type : 'options' ,
typeOptions : {
2022-01-09 21:44:18 -08:00
loadOptionsDependsOn : [
'workspace' ,
] ,
2021-12-07 08:55:20 -08:00
loadOptionsMethod : 'getTeams' ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'The team this project will be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-12-07 08:55:20 -08:00
} ,
] ,
} ,
2020-09-08 05:00:54 -07:00
] ,
} ;
methods = {
loadOptions : {
// Get all the available workspaces to display them to user so that he can
// select them easily
2020-09-16 09:20:27 -07:00
getWorkspaces ,
2020-09-08 05:00:54 -07:00
// Get all the available projects to display them to user so that they can be
// selected easily
async getProjects ( this : ILoadOptionsFunctions ) : Promise < INodePropertyOptions [ ] > {
const endpoint = '/projects' ;
const responseData = await asanaApiRequest . call ( this , 'GET' , endpoint , { } ) ;
if ( responseData . data === undefined ) {
2021-04-16 09:33:36 -07:00
throw new NodeApiError ( this . getNode ( ) , responseData , { message : 'No data got returned' } ) ;
2020-09-08 05:00:54 -07:00
}
const returnData : INodePropertyOptions [ ] = [ ] ;
for ( const projectData of responseData . data ) {
if ( projectData . resource_type !== 'project' ) {
// Not sure if for some reason also ever other resources
// get returned but just in case filter them out
continue ;
}
const projectName = projectData . name ;
const projectId = projectData . gid ;
returnData . push ( {
name : projectName ,
value : projectId ,
} ) ;
}
2020-09-08 05:01:16 -07:00
returnData . sort ( ( a , b ) = > {
if ( a . name < b . name ) { return - 1 ; }
if ( a . name > b . name ) { return 1 ; }
return 0 ;
} ) ;
2020-09-08 05:00:54 -07:00
return returnData ;
} ,
// Get all the available sections in a project to display them to user so that they
// can be selected easily
async getSections ( this : ILoadOptionsFunctions ) : Promise < INodePropertyOptions [ ] > {
const projectId = this . getNodeParameter ( 'projectId' ) as string ;
const endpoint = ` /projects/ ${ projectId } /sections ` ;
const responseData = await asanaApiRequest . call ( this , 'GET' , endpoint , { } ) ;
if ( responseData . data === undefined ) {
2021-04-16 09:33:36 -07:00
throw new NodeApiError ( this . getNode ( ) , responseData , { message : 'No data got returned' } ) ;
2020-09-08 05:00:54 -07:00
}
const returnData : INodePropertyOptions [ ] = [ ] ;
for ( const sectionData of responseData . data ) {
if ( sectionData . resource_type !== 'section' ) {
// Not sure if for some reason also ever other resources
// get returned but just in case filter them out
continue ;
}
returnData . push ( {
name : sectionData.name ,
value : sectionData.gid ,
} ) ;
}
2020-09-08 05:01:16 -07:00
returnData . sort ( ( a , b ) = > {
if ( a . name < b . name ) { return - 1 ; }
if ( a . name > b . name ) { return 1 ; }
return 0 ;
} ) ;
2020-09-08 05:00:54 -07:00
return returnData ;
} ,
// Get all the available teams to display them to user so that he can
// select them easily
async getTeams ( this : ILoadOptionsFunctions ) : Promise < INodePropertyOptions [ ] > {
const workspaceId = this . getCurrentNodeParameter ( 'workspace' ) ;
const workspace = await asanaApiRequest . call ( this , 'GET' , ` /workspaces/ ${ workspaceId } ` , { } ) ;
// if the workspace selected it's not an organization then error as they endpoint
// to retrieve the teams from an organization just work with workspaces that are an organization
if ( workspace . is_organization === false ) {
2021-04-16 09:33:36 -07:00
throw new NodeOperationError ( this . getNode ( ) , 'To filter by team, the workspace selected has to be an organization' ) ;
2020-09-08 05:00:54 -07:00
}
const endpoint = ` /organizations/ ${ workspaceId } /teams ` ;
const responseData = await asanaApiRequestAllItems . call ( this , 'GET' , endpoint , { } ) ;
const returnData : INodePropertyOptions [ ] = [ ] ;
for ( const teamData of responseData ) {
if ( teamData . resource_type !== 'team' ) {
// Not sure if for some reason also ever other resources
// get returned but just in case filter them out
continue ;
}
returnData . push ( {
name : teamData.name ,
value : teamData.gid ,
} ) ;
}
2020-09-08 05:01:16 -07:00
returnData . sort ( ( a , b ) = > {
if ( a . name < b . name ) { return - 1 ; }
if ( a . name > b . name ) { return 1 ; }
return 0 ;
} ) ;
2020-09-08 05:00:54 -07:00
return returnData ;
} ,
// Get all tags to display them to user so that they can be selected easily
// See: https://developers.asana.com/docs/get-multiple-tags
async getTags ( this : ILoadOptionsFunctions ) : Promise < INodePropertyOptions [ ] > {
const endpoint = '/tags' ;
2020-09-08 05:01:16 -07:00
const taskId = this . getNodeParameter ( 'id' ) as string ;
let taskData ;
try {
taskData = await asanaApiRequest . call ( this , 'GET' , ` /tasks/ ${ taskId } ` , { } ) ;
2021-04-16 09:33:36 -07:00
} catch ( error ) {
throw new NodeApiError ( this . getNode ( ) , error , { message : ` Could not find task with id " ${ taskId } " so tags could not be loaded. ` } ) ;
2020-09-08 05:01:16 -07:00
}
const workspace = taskData . data . workspace . gid ;
const responseData = await asanaApiRequest . call ( this , 'GET' , endpoint , { } , { workspace } ) ;
2020-09-08 05:00:54 -07:00
if ( responseData . data === undefined ) {
2021-04-16 09:33:36 -07:00
throw new NodeApiError ( this . getNode ( ) , responseData , { message : 'No data got returned' } ) ;
2020-09-08 05:00:54 -07:00
}
const returnData : INodePropertyOptions [ ] = [ ] ;
for ( const tagData of responseData . data ) {
if ( tagData . resource_type !== 'tag' ) {
// Not sure if for some reason also ever other resources
// get returned but just in case filter them out
continue ;
}
returnData . push ( {
name : tagData.name ,
value : tagData.gid ,
} ) ;
}
2020-09-08 05:01:16 -07:00
returnData . sort ( ( a , b ) = > {
if ( a . name < b . name ) { return - 1 ; }
if ( a . name > b . name ) { return 1 ; }
return 0 ;
} ) ;
2020-09-08 05:00:54 -07:00
return returnData ;
} ,
// Get all users to display them to user so that they can be selected easily
// See: https://developers.asana.com/docs/get-multiple-users
async getUsers ( this : ILoadOptionsFunctions ) : Promise < INodePropertyOptions [ ] > {
const endpoint = ` /users ` ;
const responseData = await asanaApiRequest . call ( this , 'GET' , endpoint , { } ) ;
if ( responseData . data === undefined ) {
2021-04-16 09:33:36 -07:00
throw new NodeApiError ( this . getNode ( ) , responseData , { message : 'No data got returned' } ) ;
2020-09-08 05:00:54 -07:00
}
const returnData : INodePropertyOptions [ ] = [ ] ;
for ( const userData of responseData . data ) {
if ( userData . resource_type !== 'user' ) {
// Not sure if for some reason also ever other resources
// get returned but just in case filter them out
continue ;
}
returnData . push ( {
name : userData.name ,
value : userData.gid ,
} ) ;
}
2019-06-23 03:35:23 -07:00
return returnData ;
2020-10-22 06:46:03 -07:00
} ,
2020-12-25 11:41:48 -08:00
async getTaskFields ( this : ILoadOptionsFunctions ) : Promise < INodePropertyOptions [ ] > {
const returnData : INodePropertyOptions [ ] = [ ] ;
for ( const field of getTaskFields ( ) ) {
const value = snakeCase ( field ) ;
returnData . push ( {
name : field ,
value : ( value === '' ) ? '*' : value ,
} ) ;
}
return returnData ;
} ,
2019-06-23 03:35:23 -07:00
} ,
} ;
async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
const items = this . getInputData ( ) ;
const returnData : IDataObject [ ] = [ ] ;
2020-12-22 14:44:31 -08:00
const timezone = this . getTimezone ( ) ;
2019-06-23 03:35:23 -07:00
2019-07-12 09:35:35 -07:00
const resource = this . getNodeParameter ( 'resource' , 0 ) as string ;
2019-06-23 03:35:23 -07:00
const operation = this . getNodeParameter ( 'operation' , 0 ) as string ;
let endpoint = '' ;
2022-02-05 13:55:43 -08:00
let requestMethod : IHttpRequestMethods = 'GET' ;
2019-06-23 03:35:23 -07:00
let body : IDataObject ;
let qs : IDataObject ;
2020-09-08 05:00:54 -07:00
let responseData ;
2019-06-23 03:35:23 -07:00
for ( let i = 0 ; i < items . length ; i ++ ) {
2021-07-19 23:58:54 -07:00
try {
body = { } ;
qs = { } ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
if ( resource === 'subtask' ) {
if ( operation === 'create' ) {
// ----------------------------------
// subtask:create
// ----------------------------------
2020-12-22 14:44:31 -08:00
2021-07-19 23:58:54 -07:00
const taskId = this . getNodeParameter ( 'taskId' , i ) as string ;
2020-12-22 14:44:31 -08:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
endpoint = ` /tasks/ ${ taskId } /subtasks ` ;
2020-12-22 14:44:31 -08:00
2021-07-19 23:58:54 -07:00
body . name = this . getNodeParameter ( 'name' , i ) as string ;
2020-12-22 14:44:31 -08:00
2021-07-19 23:58:54 -07:00
const otherProperties = this . getNodeParameter ( 'otherProperties' , i ) as IDataObject ;
Object . assign ( body , otherProperties ) ;
2020-12-22 14:44:31 -08:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-12-22 14:44:31 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
}
2020-12-25 11:41:48 -08:00
2021-07-19 23:58:54 -07:00
if ( operation === 'getAll' ) {
// ----------------------------------
// subtask:getAll
// ----------------------------------
const taskId = this . getNodeParameter ( 'taskId' , i ) as string ;
2020-12-25 11:41:48 -08:00
2021-07-19 23:58:54 -07:00
const returnAll = this . getNodeParameter ( 'returnAll' , i ) as boolean ;
2020-12-25 11:41:48 -08:00
2021-07-19 23:58:54 -07:00
const options = this . getNodeParameter ( 'options' , i ) as IDataObject ;
2020-12-25 11:41:48 -08:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
endpoint = ` /tasks/ ${ taskId } /subtasks ` ;
2020-12-25 11:41:48 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( qs , options ) ;
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
if ( qs . opt_fields ) {
const fields = qs . opt_fields as string [ ] ;
if ( fields . includes ( '*' ) ) {
qs . opt_fields = getTaskFields ( ) . map ( ( e ) = > snakeCase ( e ) ) . join ( ',' ) ;
} else {
qs . opt_fields = ( qs . opt_fields as string [ ] ) . join ( ',' ) ;
}
2020-12-25 11:41:48 -08:00
}
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-12-25 11:41:48 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
2020-12-25 11:41:48 -08:00
2021-12-07 08:55:20 -08:00
if ( ! returnAll ) {
2021-07-19 23:58:54 -07:00
const limit = this . getNodeParameter ( 'limit' , i ) as boolean ;
responseData = responseData . splice ( 0 , limit ) ;
}
2020-12-25 11:41:48 -08:00
}
}
2021-07-19 23:58:54 -07:00
if ( resource === 'task' ) {
if ( operation === 'create' ) {
// ----------------------------------
// task:create
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
endpoint = '/tasks' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
body . name = this . getNodeParameter ( 'name' , i ) as string ;
// body.notes = this.getNodeParameter('taskNotes', 0) as string;
body . workspace = this . getNodeParameter ( 'workspace' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const otherProperties = this . getNodeParameter ( 'otherProperties' , i ) as IDataObject ;
Object . assign ( body , otherProperties ) ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'delete' ) {
// ----------------------------------
// task:delete
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'DELETE' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = '/tasks/' + this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'get' ) {
// ----------------------------------
// task:get
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = '/tasks/' + this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'getAll' ) {
// ----------------------------------
// task:getAll
// ----------------------------------
2020-12-25 11:41:48 -08:00
2021-07-19 23:58:54 -07:00
const filters = this . getNodeParameter ( 'filters' , i ) as IDataObject ;
const returnAll = this . getNodeParameter ( 'returnAll' , i ) as boolean ;
2020-12-22 14:44:31 -08:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
endpoint = ` /tasks ` ;
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( qs , filters ) ;
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
if ( qs . opt_fields ) {
const fields = qs . opt_fields as string [ ] ;
if ( fields . includes ( '*' ) ) {
qs . opt_fields = getTaskFields ( ) . map ( ( e ) = > snakeCase ( e ) ) . join ( ',' ) ;
} else {
qs . opt_fields = ( qs . opt_fields as string [ ] ) . join ( ',' ) ;
}
2020-12-22 14:44:31 -08:00
}
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
if ( qs . modified_since ) {
qs . modified_since = moment . tz ( qs . modified_since as string , timezone ) . format ( ) ;
}
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
if ( qs . completed_since ) {
qs . completed_since = moment . tz ( qs . completed_since as string , timezone ) . format ( ) ;
}
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
if ( returnAll ) {
responseData = await asanaApiRequestAllItems . call ( this , requestMethod , endpoint , body , qs ) ;
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
} else {
qs . limit = this . getNodeParameter ( 'limit' , i ) as boolean ;
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
}
2020-12-27 23:48:57 -08:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'move' ) {
// ----------------------------------
// task:move
// ----------------------------------
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
const sectionId = this . getNodeParameter ( 'section' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /sections/ ${ sectionId } /addTask ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
body . task = this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
Object . assign ( body ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = { success : true } ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'update' ) {
// ----------------------------------
// task:update
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'PUT' ;
endpoint = '/tasks/' + this . getNodeParameter ( 'id' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const otherProperties = this . getNodeParameter ( 'otherProperties' , i ) as IDataObject ;
Object . assign ( body , otherProperties ) ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'search' ) {
// ----------------------------------
// tasksearch
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const workspaceId = this . getNodeParameter ( 'workspace' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
endpoint = ` /workspaces/ ${ workspaceId } /tasks/search ` ;
2019-07-12 09:35:35 -07:00
2021-07-19 23:58:54 -07:00
const searchTaskProperties = this . getNodeParameter ( 'searchTaskProperties' , i ) as IDataObject ;
Object . assign ( qs , searchTaskProperties ) ;
2019-07-12 09:35:35 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
}
2020-09-08 05:00:54 -07:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'taskComment' ) {
if ( operation === 'add' ) {
// ----------------------------------
// taskComment:add
// ----------------------------------
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
const taskId = this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
const isTextHtml = this . getNodeParameter ( 'isTextHtml' , i ) as boolean ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
if ( ! isTextHtml ) {
body . text = this . getNodeParameter ( 'text' , i ) as string ;
} else {
body . html_text = this . getNodeParameter ( 'text' , i ) as string ;
}
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /tasks/ ${ taskId } /stories ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
Object . assign ( body , additionalFields ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
}
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'remove' ) {
// ----------------------------------
// taskComment:remove
// ----------------------------------
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
const commentId = this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'DELETE' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /stories/ ${ commentId } ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = { success : true } ;
}
2020-09-08 05:00:54 -07:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'taskTag' ) {
if ( operation === 'add' ) {
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
// ----------------------------------
// taskTag:add
// ----------------------------------
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
const taskId = this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /tasks/ ${ taskId } /addTag ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
body . tag = this . getNodeParameter ( 'tag' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = { success : true } ;
}
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'remove' ) {
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
// ----------------------------------
// taskTag:remove
// ----------------------------------
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
const taskId = this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /tasks/ ${ taskId } /removeTag ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
body . tag = this . getNodeParameter ( 'tag' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = { success : true } ;
}
2020-09-08 05:00:54 -07:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'taskProject' ) {
if ( operation === 'add' ) {
// ----------------------------------
// taskProject:add
// ----------------------------------
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
const taskId = this . getNodeParameter ( 'id' , i ) as string ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
endpoint = ` /tasks/ ${ taskId } /addProject ` ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
body . project = this . getNodeParameter ( 'project' , i ) as string ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( body , additionalFields ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
responseData = { success : true } ;
}
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
if ( operation === 'remove' ) {
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
// ----------------------------------
// taskProject:remove
// ----------------------------------
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
const taskId = this . getNodeParameter ( 'id' , i ) as string ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
endpoint = ` /tasks/ ${ taskId } /removeProject ` ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
body . project = this . getNodeParameter ( 'project' , i ) as string ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2021-01-30 09:34:49 -08:00
2021-07-19 23:58:54 -07:00
responseData = { success : true } ;
}
2021-01-30 09:34:49 -08:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'user' ) {
if ( operation === 'get' ) {
// ----------------------------------
// get
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const userId = this . getNodeParameter ( 'userId' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
endpoint = ` /users/ ${ userId } ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
responseData = responseData . data ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'getAll' ) {
// ----------------------------------
// getAll
// ----------------------------------
2019-07-12 09:35:35 -07:00
2021-07-19 23:58:54 -07:00
const workspaceId = this . getNodeParameter ( 'workspace' , i ) as string ;
2019-07-12 09:35:35 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
endpoint = ` /workspaces/ ${ workspaceId } /users ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
responseData = responseData . data ;
2019-07-12 09:35:35 -07:00
2021-07-19 23:58:54 -07:00
}
2019-07-12 09:35:35 -07:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'project' ) {
2021-12-07 08:55:20 -08:00
if ( operation === 'create' ) {
// ----------------------------------
// project:create
// ----------------------------------
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
const teamId = this . getNodeParameter ( 'team' , i ) ;
// request parameters
requestMethod = 'POST' ;
endpoint = ` /teams/ ${ teamId } /projects ` ;
// required parameters
body . name = this . getNodeParameter ( 'name' , i ) ;
body . workspace = this . getNodeParameter ( 'workspace' , i ) ;
// optional parameters
if ( additionalFields . color ) {
qs . color = additionalFields . color ;
}
if ( additionalFields . due_on ) {
qs . due_on = additionalFields . due_on ;
}
if ( additionalFields . notes ) {
qs . notes = additionalFields . notes ;
}
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
responseData = responseData . data ;
}
if ( operation === 'delete' ) {
// ----------------------------------
// project:delete
// ----------------------------------
const projectId = this . getNodeParameter ( 'id' , i ) as string ;
requestMethod = 'DELETE' ;
endpoint = ` /projects/ ${ projectId } ` ;
2022-02-26 02:10:40 -08:00
asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2021-12-07 08:55:20 -08:00
2022-02-26 02:10:40 -08:00
responseData = { success : true } ;
2021-12-07 08:55:20 -08:00
}
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'get' ) {
// ----------------------------------
// project:get
// ----------------------------------
const projectId = this . getNodeParameter ( 'id' , i ) as string ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /projects/ ${ projectId } ` ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . data ;
2020-09-08 05:00:54 -07:00
}
2021-07-19 23:58:54 -07:00
if ( operation === 'getAll' ) {
// ----------------------------------
// project:getAll
// ----------------------------------
const workspaceId = this . getNodeParameter ( 'workspace' , i ) as string ;
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
const returnAll = this . getNodeParameter ( 'returnAll' , i ) as boolean ;
requestMethod = 'GET' ;
endpoint = ` /projects ` ;
if ( additionalFields . team ) {
qs . team = additionalFields . team ;
} else {
qs . workspace = workspaceId ;
}
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . archived ) {
qs . archived = additionalFields . archived as boolean ;
}
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
if ( returnAll ) {
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequestAllItems . call ( this , requestMethod , endpoint , body , qs ) ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
} else {
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
qs . limit = this . getNodeParameter ( 'limit' , i ) as boolean ;
2020-09-08 05:00:54 -07:00
2021-07-19 23:58:54 -07:00
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
responseData = responseData . data ;
}
2020-09-08 05:00:54 -07:00
}
2021-12-07 08:55:20 -08:00
if ( operation === 'update' ) {
// ----------------------------------
// project:update
// ----------------------------------
2022-02-26 02:10:40 -08:00
const projectId = this . getNodeParameter ( 'id' , i ) as string ;
2022-01-09 21:44:18 -08:00
const updateFields = this . getNodeParameter ( 'updateFields' , i ) as IDataObject ;
2021-12-07 08:55:20 -08:00
// request parameters
requestMethod = 'PUT' ;
endpoint = ` /projects/ ${ projectId } ` ;
// optional parameters
2022-01-09 21:44:18 -08:00
if ( updateFields . color ) {
qs . color = updateFields . color ;
2021-12-07 08:55:20 -08:00
}
2022-01-09 21:44:18 -08:00
if ( updateFields . due_on ) {
qs . due_on = updateFields . due_on ;
2021-12-07 08:55:20 -08:00
}
2022-01-09 21:44:18 -08:00
if ( updateFields . name ) {
body . name = updateFields . name ;
2021-12-07 08:55:20 -08:00
}
2022-01-09 21:44:18 -08:00
if ( updateFields . notes ) {
qs . notes = updateFields . notes ;
2021-12-07 08:55:20 -08:00
}
2022-01-09 21:44:18 -08:00
if ( updateFields . owner ) {
body . owner = updateFields . owner ;
2021-12-07 08:55:20 -08:00
}
2022-01-09 21:44:18 -08:00
if ( updateFields . team ) {
body . team = updateFields . team ;
2021-12-07 08:55:20 -08:00
}
responseData = await asanaApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
responseData = responseData . data ;
}
2020-09-08 05:00:54 -07:00
}
2021-07-19 23:58:54 -07:00
if ( Array . isArray ( responseData ) ) {
returnData . push . apply ( returnData , responseData as IDataObject [ ] ) ;
} else {
returnData . push ( responseData ) ;
}
} catch ( error ) {
if ( this . continueOnFail ( ) ) {
returnData . push ( { error : error.message } ) ;
continue ;
}
throw error ;
2020-09-08 05:00:54 -07:00
}
2019-06-23 03:35:23 -07:00
}
return [ this . helpers . returnJsonArray ( returnData ) ] ;
}
}