From a1fed27229a15e00ecd3a133c7a728bd9cc45245 Mon Sep 17 00:00:00 2001 From: quansenB Date: Thu, 24 Oct 2019 20:15:57 +0200 Subject: [PATCH 01/52] add CRUD deal descriptions --- packages/editor-ui/jsnon cop passte | 1 + packages/editor-ui/package.json | 4 +- .../ActiveCampaign/ActiveCampaign.node.ts | 496 +++++++++++++++++- 3 files changed, 498 insertions(+), 3 deletions(-) create mode 100644 packages/editor-ui/jsnon cop passte diff --git a/packages/editor-ui/jsnon cop passte b/packages/editor-ui/jsnon cop passte new file mode 100644 index 00000000000..dbfd27f67f5 --- /dev/null +++ b/packages/editor-ui/jsnon cop passte @@ -0,0 +1 @@ +//VUE_APP_URL_BASE_API=http://localhost:5678/ \ No newline at end of file diff --git a/packages/editor-ui/package.json b/packages/editor-ui/package.json index 7047295fba9..82534d8a878 100644 --- a/packages/editor-ui/package.json +++ b/packages/editor-ui/package.json @@ -17,7 +17,7 @@ "build": "vue-cli-service build", "dev": "npm run serve", "lint": "vue-cli-service lint", - "serve": "VUE_APP_URL_BASE_API=http://localhost:5678/ vue-cli-service serve", + "serve": "vue-cli-service serve", "test": "npm run test:unit", "tslint": "tslint -p tsconfig.json -c tslint.json", "test:e2e": "vue-cli-service test:e2e", @@ -78,4 +78,4 @@ "vue-typed-mixins": "^0.1.0", "vuex": "^3.1.1" } -} +} \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index e6efe97457b..d4fb4edcac0 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -59,6 +59,10 @@ export class ActiveCampaign implements INodeType { } ], properties: [ + + // ---------------------------------- + // resources + // ---------------------------------- { displayName: 'Resource', name: 'resource', @@ -68,6 +72,10 @@ export class ActiveCampaign implements INodeType { name: 'Contact', value: 'contact', }, + { + name: 'Deal', + value: 'deal', + } ], default: 'contact', description: 'The resource to operate on.', @@ -120,6 +128,48 @@ export class ActiveCampaign implements INodeType { description: 'The operation to perform.', }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'deal', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a deal', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a deal', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a deal', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all deals', + }, + { + name: 'Update', + value: 'update', + description: 'Update a deal', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, + // ---------------------------------- @@ -261,7 +311,7 @@ export class ActiveCampaign implements INodeType { }, // ---------------------------------- - // person:get + // contact:get // ---------------------------------- { displayName: 'Contact ID', @@ -429,7 +479,451 @@ export class ActiveCampaign implements INodeType { }, ], }, + // ---------------------------------- + // deal + // ---------------------------------- + // ---------------------------------- + // deal:create + // ---------------------------------- + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The title of the deal', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The description of the deal', + }, + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + { + displayName: 'Deal value', + name: 'dealValue', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The value of the deal in cents', + }, + { + displayName: 'Currency', + name: 'currency', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The currency of the deal in 3-character ISO format', + }, + { + displayName: 'Deal group ID', + name: 'dealGroup', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The group ID of the deal', + }, + { + displayName: 'Deal stage ID', + name: 'dealStage', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The stage ID of the deal', + }, + { + displayName: 'Deal owner ID', + name: 'dealOwner', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The owner ID of the deal', + }, + { + displayName: 'Deal percentage', + name: 'dealPercentage', + type: 'number', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'dealStatus', + type: 'number', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The status of the deal', + }, + + // ---------------------------------- + // deal:delete + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + + // ---------------------------------- + // deal:get + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + + // ---------------------------------- + // deal:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, + + // ---------------------------------- + // deal:update + // ---------------------------------- + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The title of the deal', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The description of the deal', + }, + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + { + displayName: 'Deal value', + name: 'dealValue', + type: 'number', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The value of the deal in cents', + }, + { + displayName: 'Currency', + name: 'currency', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The currency of the deal in 3-character ISO format', + }, + { + displayName: 'Deal group ID', + name: 'dealGroup', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The group ID of the deal', + }, + { + displayName: 'Deal stage ID', + name: 'dealStage', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The stage ID of the deal', + }, + { + displayName: 'Deal owner ID', + name: 'dealOwner', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The owner ID of the deal', + }, + { + displayName: 'Deal percentage', + name: 'dealPercentage', + type: 'number', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'dealStatus', + type: 'number', + default: '', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The status of the deal', + }, ], }; From 445384a590d79f0edd1118b462686d14106a6f2f Mon Sep 17 00:00:00 2001 From: quansenB Date: Thu, 24 Oct 2019 20:21:28 +0200 Subject: [PATCH 02/52] deal-note-description --- .../ActiveCampaign/ActiveCampaign.node.ts | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index d4fb4edcac0..433bbc75424 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -165,6 +165,16 @@ export class ActiveCampaign implements INodeType { value: 'update', description: 'Update a deal', }, + { + name: 'Create Note', + value: 'createNote', + description: 'Create a deal note', + }, + { + name: 'Update deal note', + value: 'updateNote', + description: 'Update a deal note', + }, ], default: 'create', description: 'The operation to perform.', @@ -924,6 +934,85 @@ export class ActiveCampaign implements INodeType { }, description: 'The status of the deal', }, + + // ---------------------------------- + // dealNote:create + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'createNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal Note', + name: 'dealNote', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'createNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The content of the deal note', + }, + + // ---------------------------------- + // dealNote:update + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal Note', + name: 'dealNote', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The content of the deal note', + }, ], }; From c8bd2d538d3136f3bbbf4d5f03243b3fb2b34d7f Mon Sep 17 00:00:00 2001 From: quansenB Date: Thu, 24 Oct 2019 20:29:45 +0200 Subject: [PATCH 03/52] rename misspelled file --- packages/editor-ui/{jsnon cop passte => package json debug} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/editor-ui/{jsnon cop passte => package json debug} (100%) diff --git a/packages/editor-ui/jsnon cop passte b/packages/editor-ui/package json debug similarity index 100% rename from packages/editor-ui/jsnon cop passte rename to packages/editor-ui/package json debug From cd28bbcbdc0ff472f7547eeb44b40814d318d11f Mon Sep 17 00:00:00 2001 From: quansenB Date: Thu, 24 Oct 2019 20:50:57 +0200 Subject: [PATCH 04/52] rename deal id --- .../nodes/ActiveCampaign/ActiveCampaign.node.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 433bbc75424..b4dcbf57dfc 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -532,8 +532,8 @@ export class ActiveCampaign implements INodeType { description: 'The description of the deal', }, { - displayName: 'Deal ID', - name: 'dealId', + displayName: 'Deal\'s contact ID', + name: 'contactId', type: 'number', default: '', required: true, @@ -547,7 +547,7 @@ export class ActiveCampaign implements INodeType { ], }, }, - description: 'The ID of the deal', + description: 'The ID of the deal\'s contact', }, { displayName: 'Deal value', @@ -799,8 +799,8 @@ export class ActiveCampaign implements INodeType { description: 'The description of the deal', }, { - displayName: 'Deal ID', - name: 'dealId', + displayName: 'Deal\'s contact ID', + name: 'contactId', type: 'number', default: '', displayOptions: { @@ -813,7 +813,7 @@ export class ActiveCampaign implements INodeType { ], }, }, - description: 'The ID of the deal', + description: 'The ID of the deal\'s contact', }, { displayName: 'Deal value', @@ -974,7 +974,7 @@ export class ActiveCampaign implements INodeType { }, description: 'The content of the deal note', }, - + // ---------------------------------- // dealNote:update // ---------------------------------- From e896c1c319b1b92b7215e0b9d88cef73b8c1fa08 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 02:50:03 +0200 Subject: [PATCH 05/52] rorder resources --- .../ActiveCampaign/ActiveCampaign.node.ts | 361 +++++++++--------- 1 file changed, 182 insertions(+), 179 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index b4dcbf57dfc..4cd415c1f04 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -297,96 +297,7 @@ export class ActiveCampaign implements INodeType { }, ], }, - - // ---------------------------------- - // contact:delete - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to delete.', - }, - - // ---------------------------------- - // contact:get - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to get.', - }, - - // ---------------------------------- - // contact:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, - + // ---------------------------------- // contact:update // ---------------------------------- @@ -489,6 +400,97 @@ export class ActiveCampaign implements INodeType { }, ], }, + + // ---------------------------------- + // contact:delete + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to delete.', + }, + + // ---------------------------------- + // contact:get + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to get.', + }, + + // ---------------------------------- + // contact:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'contact', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'contact', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, + + // ---------------------------------- // deal // ---------------------------------- @@ -671,95 +673,6 @@ export class ActiveCampaign implements INodeType { description: 'The status of the deal', }, - // ---------------------------------- - // deal:delete - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal', - }, - - // ---------------------------------- - // deal:get - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal', - }, - - // ---------------------------------- - // deal:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, - // ---------------------------------- // deal:update // ---------------------------------- @@ -935,6 +848,96 @@ export class ActiveCampaign implements INodeType { description: 'The status of the deal', }, + + // ---------------------------------- + // deal:delete + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + + // ---------------------------------- + // deal:get + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + + // ---------------------------------- + // deal:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, + // ---------------------------------- // dealNote:create // ---------------------------------- From 683c889a14e7318866a2e3d0fe7a528902826e7e Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 14:24:24 +0200 Subject: [PATCH 06/52] set up functionality layout --- .../ActiveCampaign/ActiveCampaign.node.ts | 107 ++++++++++++++---- 1 file changed, 86 insertions(+), 21 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 4cd415c1f04..475f712beba 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -297,7 +297,7 @@ export class ActiveCampaign implements INodeType { }, ], }, - + // ---------------------------------- // contact:update // ---------------------------------- @@ -672,7 +672,7 @@ export class ActiveCampaign implements INodeType { }, description: 'The status of the deal', }, - + // ---------------------------------- // deal:update // ---------------------------------- @@ -848,7 +848,7 @@ export class ActiveCampaign implements INodeType { description: 'The status of the deal', }, - + // ---------------------------------- // deal:delete // ---------------------------------- @@ -892,7 +892,7 @@ export class ActiveCampaign implements INodeType { }, description: 'The ID of the deal', }, - + // ---------------------------------- // deal:getAll // ---------------------------------- @@ -1120,24 +1120,89 @@ export class ActiveCampaign implements INodeType { addAdditionalFields(body.contact as IDataObject, updateFields); } - } else { - throw new Error(`The resource "${resource}" is not known!`); + } else if (resource === 'deal') { + if (operation === 'create') { + // ---------------------------------- + // deal:create + // ---------------------------------- + + requestMethod = 'POST'; + + dataKey = 'deal'; + body.deal = { + email: this.getNodeParameter('email', i) as string, + } as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + addAdditionalFields(body.deal as IDataObject, additionalFields); + + } else if (operation === 'delete') { + // ---------------------------------- + // deal:delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + const dealId = this.getNodeParameter('dealId', i) as number; + endpoint = `/api/3/deals/${dealId}`; + + } else if (operation === 'get') { + // ---------------------------------- + // deal:get + // ---------------------------------- + + requestMethod = 'GET'; + + const dealId = this.getNodeParameter('dealId', i) as number; + endpoint = `/api/3/deals/${dealId}`; + + } else if (operation === 'getAll') { + // ---------------------------------- + // persons:getAll + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + dataKey = 'deals'; + endpoint = `/api/3/deals`; + + } else if (operation === 'update') { + // ---------------------------------- + // deal:update + // ---------------------------------- + + requestMethod = 'PUT'; + + const dealId = this.getNodeParameter('dealId', i) as number; + endpoint = `/api/3/deals/${dealId}`; + + dataKey = 'deal'; + body.deal = {} as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + addAdditionalFields(body.deal as IDataObject, updateFields); + + } else { + throw new Error(`The resource "${resource}" is not known!`); + } + + let responseData; + if (returnAll === true) { + responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey); + } else { + responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey); + } + + if (Array.isArray(responseData)) { + returnData.push.apply(returnData, responseData as IDataObject[]); + } else { + returnData.push(responseData as IDataObject); + } } - let responseData; - if (returnAll === true) { - responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey); - } else { - responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey); - } - - if (Array.isArray(responseData)) { - returnData.push.apply(returnData, responseData as IDataObject[]); - } else { - returnData.push(responseData as IDataObject); - } + return [this.helpers.returnJsonArray(returnData)]; } - - return [this.helpers.returnJsonArray(returnData)]; } -} From 16e9c41f2793b5bc2e042a9d668b781d8759806d Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 14:50:15 +0200 Subject: [PATCH 07/52] fix some small things in node description --- .../ActiveCampaign/ActiveCampaign.node.ts | 53 ++++++++++++------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 475f712beba..39042adad06 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -12,6 +12,7 @@ import { activeCampaignApiRequest, activeCampaignApiRequestAllItems, } from './GenericFunctions'; +import { type } from 'os'; interface CustomProperty { name: string; @@ -500,7 +501,7 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- { displayName: 'Title', - name: 'title', + name: 'dealTitle', type: 'string', default: '', required: true, @@ -518,7 +519,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Description', - name: 'description', + name: 'dealDescription', type: 'string', default: '', displayOptions: { @@ -535,9 +536,9 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal\'s contact ID', - name: 'contactId', + name: 'dealContactId', type: 'number', - default: '', + default: 0, required: true, displayOptions: { show: { @@ -555,7 +556,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal value', name: 'dealValue', type: 'number', - default: '', + default: 0, required: true, displayOptions: { show: { @@ -571,7 +572,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Currency', - name: 'currency', + name: 'dealCurrency', type: 'string', default: '', required: true, @@ -642,7 +643,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal percentage', name: 'dealPercentage', type: 'number', - default: '', + default: 0, displayOptions: { show: { operation: [ @@ -659,7 +660,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal status', name: 'dealStatus', type: 'number', - default: '', + default: 0, displayOptions: { show: { operation: [ @@ -678,7 +679,7 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- { displayName: 'Title', - name: 'title', + name: 'dealTitle', type: 'string', default: '', required: true, @@ -696,7 +697,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Description', - name: 'description', + name: 'dealDescription', type: 'string', default: '', displayOptions: { @@ -713,9 +714,9 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal\'s contact ID', - name: 'contactId', + name: 'dealContactId', type: 'number', - default: '', + default: 0, displayOptions: { show: { operation: [ @@ -732,7 +733,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal value', name: 'dealValue', type: 'number', - default: '', + default: 0, displayOptions: { show: { operation: [ @@ -747,7 +748,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Currency', - name: 'currency', + name: 'dealCurrency', type: 'string', default: '', displayOptions: { @@ -817,7 +818,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal percentage', name: 'dealPercentage', type: 'number', - default: '', + default: 0, displayOptions: { show: { operation: [ @@ -834,7 +835,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal status', name: 'dealStatus', type: 'number', - default: '', + default: 0, displayOptions: { show: { operation: [ @@ -1129,11 +1130,25 @@ export class ActiveCampaign implements INodeType { requestMethod = 'POST'; dataKey = 'deal'; + + let currency = this.getNodeParameter('dealCurrency', i) as string; + if(currency.length !== 3){ + currency = currency.toLowerCase(); + } + body.deal = { - email: this.getNodeParameter('email', i) as string, + title: this.getNodeParameter('title', i) as string, + contact: this.getNodeParameter('contactId', i) as string, + value: this.getNodeParameter('value', i) as number, + currency, } as IDataObject; - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - addAdditionalFields(body.deal as IDataObject, additionalFields); + + let dealDescription = this.getNodeParameter('description', i) as string; + let dealGroup = this.getNodeParameter('dealGroup', i) as string; + let dealStage = this.getNodeParameter('dealStage', i) as string; + let dealPercentage = this.getNodeParameter('dealPercentage', i) as number; + let dealStatus = this.getNodeParameter('dealStatus', i) as number; + } else if (operation === 'delete') { // ---------------------------------- From 8b7398bf393893cb2d59dd1ac5f9371c7ff3a2f3 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 14:51:46 +0200 Subject: [PATCH 08/52] add dealId to update decription --- .../ActiveCampaign/ActiveCampaign.node.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 39042adad06..2842f23b4fb 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -677,6 +677,24 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- // deal:update // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, { displayName: 'Title', name: 'dealTitle', @@ -857,7 +875,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal ID', name: 'dealId', type: 'number', - default: '', + default: 0, required: true, displayOptions: { show: { @@ -879,7 +897,7 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal ID', name: 'dealId', type: 'number', - default: '', + default: 0, required: true, displayOptions: { show: { From f5c585c7be6721e84080f45813cb083a9879e5ef Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 15:47:43 +0200 Subject: [PATCH 09/52] add not required fields to body.deal obj --- .../ActiveCampaign/ActiveCampaign.node.ts | 65 ++++++++++++++----- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 2842f23b4fb..b9d28cf884f 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -38,6 +38,17 @@ function addAdditionalFields(body: IDataObject, additionalFields: IDataObject) { } } +/** + * Add one additional field to the body + * + * @param {IDataObject} body The body object to add the field to + * @param {IDataObject} additionalField The field to add + */ +function addAdditionalField(body: IDataObject, additionalField: string | number) { + body.additionalField = additionalField; +} + + export class ActiveCampaign implements INodeType { description: INodeTypeDescription = { displayName: 'ActiveCampaign', @@ -1148,25 +1159,47 @@ export class ActiveCampaign implements INodeType { requestMethod = 'POST'; dataKey = 'deal'; - - let currency = this.getNodeParameter('dealCurrency', i) as string; - if(currency.length !== 3){ - currency = currency.toLowerCase(); - } - + body.deal = { - title: this.getNodeParameter('title', i) as string, - contact: this.getNodeParameter('contactId', i) as string, - value: this.getNodeParameter('value', i) as number, - currency, + title: this.getNodeParameter('dealTitle', i) as string, + contact: this.getNodeParameter('dealContactId', i) as string, + value: this.getNodeParameter('dealValue', i) as number, + currency: '', } as IDataObject; - let dealDescription = this.getNodeParameter('description', i) as string; - let dealGroup = this.getNodeParameter('dealGroup', i) as string; - let dealStage = this.getNodeParameter('dealStage', i) as string; - let dealPercentage = this.getNodeParameter('dealPercentage', i) as number; - let dealStatus = this.getNodeParameter('dealStatus', i) as number; - + let currency= this.getNodeParameter('dealCurrency', i) as string + if (currency.length === 3) { + currency = currency.toLowerCase(); + addAdditionalField(body.deal as IDataObject, currency) + } else { + throw new Error('Currency must be in 3-character ISO format') + } + + let description = this.getNodeParameter('dealDescription', i) as string; + if (description.length !== 0){ + addAdditionalField(body.deal as IDataObject, description) + } + + let group = this.getNodeParameter('dealGroup', i) as string; + if (group.length !== 0){ + addAdditionalField(body.deal as IDataObject, group) + } + + let stage = this.getNodeParameter('dealStage', i) as string; + if (stage.length !== 0){ + addAdditionalField(body.deal as IDataObject, stage) + } + + let percentage = this.getNodeParameter('dealPercentage', i) as number; + if (percentage !== 0){ + addAdditionalField(body.deal as IDataObject, percentage) + } + + let status = this.getNodeParameter('dealStatus', i) as number; + if (status !== 0){ + addAdditionalField(body.deal as IDataObject, status) + } + } else if (operation === 'delete') { // ---------------------------------- From 0034a17b17d8975b12d3b3511693affdc05ced31 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 16:15:01 +0200 Subject: [PATCH 10/52] revert to addition fields design choice --- .../ActiveCampaign/ActiveCampaign.node.ts | 313 ++++++------------ 1 file changed, 103 insertions(+), 210 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index b9d28cf884f..0af2409e164 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -528,23 +528,6 @@ export class ActiveCampaign implements INodeType { }, description: 'The title of the deal', }, - { - displayName: 'Description', - name: 'dealDescription', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The description of the deal', - }, { displayName: 'Deal\'s contact ID', name: 'dealContactId', @@ -600,10 +583,10 @@ export class ActiveCampaign implements INodeType { description: 'The currency of the deal in 3-character ISO format', }, { - displayName: 'Deal group ID', - name: 'dealGroup', - type: 'string', - default: '', + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', displayOptions: { show: { operation: [ @@ -614,75 +597,51 @@ export class ActiveCampaign implements INodeType { ], }, }, - description: 'The group ID of the deal', - }, - { - displayName: 'Deal stage ID', - name: 'dealStage', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + default: {}, + options: [ + { + displayName: 'Description', + name: 'dealDescription', + type: 'string', + default: '', + description: 'The description of the deal', }, - }, - description: 'The stage ID of the deal', - }, - { - displayName: 'Deal owner ID', - name: 'dealOwner', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + { + displayName: 'Deal group ID', + name: 'dealGroup', + type: 'string', + default: '', + description: 'The group ID of the deal', }, - }, - description: 'The owner ID of the deal', - }, - { - displayName: 'Deal percentage', - name: 'dealPercentage', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + { + displayName: 'Deal stage ID', + name: 'dealStage', + type: 'string', + default: '', + description: 'The stage ID of the deal', }, - }, - description: 'The percentage of the deal', - }, - { - displayName: 'Deal status', - name: 'dealStatus', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + { + displayName: 'Deal owner ID', + name: 'dealOwner', + type: 'string', + default: '', + description: 'The owner ID of the deal', }, - }, - description: 'The status of the deal', + { + displayName: 'Deal percentage', + name: 'dealPercentage', + type: 'number', + default: 0, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'dealStatus', + type: 'number', + default: 0, + description: 'The status of the deal', + }, + ] }, // ---------------------------------- @@ -715,7 +674,7 @@ export class ActiveCampaign implements INodeType { displayOptions: { show: { operation: [ - 'update', + 'create', ], resource: [ 'deal', @@ -724,32 +683,16 @@ export class ActiveCampaign implements INodeType { }, description: 'The title of the deal', }, - { - displayName: 'Description', - name: 'dealDescription', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The description of the deal', - }, { displayName: 'Deal\'s contact ID', name: 'dealContactId', type: 'number', default: 0, + required: true, displayOptions: { show: { operation: [ - 'update', + 'create', ], resource: [ 'deal', @@ -763,10 +706,11 @@ export class ActiveCampaign implements INodeType { name: 'dealValue', type: 'number', default: 0, + required: true, displayOptions: { show: { operation: [ - 'update', + 'create', ], resource: [ 'deal', @@ -780,10 +724,11 @@ export class ActiveCampaign implements INodeType { name: 'dealCurrency', type: 'string', default: '', + required: true, displayOptions: { show: { operation: [ - 'update', + 'create', ], resource: [ 'deal', @@ -793,89 +738,65 @@ export class ActiveCampaign implements INodeType { description: 'The currency of the deal in 3-character ISO format', }, { - displayName: 'Deal group ID', - name: 'dealGroup', - type: 'string', - default: '', + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', displayOptions: { show: { operation: [ - 'update', + 'create', ], resource: [ 'deal', ], }, }, - description: 'The group ID of the deal', - }, - { - displayName: 'Deal stage ID', - name: 'dealStage', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + default: {}, + options: [ + { + displayName: 'Description', + name: 'dealDescription', + type: 'string', + default: '', + description: 'The description of the deal', }, - }, - description: 'The stage ID of the deal', - }, - { - displayName: 'Deal owner ID', - name: 'dealOwner', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + { + displayName: 'Deal group ID', + name: 'dealGroup', + type: 'string', + default: '', + description: 'The group ID of the deal', }, - }, - description: 'The owner ID of the deal', - }, - { - displayName: 'Deal percentage', - name: 'dealPercentage', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + { + displayName: 'Deal stage ID', + name: 'dealStage', + type: 'string', + default: '', + description: 'The stage ID of the deal', }, - }, - description: 'The percentage of the deal', - }, - { - displayName: 'Deal status', - name: 'dealStatus', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + { + displayName: 'Deal owner ID', + name: 'dealOwner', + type: 'string', + default: '', + description: 'The owner ID of the deal', }, - }, - description: 'The status of the deal', + { + displayName: 'Deal percentage', + name: 'dealPercentage', + type: 'number', + default: 0, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'dealStatus', + type: 'number', + default: 0, + description: 'The status of the deal', + }, + ] }, @@ -1159,46 +1080,18 @@ export class ActiveCampaign implements INodeType { requestMethod = 'POST'; dataKey = 'deal'; - + body.deal = { title: this.getNodeParameter('dealTitle', i) as string, contact: this.getNodeParameter('dealContactId', i) as string, value: this.getNodeParameter('dealValue', i) as number, - currency: '', } as IDataObject; - let currency= this.getNodeParameter('dealCurrency', i) as string - if (currency.length === 3) { - currency = currency.toLowerCase(); - addAdditionalField(body.deal as IDataObject, currency) - } else { - throw new Error('Currency must be in 3-character ISO format') - } + let currency = this.getNodeParameter('dealCurrency', i).toString().toLowerCase() as string + addAdditionalField(body.deal as IDataObject, currency) - let description = this.getNodeParameter('dealDescription', i) as string; - if (description.length !== 0){ - addAdditionalField(body.deal as IDataObject, description) - } - - let group = this.getNodeParameter('dealGroup', i) as string; - if (group.length !== 0){ - addAdditionalField(body.deal as IDataObject, group) - } - - let stage = this.getNodeParameter('dealStage', i) as string; - if (stage.length !== 0){ - addAdditionalField(body.deal as IDataObject, stage) - } - - let percentage = this.getNodeParameter('dealPercentage', i) as number; - if (percentage !== 0){ - addAdditionalField(body.deal as IDataObject, percentage) - } - - let status = this.getNodeParameter('dealStatus', i) as number; - if (status !== 0){ - addAdditionalField(body.deal as IDataObject, status) - } + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + addAdditionalFields(body.deal as IDataObject, additionalFields); } else if (operation === 'delete') { From 4f1a0961392cd652a64080e2bb5f1c55cd038c51 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 16:25:16 +0200 Subject: [PATCH 11/52] refactor deal update to take add field format --- .../ActiveCampaign/ActiveCampaign.node.ts | 147 +++++++----------- 1 file changed, 52 insertions(+), 95 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 0af2409e164..d7f0fec8af8 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -651,8 +651,6 @@ export class ActiveCampaign implements INodeType { displayName: 'Deal ID', name: 'dealId', type: 'number', - default: 0, - required: true, displayOptions: { show: { operation: [ @@ -663,97 +661,56 @@ export class ActiveCampaign implements INodeType { ], }, }, - description: 'The ID of the deal', - }, - { - displayName: 'Title', - name: 'dealTitle', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The title of the deal', - }, - { - displayName: 'Deal\'s contact ID', - name: 'dealContactId', - type: 'number', default: 0, required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal\'s contact', + description: 'ID of the deal to update.', }, { - displayName: 'Deal value', - name: 'dealValue', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The value of the deal in cents', - }, - { - displayName: 'Currency', - name: 'dealCurrency', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The currency of the deal in 3-character ISO format', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', + displayName: 'Update Fields', + name: 'updateFields', type: 'collection', + description: 'The fields to update.', placeholder: 'Add Field', displayOptions: { show: { operation: [ - 'create', + 'update', ], resource: [ - 'deal', + 'contact', ], }, }, default: {}, options: [ + { + displayName: 'Title', + name: 'dealTitle', + type: 'string', + default: '', + description: 'The title of the deal', + }, + { + displayName: 'Deal\'s contact ID', + name: 'dealContactId', + type: 'number', + default: 0, + description: 'The ID of the deal\'s contact', + }, + { + displayName: 'Deal value', + name: 'dealValue', + type: 'number', + default: 0, + description: 'The value of the deal in cents', + }, + { + displayName: 'Currency', + name: 'dealCurrency', + type: 'string', + default: '', + description: 'The currency of the deal in 3-character ISO format', + }, { displayName: 'Description', name: 'dealDescription', @@ -798,8 +755,7 @@ export class ActiveCampaign implements INodeType { }, ] }, - - + // ---------------------------------- // deal:delete // ---------------------------------- @@ -1079,6 +1035,8 @@ export class ActiveCampaign implements INodeType { requestMethod = 'POST'; + endpoint = '/api/3/deals'; + dataKey = 'deal'; body.deal = { @@ -1094,6 +1052,21 @@ export class ActiveCampaign implements INodeType { addAdditionalFields(body.deal as IDataObject, additionalFields); + } else if (operation === 'update') { + // ---------------------------------- + // deal:update + // ---------------------------------- + + requestMethod = 'PUT'; + + const dealId = this.getNodeParameter('dealId', i) as number; + endpoint = `/api/3/deals/${dealId}`; + + dataKey = 'deal'; + body.deal = {} as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + addAdditionalFields(body.deal as IDataObject, updateFields); + } else if (operation === 'delete') { // ---------------------------------- // deal:delete @@ -1128,22 +1101,6 @@ export class ActiveCampaign implements INodeType { dataKey = 'deals'; endpoint = `/api/3/deals`; - - } else if (operation === 'update') { - // ---------------------------------- - // deal:update - // ---------------------------------- - - requestMethod = 'PUT'; - - const dealId = this.getNodeParameter('dealId', i) as number; - endpoint = `/api/3/deals/${dealId}`; - - dataKey = 'deal'; - body.deal = {} as IDataObject; - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - addAdditionalFields(body.deal as IDataObject, updateFields); - } else { throw new Error(`The resource "${resource}" is not known!`); } From 819efc50e5da01c9e545ff35a3f0a74a5ff893a5 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 16:30:58 +0200 Subject: [PATCH 12/52] add error handling for unknon operations --- .../ActiveCampaign/ActiveCampaign.node.ts | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index d7f0fec8af8..37385bbe674 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -755,7 +755,7 @@ export class ActiveCampaign implements INodeType { }, ] }, - + // ---------------------------------- // deal:delete // ---------------------------------- @@ -1026,6 +1026,8 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.contact as IDataObject, updateFields); + } else { + throw new Error(`The operation ${operation} is not known`); } } else if (resource === 'deal') { if (operation === 'create') { @@ -1102,23 +1104,26 @@ export class ActiveCampaign implements INodeType { dataKey = 'deals'; endpoint = `/api/3/deals`; } else { - throw new Error(`The resource "${resource}" is not known!`); - } - - let responseData; - if (returnAll === true) { - responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey); - } else { - responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey); - } - - if (Array.isArray(responseData)) { - returnData.push.apply(returnData, responseData as IDataObject[]); - } else { - returnData.push(responseData as IDataObject); + throw new Error(`The operation ${operation} is not known`); } + } else { + throw new Error(`The resource "${resource}" is not known!`); } - return [this.helpers.returnJsonArray(returnData)]; + let responseData; + if (returnAll === true) { + responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey); + } else { + responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey); + } + + if (Array.isArray(responseData)) { + returnData.push.apply(returnData, responseData as IDataObject[]); + } else { + returnData.push(responseData as IDataObject); + } } + + return [this.helpers.returnJsonArray(returnData)]; } +} From 66a335054fa896fc45eceeab1877073f7a92172f Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 16:48:53 +0200 Subject: [PATCH 13/52] add dealnote functionality --- .../ActiveCampaign/ActiveCampaign.node.ts | 56 +++++++++++++++++-- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 37385bbe674..fee58816854 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1,5 +1,5 @@ import { - IExecuteFunctions, + IExecuteFunctions, getExecuteSingleFunctions, } from 'n8n-core'; import { IDataObject, @@ -906,6 +906,24 @@ export class ActiveCampaign implements INodeType { }, description: 'The ID of the deal note', }, + { + displayName: 'Deal note ID', + name: 'dealNoteId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, { displayName: 'Deal Note', name: 'dealNote', @@ -998,7 +1016,7 @@ export class ActiveCampaign implements INodeType { } else if (operation === 'getAll') { // ---------------------------------- - // persons:getAll + // contacts:getAll // ---------------------------------- requestMethod = 'GET'; @@ -1027,7 +1045,7 @@ export class ActiveCampaign implements INodeType { addAdditionalFields(body.contact as IDataObject, updateFields); } else { - throw new Error(`The operation ${operation} is not known`); + throw new Error(`The operation "${operation}" is not known`); } } else if (resource === 'deal') { if (operation === 'create') { @@ -1091,7 +1109,7 @@ export class ActiveCampaign implements INodeType { } else if (operation === 'getAll') { // ---------------------------------- - // persons:getAll + // deals:getAll // ---------------------------------- requestMethod = 'GET'; @@ -1103,8 +1121,36 @@ export class ActiveCampaign implements INodeType { dataKey = 'deals'; endpoint = `/api/3/deals`; + + } else if (operation === 'createNote') { + // ---------------------------------- + // deal:createNote + // ---------------------------------- + requestMethod = 'POST' + + body.note = { + note: this.getNodeParameter('createNote', i) as string, + } + + const dealId = this.getNodeParameter('dealId', i) as number; + endpoint = `/api/3/deals/${dealId}/notes`; + + } else if (operation === 'updateNote') { + // ---------------------------------- + // deal:updateNote + // ---------------------------------- + requestMethod = 'POST' + + body.note = { + note: this.getNodeParameter('updateNote', i) as string, + } + + const dealId = this.getNodeParameter('dealId', i) as number; + const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; + endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`; + } else { - throw new Error(`The operation ${operation} is not known`); + throw new Error(`The operation "${operation}" is not known`); } } else { throw new Error(`The resource "${resource}" is not known!`); From a09d6dfbf665817b189ae34c55856efd494abd0b Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 16:56:15 +0200 Subject: [PATCH 14/52] exclude unnecessary import --- packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index fee58816854..c9490a25056 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1,5 +1,5 @@ import { - IExecuteFunctions, getExecuteSingleFunctions, + IExecuteFunctions, } from 'n8n-core'; import { IDataObject, From 12a0592896cfc6156644293d60894c1906cc2df6 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 16:57:26 +0200 Subject: [PATCH 15/52] exclude unnecessary import --- packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index c9490a25056..b4e0913c8aa 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -12,7 +12,6 @@ import { activeCampaignApiRequest, activeCampaignApiRequestAllItems, } from './GenericFunctions'; -import { type } from 'os'; interface CustomProperty { name: string; From 78997ddeac4304f89ee067a66b508ba912251482 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 17:48:46 +0200 Subject: [PATCH 16/52] rename fields to how they appear in APi to prevent bug --- .../ActiveCampaign/ActiveCampaign.node.ts | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index b4e0913c8aa..3de65413e7e 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -37,17 +37,6 @@ function addAdditionalFields(body: IDataObject, additionalFields: IDataObject) { } } -/** - * Add one additional field to the body - * - * @param {IDataObject} body The body object to add the field to - * @param {IDataObject} additionalField The field to add - */ -function addAdditionalField(body: IDataObject, additionalField: string | number) { - body.additionalField = additionalField; -} - - export class ActiveCampaign implements INodeType { description: INodeTypeDescription = { displayName: 'ActiveCampaign', @@ -511,7 +500,7 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- { displayName: 'Title', - name: 'dealTitle', + name: 'title', type: 'string', default: '', required: true, @@ -529,7 +518,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal\'s contact ID', - name: 'dealContactId', + name: 'contact', type: 'number', default: 0, required: true, @@ -547,7 +536,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal value', - name: 'dealValue', + name: 'value', type: 'number', default: 0, required: true, @@ -565,7 +554,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Currency', - name: 'dealCurrency', + name: 'currency', type: 'string', default: '', required: true, @@ -600,42 +589,42 @@ export class ActiveCampaign implements INodeType { options: [ { displayName: 'Description', - name: 'dealDescription', + name: 'description', type: 'string', default: '', description: 'The description of the deal', }, { displayName: 'Deal group ID', - name: 'dealGroup', + name: 'group', type: 'string', default: '', description: 'The group ID of the deal', }, { displayName: 'Deal stage ID', - name: 'dealStage', + name: 'stage', type: 'string', default: '', description: 'The stage ID of the deal', }, { displayName: 'Deal owner ID', - name: 'dealOwner', + name: 'owner', type: 'string', default: '', description: 'The owner ID of the deal', }, { displayName: 'Deal percentage', - name: 'dealPercentage', + name: 'percent', type: 'number', default: 0, description: 'The percentage of the deal', }, { displayName: 'Deal status', - name: 'dealStatus', + name: 'status', type: 'number', default: 0, description: 'The status of the deal', @@ -676,7 +665,7 @@ export class ActiveCampaign implements INodeType { 'update', ], resource: [ - 'contact', + 'deal', ], }, }, @@ -684,70 +673,70 @@ export class ActiveCampaign implements INodeType { options: [ { displayName: 'Title', - name: 'dealTitle', + name: 'title', type: 'string', default: '', description: 'The title of the deal', }, { displayName: 'Deal\'s contact ID', - name: 'dealContactId', + name: 'contact', type: 'number', default: 0, description: 'The ID of the deal\'s contact', }, { displayName: 'Deal value', - name: 'dealValue', + name: 'value', type: 'number', default: 0, description: 'The value of the deal in cents', }, { displayName: 'Currency', - name: 'dealCurrency', + name: 'currency', type: 'string', default: '', description: 'The currency of the deal in 3-character ISO format', }, { displayName: 'Description', - name: 'dealDescription', + name: 'description', type: 'string', default: '', description: 'The description of the deal', }, { displayName: 'Deal group ID', - name: 'dealGroup', + name: 'group', type: 'string', default: '', description: 'The group ID of the deal', }, { displayName: 'Deal stage ID', - name: 'dealStage', + name: 'stage', type: 'string', default: '', description: 'The stage ID of the deal', }, { displayName: 'Deal owner ID', - name: 'dealOwner', + name: 'owner', type: 'string', default: '', description: 'The owner ID of the deal', }, { displayName: 'Deal percentage', - name: 'dealPercentage', + name: 'percent', type: 'number', default: 0, description: 'The percentage of the deal', }, { displayName: 'Deal status', - name: 'dealStatus', + name: 'status', type: 'number', default: 0, description: 'The status of the deal', @@ -1059,13 +1048,13 @@ export class ActiveCampaign implements INodeType { dataKey = 'deal'; body.deal = { - title: this.getNodeParameter('dealTitle', i) as string, - contact: this.getNodeParameter('dealContactId', i) as string, - value: this.getNodeParameter('dealValue', i) as number, + title: this.getNodeParameter('title', i) as string, + contact: this.getNodeParameter('contact', i) as string, + value: this.getNodeParameter('value', i) as number, } as IDataObject; - let currency = this.getNodeParameter('dealCurrency', i).toString().toLowerCase() as string - addAdditionalField(body.deal as IDataObject, currency) + let currency = this.getNodeParameter('currency', i).toString().toLowerCase() as string + addAdditionalFields(body.deal as IDataObject, { currency }) const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.deal as IDataObject, additionalFields); @@ -1154,7 +1143,11 @@ export class ActiveCampaign implements INodeType { } else { throw new Error(`The resource "${resource}" is not known!`); } - + console.log(requestMethod) + console.log(endpoint) + console.log(body) + console.log(qs) + console.log(dataKey) let responseData; if (returnAll === true) { responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey); From 5b335c1578829155558b3e806cab8cbe14b2c6e2 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 18:18:33 +0200 Subject: [PATCH 17/52] fix dealNote bug --- .../nodes/ActiveCampaign/ActiveCampaign.node.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 3de65413e7e..d3ea171dfa3 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1115,10 +1115,12 @@ export class ActiveCampaign implements INodeType { // deal:createNote // ---------------------------------- requestMethod = 'POST' + console.log(operation) + console.log(this.getNodeParameter('dealNote', i) as string) body.note = { - note: this.getNodeParameter('createNote', i) as string, - } + note: this.getNodeParameter('dealNote', i) as string, + } as IDataObject const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/api/3/deals/${dealId}/notes`; @@ -1130,8 +1132,8 @@ export class ActiveCampaign implements INodeType { requestMethod = 'POST' body.note = { - note: this.getNodeParameter('updateNote', i) as string, - } + note: this.getNodeParameter('dealNote', i) as string, + } as IDataObject const dealId = this.getNodeParameter('dealId', i) as number; const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; From ccfcd6fc688a782fa60564825fb4fad63494c9f3 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 18:23:34 +0200 Subject: [PATCH 18/52] fix deal noe update --- packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index d3ea171dfa3..ec52246f1e5 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1129,7 +1129,7 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- // deal:updateNote // ---------------------------------- - requestMethod = 'POST' + requestMethod = 'PUT' body.note = { note: this.getNodeParameter('dealNote', i) as string, From 9072f9212eaac2d9e2439d6b7f41aa7cc5674a73 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 18:26:43 +0200 Subject: [PATCH 19/52] remove console.logs --- .../nodes/ActiveCampaign/ActiveCampaign.node.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index ec52246f1e5..b6d3ebd195b 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1115,8 +1115,6 @@ export class ActiveCampaign implements INodeType { // deal:createNote // ---------------------------------- requestMethod = 'POST' - console.log(operation) - console.log(this.getNodeParameter('dealNote', i) as string) body.note = { note: this.getNodeParameter('dealNote', i) as string, @@ -1145,11 +1143,7 @@ export class ActiveCampaign implements INodeType { } else { throw new Error(`The resource "${resource}" is not known!`); } - console.log(requestMethod) - console.log(endpoint) - console.log(body) - console.log(qs) - console.log(dataKey) + let responseData; if (returnAll === true) { responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey); From 5dcb2a74f2748e881c763717b877e611aa06e3a9 Mon Sep 17 00:00:00 2001 From: quansenB Date: Fri, 25 Oct 2019 18:29:23 +0200 Subject: [PATCH 20/52] add .env to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 91e093160a1..0466b836952 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ package-lock.json yarn.lock google-generated-credentials.json _START_PACKAGE +.env From 6166e3955b512d8bcd1451b3056ad55b53345851 Mon Sep 17 00:00:00 2001 From: quansenB Date: Tue, 29 Oct 2019 00:14:04 +0100 Subject: [PATCH 21/52] add -vscode to gitignore --- .gitignore | 1 + package.json | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0466b836952..1b2f93c3f33 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ yarn.lock google-generated-credentials.json _START_PACKAGE .env +.vscode diff --git a/package.json b/package.json index b045830f51d..b9d1ec33d2b 100644 --- a/package.json +++ b/package.json @@ -16,5 +16,9 @@ "lerna": "^3.13.1", "run-script-os": "^1.0.7" }, - "postcss": {} + "postcss": {}, + "dependencies": { + "n8n-node-dev": "^0.5.0", + "typescript": "^3.6.4" + } } From fbe78e4cb61803ee5d170c4ed14338700a14ed70 Mon Sep 17 00:00:00 2001 From: quansenB Date: Tue, 29 Oct 2019 00:15:28 +0100 Subject: [PATCH 22/52] revert package.json chanes in editor ui --- packages/editor-ui/package json debug | 1 - packages/editor-ui/package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 packages/editor-ui/package json debug diff --git a/packages/editor-ui/package json debug b/packages/editor-ui/package json debug deleted file mode 100644 index dbfd27f67f5..00000000000 --- a/packages/editor-ui/package json debug +++ /dev/null @@ -1 +0,0 @@ -//VUE_APP_URL_BASE_API=http://localhost:5678/ \ No newline at end of file diff --git a/packages/editor-ui/package.json b/packages/editor-ui/package.json index 82534d8a878..4dd2fe0014a 100644 --- a/packages/editor-ui/package.json +++ b/packages/editor-ui/package.json @@ -17,7 +17,7 @@ "build": "vue-cli-service build", "dev": "npm run serve", "lint": "vue-cli-service lint", - "serve": "vue-cli-service serve", + "serve": "VUE_APP_URL_BASE_API=http://localhost:5678/ vue-cli-service serve", "test": "npm run test:unit", "tslint": "tslint -p tsconfig.json -c tslint.json", "test:e2e": "vue-cli-service test:e2e", From a8b3f383ef687e8728a384546efdd7f6c3868022 Mon Sep 17 00:00:00 2001 From: quansenB Date: Tue, 29 Oct 2019 00:19:02 +0100 Subject: [PATCH 23/52] revert unneeded changes for PR --- package.json | 6 +----- packages/editor-ui/package.json | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index b9d1ec33d2b..b045830f51d 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,5 @@ "lerna": "^3.13.1", "run-script-os": "^1.0.7" }, - "postcss": {}, - "dependencies": { - "n8n-node-dev": "^0.5.0", - "typescript": "^3.6.4" - } + "postcss": {} } diff --git a/packages/editor-ui/package.json b/packages/editor-ui/package.json index 4dd2fe0014a..7047295fba9 100644 --- a/packages/editor-ui/package.json +++ b/packages/editor-ui/package.json @@ -78,4 +78,4 @@ "vue-typed-mixins": "^0.1.0", "vuex": "^3.1.1" } -} \ No newline at end of file +} From 3d42a0f0e6bbb13462650c51103c3682beccfba2 Mon Sep 17 00:00:00 2001 From: quansenB Date: Tue, 29 Oct 2019 19:51:09 +0100 Subject: [PATCH 24/52] add currency dropdown --- .../ActiveCampaign/ActiveCampaign.node.ts | 12 +- .../nodes/ActiveCampaign/currencies.ts | 175 ++++++++++++++++++ 2 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 packages/nodes-base/nodes/ActiveCampaign/currencies.ts diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index b6d3ebd195b..2cd6c27f9de 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1,11 +1,13 @@ import { IExecuteFunctions, } from 'n8n-core'; + import { IDataObject, INodeTypeDescription, INodeExecutionData, INodeType, + INodePropertyOptions, } from 'n8n-workflow'; import { @@ -13,6 +15,8 @@ import { activeCampaignApiRequestAllItems, } from './GenericFunctions'; +import { returnAllCurrencyOptions } from './currencies' + interface CustomProperty { name: string; value: string; @@ -555,8 +559,8 @@ export class ActiveCampaign implements INodeType { { displayName: 'Currency', name: 'currency', - type: 'string', - default: '', + type: 'options', + default: 'eur', required: true, displayOptions: { show: { @@ -568,6 +572,7 @@ export class ActiveCampaign implements INodeType { ], }, }, + options: returnAllCurrencyOptions(), description: 'The currency of the deal in 3-character ISO format', }, { @@ -695,7 +700,8 @@ export class ActiveCampaign implements INodeType { { displayName: 'Currency', name: 'currency', - type: 'string', + type: 'options', + options: returnAllCurrencyOptions(), default: '', description: 'The currency of the deal in 3-character ISO format', }, diff --git a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts new file mode 100644 index 00000000000..007f95fa93e --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts @@ -0,0 +1,175 @@ +export function returnAllCurrencyOptions() { + return [ + { name: 'United States Dollar', value: 'usd' }, + { name: 'Euro', value: 'eur' }, + { name: 'Renminbi', value: 'cny' }, + { name: '--------', value: '' }, + { name: 'United Arab Emirates Dirham', value: 'aed' }, + { name: 'Afghan Afghani', value: 'afn' }, + { name: 'Albanian Lek', value: 'all' }, + { name: 'Armenian Dram', value: 'amd' }, + { name: 'Netherlands Antillean Guilder', value: 'ang' }, + { name: 'Angolan Kwanza', value: 'aoa' }, + { name: 'Argentine Peso', value: 'ars' }, + { name: 'Australian Dollar', value: 'aud' }, + { name: 'Aruban Florin', value: 'awg' }, + { name: 'Azerbaijani Manat', value: 'azn' }, + { name: 'Bosnia-Herzegovina Convertible Mark', value: 'bam' }, + { name: 'Barbadian Dollar', value: 'bbd' }, + { name: 'Bangladeshi Taka', value: 'bdt' }, + { name: 'Bulgarian Lev', value: 'bgn' }, + { name: 'Bahraini Dinar', value: 'bhd' }, + { name: 'Burundian Franc', value: 'bif' }, + { name: 'Bermudan Dollar', value: 'bmd' }, + { name: 'Brunei Dollar', value: 'bnd' }, + { name: 'Bolivian Boliviano', value: 'bob' }, + { name: 'Brazilian Real', value: 'brl' }, + { name: 'Bahamian Dollar', value: 'bsd' }, + { name: 'Bitcoin', value: 'btc' }, + { name: 'Bhutanese Ngultrum', value: 'btn' }, + { name: 'Botswanan Pula', value: 'bwp' }, + { name: 'Belarusian Ruble', value: 'byn' }, + { name: 'Belize Dollar', value: 'bzd' }, + { name: 'Canadian Dollar', value: 'cad' }, + { name: 'Congolese Franc', value: 'cdf' }, + { name: 'Swiss Franc', value: 'chf' }, + { name: 'Chilean Unit of Account (UF)', value: 'clf' }, + { name: 'Chilean Peso', value: 'clp' }, + { name: 'Chinese Yuan (Offshore)', value: 'cnh' }, + { name: 'Colombian Peso', value: 'cop' }, + { name: 'Costa Rican Colón', value: 'crc' }, + { name: 'Cuban Convertible Peso', value: 'cuc' }, + { name: 'Cuban Peso', value: 'cup' }, + { name: 'Cape Verdean Escudo', value: 'cve' }, + { name: 'Czech Republic Koruna', value: 'czk' }, + { name: 'Djiboutian Franc', value: 'djf' }, + { name: 'Danish Krone', value: 'dkk' }, + { name: 'Dominican Peso', value: 'dop' }, + { name: 'Algerian Dinar', value: 'dzd' }, + { name: 'Egyptian Pound', value: 'egp' }, + { name: 'Eritrean Nakfa', value: 'ern' }, + { name: 'Ethiopian Birr', value: 'etb' }, + { name: 'Fijian Dollar', value: 'fjd' }, + { name: 'Falkland Islands Pound', value: 'fkp' }, + { name: 'British Pound Sterling', value: 'gbp' }, + { name: 'Georgian Lari', value: 'gel' }, + { name: 'Guernsey Pound', value: 'ggp' }, + { name: 'Ghanaian Cedi', value: 'ghs' }, + { name: 'Gibraltar Pound', value: 'gip' }, + { name: 'Gambian Dalasi', value: 'gmd' }, + { name: 'Guinean Franc', value: 'gnf' }, + { name: 'Guatemalan Quetzal', value: 'gtq' }, + { name: 'Guyanaese Dollar', value: 'gyd' }, + { name: 'Hong Kong Dollar', value: 'hkd' }, + { name: 'Honduran Lempira', value: 'hnl' }, + { name: 'Croatian Kuna', value: 'hrk' }, + { name: 'Haitian Gourde', value: 'htg' }, + { name: 'Hungarian Forint', value: 'huf' }, + { name: 'Indonesian Rupiah', value: 'idr' }, + { name: 'Israeli New Sheqel', value: 'ils' }, + { name: 'Manx pound', value: 'imp' }, + { name: 'Indian Rupee', value: 'inr' }, + { name: 'Iraqi Dinar', value: 'iqd' }, + { name: 'Iranian Rial', value: 'irr' }, + { name: 'Icelandic Króna', value: 'isk' }, + { name: 'Jersey Pound', value: 'jep' }, + { name: 'Jamaican Dollar', value: 'jmd' }, + { name: 'Jordanian Dinar', value: 'jod' }, + { name: 'Japanese Yen', value: 'jpy' }, + { name: 'Kenyan Shilling', value: 'kes' }, + { name: 'Kyrgystani Som', value: 'kgs' }, + { name: 'Cambodian Riel', value: 'khr' }, + { name: 'Comorian Franc', value: 'kmf' }, + { name: 'North Korean Won', value: 'kpw' }, + { name: 'South Korean Won', value: 'krw' }, + { name: 'Kuwaiti Dinar', value: 'kwd' }, + { name: 'Cayman Islands Dollar', value: 'kyd' }, + { name: 'Kazakhstani Tenge', value: 'kzt' }, + { name: 'Laotian Kip', value: 'lak' }, + { name: 'Lebanese Pound', value: 'lbp' }, + { name: 'Sri Lankan Rupee', value: 'lkr' }, + { name: 'Liberian Dollar', value: 'lrd' }, + { name: 'Lesotho Loti', value: 'lsl' }, + { name: 'Libyan Dinar', value: 'lyd' }, + { name: 'Moroccan Dirham', value: 'mad' }, + { name: 'Moldovan Leu', value: 'mdl' }, + { name: 'Malagasy Ariary', value: 'mga' }, + { name: 'Macedonian Denar', value: 'mkd' }, + { name: 'Myanma Kyat', value: 'mmk' }, + { name: 'Mongolian Tugrik', value: 'mnt' }, + { name: 'Macanese Pataca', value: 'mop' }, + { name: 'Mauritanian Ouguiya (pre-2018)', value: 'mro' }, + { name: 'Mauritanian Ouguiya', value: 'mru' }, + { name: 'Mauritian Rupee', value: 'mur' }, + { name: 'Maldivian Rufiyaa', value: 'mvr' }, + { name: 'Malawian Kwacha', value: 'mwk' }, + { name: 'Mexican Peso', value: 'mxn' }, + { name: 'Malaysian Ringgit', value: 'myr' }, + { name: 'Mozambican Metical', value: 'mzn' }, + { name: 'Namibian Dollar', value: 'nad' }, + { name: 'Nigerian Naira', value: 'ngn' }, + { name: 'Nicaraguan Córdoba', value: 'nio' }, + { name: 'Norwegian Krone', value: 'nok' }, + { name: 'Nepalese Rupee', value: 'npr' }, + { name: 'New Zealand Dollar', value: 'nzd' }, + { name: 'Omani Rial', value: 'omr' }, + { name: 'Panamanian Balboa', value: 'pab' }, + { name: 'Peruvian Nuevo Sol', value: 'pen' }, + { name: 'Papua New Guinean Kina', value: 'pgk' }, + { name: 'Philippine Peso', value: 'php' }, + { name: 'Pakistani Rupee', value: 'pkr' }, + { name: 'Polish Zloty', value: 'pln' }, + { name: 'Paraguayan Guarani', value: 'pyg' }, + { name: 'Qatari Rial', value: 'qar' }, + { name: 'Romanian Leu', value: 'ron' }, + { name: 'Serbian Dinar', value: 'rsd' }, + { name: 'Russian Ruble', value: 'rub' }, + { name: 'Rwandan Franc', value: 'rwf' }, + { name: 'Saudi Riyal', value: 'sar' }, + { name: 'Solomon Islands Dollar', value: 'sbd' }, + { name: 'Seychellois Rupee', value: 'scr' }, + { name: 'Sudanese Pound', value: 'sdg' }, + { name: 'Swedish Krona', value: 'sek' }, + { name: 'Singapore Dollar', value: 'sgd' }, + { name: 'Saint Helena Pound', value: 'shp' }, + { name: 'Sierra Leonean Leone', value: 'sll' }, + { name: 'Somali Shilling', value: 'sos' }, + { name: 'Surinamese Dollar', value: 'srd' }, + { name: 'South Sudanese Pound', value: 'ssp' }, + { name: 'São Tomé and Príncipe Dobra (pre-2018)', value: 'std' }, + { name: 'São Tomé and Príncipe Dobra', value: 'stn' }, + { name: 'Salvadoran Colón', value: 'svc' }, + { name: 'Syrian Pound', value: 'syp' }, + { name: 'Swazi Lilangeni', value: 'szl' }, + { name: 'Thai Baht', value: 'thb' }, + { name: 'Tajikistani Somoni', value: 'tjs' }, + { name: 'Turkmenistani Manat', value: 'tmt' }, + { name: 'Tunisian Dinar', value: 'tnd' }, + { name: "Tongan Pa'anga", value: 'top' }, + { name: 'Turkish Lira', value: 'try' }, + { name: 'Trinidad and Tobago Dollar', value: 'ttd' }, + { name: 'New Taiwan Dollar', value: 'twd' }, + { name: 'Tanzanian Shilling', value: 'tzs' }, + { name: 'Ukrainian Hryvnia', value: 'uah' }, + { name: 'Ugandan Shilling', value: 'ugx' }, + { name: 'Uruguayan Peso', value: 'uyu' }, + { name: 'Uzbekistan Som', value: 'uzs' }, + { name: 'Venezuelan Bolívar Fuerte', value: 'vef' }, + { name: 'Vietnamese Dong', value: 'vnd' }, + { name: 'Vanuatu Vatu', value: 'vuv' }, + { name: 'Samoan Tala', value: 'wst' }, + { name: 'CFA Franc BEAC', value: 'xaf' }, + { name: 'Silver Ounce', value: 'xag' }, + { name: 'Gold Ounce', value: 'xau' }, + { name: 'East Caribbean Dollar', value: 'xcd' }, + { name: 'Special Drawing Rights', value: 'xdr' }, + { name: 'CFA Franc BCEAO', value: 'xof' }, + { name: 'Palladium Ounce', value: 'xpd' }, + { name: 'CFP Franc', value: 'xpf' }, + { name: 'Platinum Ounce', value: 'xpt' }, + { name: 'Yemeni Rial', value: 'yer' }, + { name: 'South African Rand', value: 'zar' }, + { name: 'Zambian Kwacha', value: 'zmw' }, + { name: 'Zimbabwean Dollar', value: 'zwl' } + ] +} \ No newline at end of file From 4cbbdda8c1a80a53e273fb04de8e41da01762afc Mon Sep 17 00:00:00 2001 From: quansenB Date: Tue, 29 Oct 2019 19:53:02 +0100 Subject: [PATCH 25/52] add eur as default at update deal --- packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 2cd6c27f9de..7aeb933cb27 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -702,7 +702,7 @@ export class ActiveCampaign implements INodeType { name: 'currency', type: 'options', options: returnAllCurrencyOptions(), - default: '', + default: 'eur', description: 'The currency of the deal in 3-character ISO format', }, { From 51a6b47985296d55e8d4eafaad56546ab9e7f8fa Mon Sep 17 00:00:00 2001 From: quansenB Date: Tue, 29 Oct 2019 20:08:23 +0100 Subject: [PATCH 26/52] display pipeline, owner and stage as default in create deal --- .../ActiveCampaign/ActiveCampaign.node.ts | 97 ++++++++++++++----- 1 file changed, 71 insertions(+), 26 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 7aeb933cb27..6835a752a05 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -575,6 +575,57 @@ export class ActiveCampaign implements INodeType { options: returnAllCurrencyOptions(), description: 'The currency of the deal in 3-character ISO format', }, + { + displayName: 'Deal pipeline ID', + name: 'pipeline', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The pipeline ID of the deal', + }, + { + displayName: 'Deal stage ID', + name: 'stage', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The stage ID of the deal', + }, + { + displayName: 'Deal owner ID', + name: 'owner', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The owner ID of the deal', + }, { displayName: 'Additional Fields', name: 'additionalFields', @@ -599,27 +650,7 @@ export class ActiveCampaign implements INodeType { default: '', description: 'The description of the deal', }, - { - displayName: 'Deal group ID', - name: 'group', - type: 'string', - default: '', - description: 'The group ID of the deal', - }, - { - displayName: 'Deal stage ID', - name: 'stage', - type: 'string', - default: '', - description: 'The stage ID of the deal', - }, - { - displayName: 'Deal owner ID', - name: 'owner', - type: 'string', - default: '', - description: 'The owner ID of the deal', - }, + { displayName: 'Deal percentage', name: 'percent', @@ -713,11 +744,11 @@ export class ActiveCampaign implements INodeType { description: 'The description of the deal', }, { - displayName: 'Deal group ID', - name: 'group', + displayName: 'Deal pipeline ID', + name: 'pipeline', type: 'string', default: '', - description: 'The group ID of the deal', + description: 'The pipeline ID of the deal', }, { displayName: 'Deal stage ID', @@ -1059,13 +1090,27 @@ export class ActiveCampaign implements INodeType { value: this.getNodeParameter('value', i) as number, } as IDataObject; - let currency = this.getNodeParameter('currency', i).toString().toLowerCase() as string + const group = this.getNodeParameter('pipeline', i) as string + if(group !== ''){ + addAdditionalFields(body.deal as IDataObject, { group }) + } + + const owner = this.getNodeParameter('owner', i) as string + if(owner !== ''){ + addAdditionalFields(body.deal as IDataObject, { owner }) + } + + const stage = this.getNodeParameter('stage', i) as string + if(stage !== ''){ + addAdditionalFields(body.deal as IDataObject, { stage }) + } + + const currency = this.getNodeParameter('currency', i) as string addAdditionalFields(body.deal as IDataObject, { currency }) const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.deal as IDataObject, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // deal:update From 2e56730fade0647d39dfe4b160dc4702e1c17f1f Mon Sep 17 00:00:00 2001 From: quansenB Date: Tue, 29 Oct 2019 23:45:20 +0100 Subject: [PATCH 27/52] delete left over deleteNote code and change defdault currencies --- .../ActiveCampaign/ActiveCampaign.node.ts | 18 +++++++++++------- .../nodes/ActiveCampaign/currencies.ts | 8 ++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 6835a752a05..787f6767c1f 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -577,7 +577,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal pipeline ID', - name: 'pipeline', + name: 'owner', type: 'string', default: '', displayOptions: { @@ -650,7 +650,7 @@ export class ActiveCampaign implements INodeType { default: '', description: 'The description of the deal', }, - + { displayName: 'Deal percentage', name: 'percent', @@ -745,7 +745,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal pipeline ID', - name: 'pipeline', + name: 'owner', type: 'string', default: '', description: 'The pipeline ID of the deal', @@ -966,6 +966,7 @@ export class ActiveCampaign implements INodeType { }, description: 'The content of the deal note', }, + ], }; @@ -1090,18 +1091,18 @@ export class ActiveCampaign implements INodeType { value: this.getNodeParameter('value', i) as number, } as IDataObject; - const group = this.getNodeParameter('pipeline', i) as string - if(group !== ''){ + const group = this.getNodeParameter('owner', i) as string + if (group !== '') { addAdditionalFields(body.deal as IDataObject, { group }) } const owner = this.getNodeParameter('owner', i) as string - if(owner !== ''){ + if (owner !== '') { addAdditionalFields(body.deal as IDataObject, { owner }) } const stage = this.getNodeParameter('stage', i) as string - if(stage !== ''){ + if (stage !== '') { addAdditionalFields(body.deal as IDataObject, { stage }) } @@ -1188,9 +1189,11 @@ export class ActiveCampaign implements INodeType { const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`; + } else { throw new Error(`The operation "${operation}" is not known`); } + } else { throw new Error(`The resource "${resource}" is not known!`); } @@ -1212,3 +1215,4 @@ export class ActiveCampaign implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } } + diff --git a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts index 007f95fa93e..8ff4d48adc1 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts @@ -1,7 +1,9 @@ export function returnAllCurrencyOptions() { - return [ - { name: 'United States Dollar', value: 'usd' }, + return [ { name: 'Euro', value: 'eur' }, + { name: 'United States Dollar', value: 'usd' }, + { name: 'British Pound Sterling', value: 'gbp' }, + { name: 'Swiss Franc', value: 'chf' }, { name: 'Renminbi', value: 'cny' }, { name: '--------', value: '' }, { name: 'United Arab Emirates Dirham', value: 'aed' }, @@ -32,7 +34,6 @@ export function returnAllCurrencyOptions() { { name: 'Belize Dollar', value: 'bzd' }, { name: 'Canadian Dollar', value: 'cad' }, { name: 'Congolese Franc', value: 'cdf' }, - { name: 'Swiss Franc', value: 'chf' }, { name: 'Chilean Unit of Account (UF)', value: 'clf' }, { name: 'Chilean Peso', value: 'clp' }, { name: 'Chinese Yuan (Offshore)', value: 'cnh' }, @@ -51,7 +52,6 @@ export function returnAllCurrencyOptions() { { name: 'Ethiopian Birr', value: 'etb' }, { name: 'Fijian Dollar', value: 'fjd' }, { name: 'Falkland Islands Pound', value: 'fkp' }, - { name: 'British Pound Sterling', value: 'gbp' }, { name: 'Georgian Lari', value: 'gel' }, { name: 'Guernsey Pound', value: 'ggp' }, { name: 'Ghanaian Cedi', value: 'ghs' }, From 46c737dcf259430bda5a9d820d0eb9df34737240 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sat, 2 Nov 2019 18:29:01 +0100 Subject: [PATCH 28/52] add all currencies --- .../nodes-base/nodes/utils/allCurrencies.ts | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 packages/nodes-base/nodes/utils/allCurrencies.ts diff --git a/packages/nodes-base/nodes/utils/allCurrencies.ts b/packages/nodes-base/nodes/utils/allCurrencies.ts new file mode 100644 index 00000000000..3fd41695d4a --- /dev/null +++ b/packages/nodes-base/nodes/utils/allCurrencies.ts @@ -0,0 +1,173 @@ +[ + { name: 'Euro', value: 'eur' }, + { name: 'United States Dollar', value: 'usd' }, + { name: 'British Pound Sterling', value: 'gbp' }, + { name: 'Swiss Franc', value: 'chf' }, + { name: 'Renminbi', value: 'cny' }, + { name: '--------', value: '' }, + { name: 'United Arab Emirates Dirham', value: 'aed' }, + { name: 'Afghan Afghani', value: 'afn' }, + { name: 'Albanian Lek', value: 'all' }, + { name: 'Armenian Dram', value: 'amd' }, + { name: 'Netherlands Antillean Guilder', value: 'ang' }, + { name: 'Angolan Kwanza', value: 'aoa' }, + { name: 'Argentine Peso', value: 'ars' }, + { name: 'Australian Dollar', value: 'aud' }, + { name: 'Aruban Florin', value: 'awg' }, + { name: 'Azerbaijani Manat', value: 'azn' }, + { name: 'Bosnia-Herzegovina Convertible Mark', value: 'bam' }, + { name: 'Barbadian Dollar', value: 'bbd' }, + { name: 'Bangladeshi Taka', value: 'bdt' }, + { name: 'Bulgarian Lev', value: 'bgn' }, + { name: 'Bahraini Dinar', value: 'bhd' }, + { name: 'Burundian Franc', value: 'bif' }, + { name: 'Bermudan Dollar', value: 'bmd' }, + { name: 'Brunei Dollar', value: 'bnd' }, + { name: 'Bolivian Boliviano', value: 'bob' }, + { name: 'Brazilian Real', value: 'brl' }, + { name: 'Bahamian Dollar', value: 'bsd' }, + { name: 'Bitcoin', value: 'btc' }, + { name: 'Bhutanese Ngultrum', value: 'btn' }, + { name: 'Botswanan Pula', value: 'bwp' }, + { name: 'Belarusian Ruble', value: 'byn' }, + { name: 'Belize Dollar', value: 'bzd' }, + { name: 'Canadian Dollar', value: 'cad' }, + { name: 'Congolese Franc', value: 'cdf' }, + { name: 'Chilean Unit of Account (UF)', value: 'clf' }, + { name: 'Chilean Peso', value: 'clp' }, + { name: 'Chinese Yuan (Offshore)', value: 'cnh' }, + { name: 'Colombian Peso', value: 'cop' }, + { name: 'Costa Rican Colón', value: 'crc' }, + { name: 'Cuban Convertible Peso', value: 'cuc' }, + { name: 'Cuban Peso', value: 'cup' }, + { name: 'Cape Verdean Escudo', value: 'cve' }, + { name: 'Czech Republic Koruna', value: 'czk' }, + { name: 'Djiboutian Franc', value: 'djf' }, + { name: 'Danish Krone', value: 'dkk' }, + { name: 'Dominican Peso', value: 'dop' }, + { name: 'Algerian Dinar', value: 'dzd' }, + { name: 'Egyptian Pound', value: 'egp' }, + { name: 'Eritrean Nakfa', value: 'ern' }, + { name: 'Ethiopian Birr', value: 'etb' }, + { name: 'Fijian Dollar', value: 'fjd' }, + { name: 'Falkland Islands Pound', value: 'fkp' }, + { name: 'Georgian Lari', value: 'gel' }, + { name: 'Guernsey Pound', value: 'ggp' }, + { name: 'Ghanaian Cedi', value: 'ghs' }, + { name: 'Gibraltar Pound', value: 'gip' }, + { name: 'Gambian Dalasi', value: 'gmd' }, + { name: 'Guinean Franc', value: 'gnf' }, + { name: 'Guatemalan Quetzal', value: 'gtq' }, + { name: 'Guyanaese Dollar', value: 'gyd' }, + { name: 'Hong Kong Dollar', value: 'hkd' }, + { name: 'Honduran Lempira', value: 'hnl' }, + { name: 'Croatian Kuna', value: 'hrk' }, + { name: 'Haitian Gourde', value: 'htg' }, + { name: 'Hungarian Forint', value: 'huf' }, + { name: 'Indonesian Rupiah', value: 'idr' }, + { name: 'Israeli New Sheqel', value: 'ils' }, + { name: 'Manx pound', value: 'imp' }, + { name: 'Indian Rupee', value: 'inr' }, + { name: 'Iraqi Dinar', value: 'iqd' }, + { name: 'Iranian Rial', value: 'irr' }, + { name: 'Icelandic Króna', value: 'isk' }, + { name: 'Jersey Pound', value: 'jep' }, + { name: 'Jamaican Dollar', value: 'jmd' }, + { name: 'Jordanian Dinar', value: 'jod' }, + { name: 'Japanese Yen', value: 'jpy' }, + { name: 'Kenyan Shilling', value: 'kes' }, + { name: 'Kyrgystani Som', value: 'kgs' }, + { name: 'Cambodian Riel', value: 'khr' }, + { name: 'Comorian Franc', value: 'kmf' }, + { name: 'North Korean Won', value: 'kpw' }, + { name: 'South Korean Won', value: 'krw' }, + { name: 'Kuwaiti Dinar', value: 'kwd' }, + { name: 'Cayman Islands Dollar', value: 'kyd' }, + { name: 'Kazakhstani Tenge', value: 'kzt' }, + { name: 'Laotian Kip', value: 'lak' }, + { name: 'Lebanese Pound', value: 'lbp' }, + { name: 'Sri Lankan Rupee', value: 'lkr' }, + { name: 'Liberian Dollar', value: 'lrd' }, + { name: 'Lesotho Loti', value: 'lsl' }, + { name: 'Libyan Dinar', value: 'lyd' }, + { name: 'Moroccan Dirham', value: 'mad' }, + { name: 'Moldovan Leu', value: 'mdl' }, + { name: 'Malagasy Ariary', value: 'mga' }, + { name: 'Macedonian Denar', value: 'mkd' }, + { name: 'Myanma Kyat', value: 'mmk' }, + { name: 'Mongolian Tugrik', value: 'mnt' }, + { name: 'Macanese Pataca', value: 'mop' }, + { name: 'Mauritanian Ouguiya (pre-2018)', value: 'mro' }, + { name: 'Mauritanian Ouguiya', value: 'mru' }, + { name: 'Mauritian Rupee', value: 'mur' }, + { name: 'Maldivian Rufiyaa', value: 'mvr' }, + { name: 'Malawian Kwacha', value: 'mwk' }, + { name: 'Mexican Peso', value: 'mxn' }, + { name: 'Malaysian Ringgit', value: 'myr' }, + { name: 'Mozambican Metical', value: 'mzn' }, + { name: 'Namibian Dollar', value: 'nad' }, + { name: 'Nigerian Naira', value: 'ngn' }, + { name: 'Nicaraguan Córdoba', value: 'nio' }, + { name: 'Norwegian Krone', value: 'nok' }, + { name: 'Nepalese Rupee', value: 'npr' }, + { name: 'New Zealand Dollar', value: 'nzd' }, + { name: 'Omani Rial', value: 'omr' }, + { name: 'Panamanian Balboa', value: 'pab' }, + { name: 'Peruvian Nuevo Sol', value: 'pen' }, + { name: 'Papua New Guinean Kina', value: 'pgk' }, + { name: 'Philippine Peso', value: 'php' }, + { name: 'Pakistani Rupee', value: 'pkr' }, + { name: 'Polish Zloty', value: 'pln' }, + { name: 'Paraguayan Guarani', value: 'pyg' }, + { name: 'Qatari Rial', value: 'qar' }, + { name: 'Romanian Leu', value: 'ron' }, + { name: 'Serbian Dinar', value: 'rsd' }, + { name: 'Russian Ruble', value: 'rub' }, + { name: 'Rwandan Franc', value: 'rwf' }, + { name: 'Saudi Riyal', value: 'sar' }, + { name: 'Solomon Islands Dollar', value: 'sbd' }, + { name: 'Seychellois Rupee', value: 'scr' }, + { name: 'Sudanese Pound', value: 'sdg' }, + { name: 'Swedish Krona', value: 'sek' }, + { name: 'Singapore Dollar', value: 'sgd' }, + { name: 'Saint Helena Pound', value: 'shp' }, + { name: 'Sierra Leonean Leone', value: 'sll' }, + { name: 'Somali Shilling', value: 'sos' }, + { name: 'Surinamese Dollar', value: 'srd' }, + { name: 'South Sudanese Pound', value: 'ssp' }, + { name: 'São Tomé and Príncipe Dobra (pre-2018)', value: 'std' }, + { name: 'São Tomé and Príncipe Dobra', value: 'stn' }, + { name: 'Salvadoran Colón', value: 'svc' }, + { name: 'Syrian Pound', value: 'syp' }, + { name: 'Swazi Lilangeni', value: 'szl' }, + { name: 'Thai Baht', value: 'thb' }, + { name: 'Tajikistani Somoni', value: 'tjs' }, + { name: 'Turkmenistani Manat', value: 'tmt' }, + { name: 'Tunisian Dinar', value: 'tnd' }, + { name: "Tongan Pa'anga", value: 'top' }, + { name: 'Turkish Lira', value: 'try' }, + { name: 'Trinidad and Tobago Dollar', value: 'ttd' }, + { name: 'New Taiwan Dollar', value: 'twd' }, + { name: 'Tanzanian Shilling', value: 'tzs' }, + { name: 'Ukrainian Hryvnia', value: 'uah' }, + { name: 'Ugandan Shilling', value: 'ugx' }, + { name: 'Uruguayan Peso', value: 'uyu' }, + { name: 'Uzbekistan Som', value: 'uzs' }, + { name: 'Venezuelan Bolívar Fuerte', value: 'vef' }, + { name: 'Vietnamese Dong', value: 'vnd' }, + { name: 'Vanuatu Vatu', value: 'vuv' }, + { name: 'Samoan Tala', value: 'wst' }, + { name: 'CFA Franc BEAC', value: 'xaf' }, + { name: 'Silver Ounce', value: 'xag' }, + { name: 'Gold Ounce', value: 'xau' }, + { name: 'East Caribbean Dollar', value: 'xcd' }, + { name: 'Special Drawing Rights', value: 'xdr' }, + { name: 'CFA Franc BCEAO', value: 'xof' }, + { name: 'Palladium Ounce', value: 'xpd' }, + { name: 'CFP Franc', value: 'xpf' }, + { name: 'Platinum Ounce', value: 'xpt' }, + { name: 'Yemeni Rial', value: 'yer' }, + { name: 'South African Rand', value: 'zar' }, + { name: 'Zambian Kwacha', value: 'zmw' }, + { name: 'Zimbabwean Dollar', value: 'zwl' } +] \ No newline at end of file From 925586e54311df77e30673e82dc0ef76ba674784 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sat, 2 Nov 2019 19:48:29 +0100 Subject: [PATCH 29/52] add create ecommerce node description --- .../ActiveCampaign/ActiveCampaign.node.ts | 604 +++++++++++++++++- 1 file changed, 603 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 787f6767c1f..622d343d450 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -79,6 +79,10 @@ export class ActiveCampaign implements INodeType { { name: 'Deal', value: 'deal', + }, + { + name: "E-commerce order", + value: "ecommerceOrder" } ], default: 'contact', @@ -184,6 +188,48 @@ export class ActiveCampaign implements INodeType { description: 'The operation to perform.', }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'ecommerceOrder', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a order', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a order', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a order', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all orders', + }, + { + name: 'Update', + value: 'update', + description: 'Update a order', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, + // ---------------------------------- @@ -966,7 +1012,563 @@ export class ActiveCampaign implements INodeType { }, description: 'The content of the deal note', }, + + // ---------------------------------- + // ecommerceOrder + // ---------------------------------- + + // ---------------------------------- + // ecommerceOrder:create + // ---------------------------------- + { + displayName: 'External ID', + name: 'externalid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', + }, + { + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Order currency', + name: 'currency', + type: 'options', + default: 'eur', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + options: returnAllCurrencyOptions(), + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', + }, + { + displayName: 'Connection ID', + name: 'connectionid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the connection from which this order originated.', + }, + { + displayName: 'Customer ID', + name: 'customerid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the customer associated with this order.', + }, + { + displayName: 'Creation Date', + name: 'externalCreatedDate', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'externalCreatedDate', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + displayOptions: { + show: { + operation: [ + 'create' + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + typeOptions: { + alwaysOpenEditWindow: true, + }, + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + typeOptions: { + alwaysOpenEditWindow: true, + }, + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + typeOptions: { + alwaysOpenEditWindow: true, + }, + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + typeOptions: { + alwaysOpenEditWindow: true, + }, + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, + + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'string', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, + + ] + }, + // ---------------------------------- + // ecommerceOrder:update + // ---------------------------------- + { + displayName: 'ecommerceOrder ID', + name: 'ecommerceOrderId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the ecommerceOrder to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + description: 'The title of the ecommerceOrder', + }, + { + displayName: 'ecommerceOrder\'s contact ID', + name: 'contact', + type: 'number', + default: 0, + description: 'The ID of the ecommerceOrder\'s contact', + }, + { + displayName: 'ecommerceOrder value', + name: 'value', + type: 'number', + default: 0, + description: 'The value of the ecommerceOrder in cents', + }, + { + displayName: 'Currency', + name: 'currency', + type: 'options', + options: returnAllCurrencyOptions(), + default: 'eur', + description: 'The currency of the ecommerceOrder in 3-character ISO format', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the ecommerceOrder', + }, + { + displayName: 'ecommerceOrder pipeline ID', + name: 'owner', + type: 'string', + default: '', + description: 'The pipeline ID of the ecommerceOrder', + }, + { + displayName: 'ecommerceOrder stage ID', + name: 'stage', + type: 'string', + default: '', + description: 'The stage ID of the ecommerceOrder', + }, + { + displayName: 'ecommerceOrder owner ID', + name: 'owner', + type: 'string', + default: '', + description: 'The owner ID of the ecommerceOrder', + }, + { + displayName: 'ecommerceOrder percentage', + name: 'percent', + type: 'number', + default: 0, + description: 'The percentage of the ecommerceOrder', + }, + { + displayName: 'ecommerceOrder status', + name: 'status', + type: 'number', + default: 0, + description: 'The status of the ecommerceOrder', + }, + ] + }, + + // ---------------------------------- + // ecommerceOrder:delete + // ---------------------------------- + { + displayName: 'ecommerceOrder ID', + name: 'ecommerceOrderId', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The ID of the ecommerceOrder', + }, + + // ---------------------------------- + // ecommerceOrder:get + // ---------------------------------- + { + displayName: 'ecommerceOrder ID', + name: 'ecommerceOrderId', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The ID of the ecommerceOrder', + }, + + // ---------------------------------- + // ecommerceOrder:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, ], }; @@ -1193,7 +1795,7 @@ export class ActiveCampaign implements INodeType { } else { throw new Error(`The operation "${operation}" is not known`); } - + } else { throw new Error(`The resource "${resource}" is not known!`); } From a69426d6ba3aab2e0a10ef2c93ca10b40f0af4c3 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sat, 2 Nov 2019 21:49:45 +0100 Subject: [PATCH 30/52] add rest of ecommerce description --- .../ActiveCampaign/ActiveCampaign.node.ts | 272 +++++++++++++----- 1 file changed, 193 insertions(+), 79 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 622d343d450..ffb54356657 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1166,7 +1166,7 @@ export class ActiveCampaign implements INodeType { { displayName: 'Creation Date', name: 'externalCreatedDate', - type: 'string', + type: 'dateTime', default: '', required: true, displayOptions: { @@ -1183,8 +1183,8 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Abandoning Date', - name: 'externalCreatedDate', - type: 'string', + name: 'abandonedDate', + type: 'dateTime', default: '', displayOptions: { show: { @@ -1218,15 +1218,12 @@ export class ActiveCampaign implements INodeType { }, default: {}, description: 'All ordered products', - placeholder: 'Add product', + placeholder: 'Add product field', options: [ { displayName: 'Name', name: 'name', type: 'string', - typeOptions: { - alwaysOpenEditWindow: true, - }, default: '', description: 'The name of the product', }, @@ -1234,9 +1231,6 @@ export class ActiveCampaign implements INodeType { displayName: 'Price', name: 'price', type: 'number', - typeOptions: { - alwaysOpenEditWindow: true, - }, default: 0, description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', }, @@ -1244,9 +1238,6 @@ export class ActiveCampaign implements INodeType { displayName: 'Product Quantity', name: 'quantity', type: 'number', - typeOptions: { - alwaysOpenEditWindow: true, - }, default: 0, description: 'The quantity ordered.', }, @@ -1254,9 +1245,6 @@ export class ActiveCampaign implements INodeType { displayName: 'Product external ID', name: 'externalid', type: 'string', - typeOptions: { - alwaysOpenEditWindow: true, - }, default: '', description: 'The id of the product in the external service.', }, @@ -1346,7 +1334,7 @@ export class ActiveCampaign implements INodeType { { displayName: 'External updated date', name: 'externalUpdatedDate', - type: 'string', + type: 'dateTime', default: '', description: 'The date the order was updated.', }, @@ -1372,9 +1360,10 @@ export class ActiveCampaign implements INodeType { // ecommerceOrder:update // ---------------------------------- { - displayName: 'ecommerceOrder ID', - name: 'ecommerceOrderId', + displayName: 'Order ID', + name: 'orderId', type: 'number', + default: 0, displayOptions: { show: { operation: [ @@ -1385,15 +1374,13 @@ export class ActiveCampaign implements INodeType { ], }, }, - default: 0, - required: true, - description: 'ID of the ecommerceOrder to update.', + description: 'The id of the e-commerce order.', }, + { - displayName: 'Update Fields', - name: 'updateFields', + displayName: 'Add Field', + name: 'additionalFields', type: 'collection', - description: 'The fields to update.', placeholder: 'Add Field', displayOptions: { show: { @@ -1408,76 +1395,205 @@ export class ActiveCampaign implements INodeType { default: {}, options: [ { - displayName: 'Title', - name: 'title', + displayName: 'External ID', + name: 'externalid', type: 'string', default: '', - description: 'The title of the ecommerceOrder', + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', }, { - displayName: 'ecommerceOrder\'s contact ID', - name: 'contact', + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', type: 'number', default: 0, - description: 'The ID of the ecommerceOrder\'s contact', + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', }, { - displayName: 'ecommerceOrder value', - name: 'value', + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', type: 'number', default: 0, - description: 'The value of the ecommerceOrder in cents', + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', }, { - displayName: 'Currency', + displayName: 'Order currency', name: 'currency', type: 'options', - options: returnAllCurrencyOptions(), default: 'eur', - description: 'The currency of the ecommerceOrder in 3-character ISO format', + options: returnAllCurrencyOptions(), + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', }, { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the ecommerceOrder', - }, - { - displayName: 'ecommerceOrder pipeline ID', - name: 'owner', - type: 'string', - default: '', - description: 'The pipeline ID of the ecommerceOrder', - }, - { - displayName: 'ecommerceOrder stage ID', - name: 'stage', - type: 'string', - default: '', - description: 'The stage ID of the ecommerceOrder', - }, - { - displayName: 'ecommerceOrder owner ID', - name: 'owner', - type: 'string', - default: '', - description: 'The owner ID of the ecommerceOrder', - }, - { - displayName: 'ecommerceOrder percentage', - name: 'percent', + displayName: 'Connection ID', + name: 'connectionid', type: 'number', default: 0, - description: 'The percentage of the ecommerceOrder', + description: 'The id of the connection from which this order originated.', }, { - displayName: 'ecommerceOrder status', - name: 'status', + displayName: 'Customer ID', + name: 'customerid', type: 'number', default: 0, - description: 'The status of the ecommerceOrder', + description: 'The id of the customer associated with this order.', }, + { + displayName: 'Creation Date', + name: 'externalupdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'abandonedDate', + type: 'dateTime', + default: '', + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, + + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, + + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product field', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, + ] }, @@ -1485,11 +1601,10 @@ export class ActiveCampaign implements INodeType { // ecommerceOrder:delete // ---------------------------------- { - displayName: 'ecommerceOrder ID', - name: 'ecommerceOrderId', + displayName: 'Order ID', + name: 'orderId', type: 'number', default: 0, - required: true, displayOptions: { show: { operation: [ @@ -1500,18 +1615,17 @@ export class ActiveCampaign implements INodeType { ], }, }, - description: 'The ID of the ecommerceOrder', + description: 'The id of the e-commerce order.', }, // ---------------------------------- // ecommerceOrder:get // ---------------------------------- { - displayName: 'ecommerceOrder ID', - name: 'ecommerceOrderId', + displayName: 'Order ID', + name: 'orderId', type: 'number', default: 0, - required: true, displayOptions: { show: { operation: [ @@ -1522,7 +1636,7 @@ export class ActiveCampaign implements INodeType { ], }, }, - description: 'The ID of the ecommerceOrder', + description: 'The id of the e-commerce order.', }, // ---------------------------------- From 6bd391a35e0f85a130262b7c90bbccc4e776ea16 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sat, 2 Nov 2019 23:11:55 +0100 Subject: [PATCH 31/52] finish ecom order endpoints --- .../ActiveCampaign/ActiveCampaign.node.ts | 119 ++++++++++++++++-- .../nodes/ActiveCampaign/GenericFunctions.ts | 6 + 2 files changed, 113 insertions(+), 12 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index ffb54356657..55fc88617f9 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -7,12 +7,12 @@ import { INodeTypeDescription, INodeExecutionData, INodeType, - INodePropertyOptions, } from 'n8n-workflow'; import { activeCampaignApiRequest, activeCampaignApiRequestAllItems, + IProduct, } from './GenericFunctions'; import { returnAllCurrencyOptions } from './currencies' @@ -623,7 +623,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal pipeline ID', - name: 'owner', + name: 'group', type: 'string', default: '', displayOptions: { @@ -791,7 +791,7 @@ export class ActiveCampaign implements INodeType { }, { displayName: 'Deal pipeline ID', - name: 'owner', + name: 'group', type: 'string', default: '', description: 'The pipeline ID of the deal', @@ -1355,7 +1355,7 @@ export class ActiveCampaign implements INodeType { ] }, - + // ---------------------------------- // ecommerceOrder:update // ---------------------------------- @@ -1376,10 +1376,10 @@ export class ActiveCampaign implements INodeType { }, description: 'The id of the e-commerce order.', }, - + { displayName: 'Add Field', - name: 'additionalFields', + name: 'updateFields', type: 'collection', placeholder: 'Add Field', displayOptions: { @@ -1515,7 +1515,7 @@ export class ActiveCampaign implements INodeType { default: '', description: 'The order number. This can be different than the externalid.', }, - + { displayName: 'Products', name: 'orderProducts', @@ -1682,7 +1682,7 @@ export class ActiveCampaign implements INodeType { }, default: 100, description: 'How many results to return.', - }, + }, ], }; @@ -1805,9 +1805,10 @@ export class ActiveCampaign implements INodeType { title: this.getNodeParameter('title', i) as string, contact: this.getNodeParameter('contact', i) as string, value: this.getNodeParameter('value', i) as number, + currency: this.getNodeParameter('currency', i) as string } as IDataObject; - const group = this.getNodeParameter('owner', i) as string + const group = this.getNodeParameter('group', i) as string if (group !== '') { addAdditionalFields(body.deal as IDataObject, { group }) } @@ -1822,9 +1823,6 @@ export class ActiveCampaign implements INodeType { addAdditionalFields(body.deal as IDataObject, { stage }) } - const currency = this.getNodeParameter('currency', i) as string - addAdditionalFields(body.deal as IDataObject, { currency }) - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.deal as IDataObject, additionalFields); @@ -1906,6 +1904,103 @@ export class ActiveCampaign implements INodeType { endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`; + } else { + throw new Error(`The operation "${operation}" is not known`); + } + } else if (resource === 'ecommerceOrder') { + if (operation === 'create') { + // ---------------------------------- + // ecommerceOrder:create + // ---------------------------------- + + requestMethod = 'POST'; + + endpoint = '/api/3/ecomOrders'; + + dataKey = 'ecommerceOrder'; + + body.ecomOrder = { + source: this.getNodeParameter('source', i) as string, + email: this.getNodeParameter('email', i) as string, + totalPrice: this.getNodeParameter('totalPrice', i) as number, + currency: this.getNodeParameter('currency', i).toString().toUpperCase() as string, + externalCreatedDate: this.getNodeParameter('externalCreatedDate', i) as string, + connectionid: this.getNodeParameter('connectionid', i) as number, + customerid: this.getNodeParameter('customerid', i) as number, + } as IDataObject; + + const externalid = this.getNodeParameter('externalid', i) as string; + if (externalid !== '') { + addAdditionalFields(body.ecomOrder as IDataObject, { externalid }); + } + + const externalcheckoutid = this.getNodeParameter('externalcheckoutid', i) as string; + if (externalcheckoutid !== '') { + addAdditionalFields(body.ecomOrder as IDataObject, { externalcheckoutid }); + } + + const abandonedDate = this.getNodeParameter('abandonedDate', i) as string; + if (abandonedDate !== '') { + addAdditionalFields(body.ecomOrder as IDataObject, { abandonedDate }); + } + + const orderProducts = this.getNodeParameter('orderProducts', i) as unknown as IProduct[]; + addAdditionalFields(body.ecomOrder as IDataObject, { orderProducts }); + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + addAdditionalFields(body.ecomOrder as IDataObject, additionalFields); + + } else if (operation === 'update') { + // ---------------------------------- + // ecommerceOrder:update + // ---------------------------------- + + requestMethod = 'PUT'; + + const orderId = this.getNodeParameter('orderId', i) as number; + endpoint = `/api/3/ecomOrders/${orderId}`; + + dataKey = 'ecommerceOrder'; + body.ecomOrder = {} as IDataObject; + + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + addAdditionalFields(body.ecomOrder as IDataObject, updateFields); + + } else if (operation === 'delete') { + // ---------------------------------- + // ecommerceOrder:delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + const orderId = this.getNodeParameter('orderId', i) as number; + endpoint = `/api/3/ecomOrders/${orderId}`; + + } else if (operation === 'get') { + // ---------------------------------- + // ecommerceOrder:get + // ---------------------------------- + + requestMethod = 'GET'; + + const orderId = this.getNodeParameter('orderId', i) as number; + endpoint = `/api/3/ecomOrders/${orderId}`; + + } else if (operation === 'getAll') { + // ---------------------------------- + // ecommerceOrders:getAll + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + dataKey = 'ecommerceOrders'; + endpoint = `/api/3/ecomOrders`; + } else { throw new Error(`The operation "${operation}" is not known`); } diff --git a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts index 169c9f11468..932f73e2c15 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts @@ -9,6 +9,12 @@ import { import { OptionsWithUri } from 'request'; +export interface IProduct { + fields: { + item?: object[]; + }; +} + /** * Make an API request to ActiveCampaign From 09d00fc0d709a898e569003b14aabe0579c34727 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 12:47:36 +0100 Subject: [PATCH 32/52] refactor node description --- .../ActiveCampaign/ActiveCampaign.node.ts | 1600 +---------------- .../ActiveCampaign/ContactDescription.ts | 351 ++++ .../nodes/ActiveCampaign/DealDescription.ts | 529 ++++++ .../ActiveCampaign/EcomOrderDescription.ts | 719 ++++++++ .../nodes/ActiveCampaign/currencies.ts | 348 ++-- 5 files changed, 1792 insertions(+), 1755 deletions(-) create mode 100644 packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts create mode 100644 packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts create mode 100644 packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 55fc88617f9..127d06c4594 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -15,7 +15,20 @@ import { IProduct, } from './GenericFunctions'; -import { returnAllCurrencyOptions } from './currencies' +import { + contactOperations, + contactFields +} from './ContactDescription'; + +import { + dealOperations, + dealFields +} from './DealDescription'; + +import { + ecomOrderOperations, + ecomOrderFields +} from './EcomOrderDescription'; interface CustomProperty { name: string; @@ -63,7 +76,6 @@ export class ActiveCampaign implements INodeType { } ], properties: [ - // ---------------------------------- // resources // ---------------------------------- @@ -89,1600 +101,28 @@ export class ActiveCampaign implements INodeType { description: 'The resource to operate on.', }, - - // ---------------------------------- // operations // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'contact', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a contact', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a contact', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a contact', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all contact', - }, - { - name: 'Update', - value: 'update', - description: 'Update a contact', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, - - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'deal', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a deal', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a deal', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a deal', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all deals', - }, - { - name: 'Update', - value: 'update', - description: 'Update a deal', - }, - { - name: 'Create Note', - value: 'createNote', - description: 'Create a deal note', - }, - { - name: 'Update deal note', - value: 'updateNote', - description: 'Update a deal note', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, - - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'ecommerceOrder', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a order', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a order', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a order', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all orders', - }, - { - name: 'Update', - value: 'update', - description: 'Update a order', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, - - + ...contactOperations, + ...dealOperations, + ...ecomOrderOperations, // ---------------------------------- // contact // ---------------------------------- - - // ---------------------------------- - // contact:create - // ---------------------------------- - { - displayName: 'Email', - name: 'email', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], - }, - }, - description: 'The email of the contact to create', - }, - { - displayName: 'Update if exists', - name: 'updateIfExists', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], - }, - }, - default: false, - description: 'Update user if it exists already. If not set and user exists it will error instead.', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'First Name', - name: 'firstName', - type: 'string', - default: '', - description: 'The first name of the contact to create', - }, - { - displayName: 'Last Name', - name: 'lastName', - type: 'string', - default: '', - description: 'The last name of the contact to create', - }, - { - displayName: 'Phone', - name: 'phone', - type: 'string', - default: '', - description: 'Phone number of the contact.', - }, - { - displayName: 'Custom Properties', - name: 'customProperties', - placeholder: 'Add Custom Property', - description: 'Adds a custom property to set also values which have not been predefined.', - type: 'fixedCollection', - typeOptions: { - multipleValues: true, - }, - default: {}, - options: [ - { - name: 'property', - displayName: 'Property', - values: [ - { - displayName: 'Property Name', - name: 'name', - type: 'string', - default: '', - description: 'Name of the property to set.', - }, - { - displayName: 'Property Value', - name: 'value', - type: 'string', - default: '', - description: 'Value of the property to set.', - }, - ] - }, - ], - }, - ], - }, - - // ---------------------------------- - // contact:update - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to update.', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - description: 'The fields to update.', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Email', - name: 'email', - type: 'string', - default: '', - description: 'Email of the contact.', - }, - { - displayName: 'First Name', - name: 'firstName', - type: 'string', - default: '', - description: 'First name of the contact', - }, - { - displayName: 'Last Name', - name: 'lastName', - type: 'string', - default: '', - description: 'Last name of the contact', - }, - { - displayName: 'Phone', - name: 'phone', - type: 'string', - default: '', - description: 'Phone number of the contact.', - }, - { - displayName: 'Custom Properties', - name: 'customProperties', - placeholder: 'Add Custom Property', - description: 'Adds a custom property to set also values which have not been predefined.', - type: 'fixedCollection', - typeOptions: { - multipleValues: true, - }, - default: {}, - options: [ - { - name: 'property', - displayName: 'Property', - values: [ - { - displayName: 'Property Name', - name: 'name', - type: 'string', - default: '', - description: 'Name of the property to set.', - }, - { - displayName: 'Property Value', - name: 'value', - type: 'string', - default: '', - description: 'Value of the property to set.', - }, - ] - }, - ], - }, - ], - }, - - // ---------------------------------- - // contact:delete - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to delete.', - }, - - // ---------------------------------- - // contact:get - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to get.', - }, - - // ---------------------------------- - // contact:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, - + ...contactFields, // ---------------------------------- // deal // ---------------------------------- - - // ---------------------------------- - // deal:create - // ---------------------------------- - { - displayName: 'Title', - name: 'title', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The title of the deal', - }, - { - displayName: 'Deal\'s contact ID', - name: 'contact', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal\'s contact', - }, - { - displayName: 'Deal value', - name: 'value', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The value of the deal in cents', - }, - { - displayName: 'Currency', - name: 'currency', - type: 'options', - default: 'eur', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - options: returnAllCurrencyOptions(), - description: 'The currency of the deal in 3-character ISO format', - }, - { - displayName: 'Deal pipeline ID', - name: 'group', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The pipeline ID of the deal', - }, - { - displayName: 'Deal stage ID', - name: 'stage', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The stage ID of the deal', - }, - { - displayName: 'Deal owner ID', - name: 'owner', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The owner ID of the deal', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the deal', - }, - - { - displayName: 'Deal percentage', - name: 'percent', - type: 'number', - default: 0, - description: 'The percentage of the deal', - }, - { - displayName: 'Deal status', - name: 'status', - type: 'number', - default: 0, - description: 'The status of the deal', - }, - ] - }, - - // ---------------------------------- - // deal:update - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the deal to update.', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - description: 'The fields to update.', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Title', - name: 'title', - type: 'string', - default: '', - description: 'The title of the deal', - }, - { - displayName: 'Deal\'s contact ID', - name: 'contact', - type: 'number', - default: 0, - description: 'The ID of the deal\'s contact', - }, - { - displayName: 'Deal value', - name: 'value', - type: 'number', - default: 0, - description: 'The value of the deal in cents', - }, - { - displayName: 'Currency', - name: 'currency', - type: 'options', - options: returnAllCurrencyOptions(), - default: 'eur', - description: 'The currency of the deal in 3-character ISO format', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the deal', - }, - { - displayName: 'Deal pipeline ID', - name: 'group', - type: 'string', - default: '', - description: 'The pipeline ID of the deal', - }, - { - displayName: 'Deal stage ID', - name: 'stage', - type: 'string', - default: '', - description: 'The stage ID of the deal', - }, - { - displayName: 'Deal owner ID', - name: 'owner', - type: 'string', - default: '', - description: 'The owner ID of the deal', - }, - { - displayName: 'Deal percentage', - name: 'percent', - type: 'number', - default: 0, - description: 'The percentage of the deal', - }, - { - displayName: 'Deal status', - name: 'status', - type: 'number', - default: 0, - description: 'The status of the deal', - }, - ] - }, - - // ---------------------------------- - // deal:delete - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal', - }, - - // ---------------------------------- - // deal:get - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal', - }, - - // ---------------------------------- - // deal:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, - - // ---------------------------------- - // dealNote:create - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'createNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal note', - }, - { - displayName: 'Deal Note', - name: 'dealNote', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'createNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The content of the deal note', - }, - - // ---------------------------------- - // dealNote:update - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal note', - }, - { - displayName: 'Deal note ID', - name: 'dealNoteId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal note', - }, - { - displayName: 'Deal Note', - name: 'dealNote', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The content of the deal note', - }, + ...dealFields, // ---------------------------------- // ecommerceOrder // ---------------------------------- + ...ecomOrderFields, - // ---------------------------------- - // ecommerceOrder:create - // ---------------------------------- - { - displayName: 'External ID', - name: 'externalid', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', - }, - { - displayName: 'External checkout ID', - name: 'externalcheckoutid', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', - }, - { - displayName: 'Order source', - name: 'source', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The email address of the customer who placed the order.', - }, - { - displayName: 'Total price', - name: 'totalPrice', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Order currency', - name: 'currency', - type: 'options', - default: 'eur', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - options: returnAllCurrencyOptions(), - description: 'The currency of the order (3-digit ISO code, e.g., "USD").', - }, - { - displayName: 'Connection ID', - name: 'connectionid', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the connection from which this order originated.', - }, - { - displayName: 'Customer ID', - name: 'customerid', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the customer associated with this order.', - }, - { - displayName: 'Creation Date', - name: 'externalCreatedDate', - type: 'dateTime', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The date the order was placed.', - }, - { - displayName: 'Abandoning Date', - name: 'abandonedDate', - type: 'dateTime', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', - }, - { - displayName: 'Products', - name: 'orderProducts', - type: 'collection', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add product', - }, - displayOptions: { - show: { - operation: [ - 'create' - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - description: 'All ordered products', - placeholder: 'Add product field', - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The name of the product', - }, - { - displayName: 'Price', - name: 'price', - type: 'number', - default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Product Quantity', - name: 'quantity', - type: 'number', - default: 0, - description: 'The quantity ordered.', - }, - { - displayName: 'Product external ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the product in the external service.', - }, - { - displayName: 'Product Category', - name: 'category', - type: 'string', - default: '', - description: 'The category of the product.', - }, - { - displayName: 'SKU', - name: 'sku', - type: 'string', - default: '', - description: 'The SKU for the product.', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the product.', - }, - { - displayName: 'Image URL', - name: 'imageUrl', - type: 'string', - default: '', - description: 'An Image URL that displays an image of the product.', - }, - { - displayName: 'Product URL', - name: 'productUrl', - type: 'string', - default: '', - description: 'A URL linking to the product in your store.', - }, - ], - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Shipping Amount', - name: 'shippingAmount', - type: 'number', - default: 0, - description: 'The total shipping amount for the order in cents .', - }, - - { - displayName: 'Tax Amount', - name: 'taxAmount', - type: 'number', - default: 0, - description: 'The total tax amount for the order in cents.', - }, - { - displayName: 'Discount Amount', - name: 'discountAmount', - type: 'number', - default: 0, - description: 'The total discount amount for the order in cents.', - }, - { - displayName: 'Order URL', - name: 'orderUrl', - type: 'string', - default: '', - description: 'The URL for the order in the external service.', - }, - { - displayName: 'External updated date', - name: 'externalUpdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was updated.', - }, - { - displayName: 'Shipping Method', - name: 'shippingMethod', - type: 'string', - default: '', - description: 'The shipping method of the order.', - }, - { - displayName: 'Order Number', - name: 'orderNumber', - type: 'string', - default: '', - description: 'The order number. This can be different than the externalid.', - }, - - ] - }, - - // ---------------------------------- - // ecommerceOrder:update - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, - - { - displayName: 'Add Field', - name: 'updateFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'External ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', - }, - { - displayName: 'External checkout ID', - name: 'externalcheckoutid', - type: 'string', - default: '', - description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', - }, - { - displayName: 'Order source', - name: 'source', - type: 'number', - default: 0, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - description: 'The email address of the customer who placed the order.', - }, - { - displayName: 'Total price', - name: 'totalPrice', - type: 'number', - default: 0, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Order currency', - name: 'currency', - type: 'options', - default: 'eur', - options: returnAllCurrencyOptions(), - description: 'The currency of the order (3-digit ISO code, e.g., "USD").', - }, - { - displayName: 'Connection ID', - name: 'connectionid', - type: 'number', - default: 0, - description: 'The id of the connection from which this order originated.', - }, - { - displayName: 'Customer ID', - name: 'customerid', - type: 'number', - default: 0, - description: 'The id of the customer associated with this order.', - }, - { - displayName: 'Creation Date', - name: 'externalupdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was placed.', - }, - { - displayName: 'Abandoning Date', - name: 'abandonedDate', - type: 'dateTime', - default: '', - description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', - }, - { - displayName: 'Shipping Amount', - name: 'shippingAmount', - type: 'number', - default: 0, - description: 'The total shipping amount for the order in cents .', - }, - - { - displayName: 'Tax Amount', - name: 'taxAmount', - type: 'number', - default: 0, - description: 'The total tax amount for the order in cents.', - }, - { - displayName: 'Discount Amount', - name: 'discountAmount', - type: 'number', - default: 0, - description: 'The total discount amount for the order in cents.', - }, - { - displayName: 'Order URL', - name: 'orderUrl', - type: 'string', - default: '', - description: 'The URL for the order in the external service.', - }, - { - displayName: 'External updated date', - name: 'externalUpdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was updated.', - }, - { - displayName: 'Shipping Method', - name: 'shippingMethod', - type: 'string', - default: '', - description: 'The shipping method of the order.', - }, - { - displayName: 'Order Number', - name: 'orderNumber', - type: 'string', - default: '', - description: 'The order number. This can be different than the externalid.', - }, - - { - displayName: 'Products', - name: 'orderProducts', - type: 'collection', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add product', - }, - default: {}, - description: 'All ordered products', - placeholder: 'Add product field', - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The name of the product', - }, - { - displayName: 'Price', - name: 'price', - type: 'number', - default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Product Quantity', - name: 'quantity', - type: 'number', - default: 0, - description: 'The quantity ordered.', - }, - { - displayName: 'Product external ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the product in the external service.', - }, - { - displayName: 'Product Category', - name: 'category', - type: 'string', - default: '', - description: 'The category of the product.', - }, - { - displayName: 'SKU', - name: 'sku', - type: 'string', - default: '', - description: 'The SKU for the product.', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the product.', - }, - { - displayName: 'Image URL', - name: 'imageUrl', - type: 'string', - default: '', - description: 'An Image URL that displays an image of the product.', - }, - { - displayName: 'Product URL', - name: 'productUrl', - type: 'string', - default: '', - description: 'A URL linking to the product in your store.', - }, - ], - }, - - ] - }, - - // ---------------------------------- - // ecommerceOrder:delete - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, - - // ---------------------------------- - // ecommerceOrder:get - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, - - // ---------------------------------- - // ecommerceOrder:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, ], }; diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts new file mode 100644 index 00000000000..b4448245056 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts @@ -0,0 +1,351 @@ +import { INodeProperties } from "n8n-workflow"; + +export const contactOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'contact', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a contact', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a contact', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a contact', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all contact', + }, + { + name: 'Update', + value: 'update', + description: 'Update a contact', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, +] as INodeProperties[] + +export const contactFields = [ + // ---------------------------------- + // contact:create + // ---------------------------------- + { + displayName: 'Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'contact', + ], + }, + }, + description: 'The email of the contact to create', + }, + { + displayName: 'Update if exists', + name: 'updateIfExists', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'contact', + ], + }, + }, + default: false, + description: 'Update user if it exists already. If not set and user exists it will error instead.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'contact', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: 'The first name of the contact to create', + }, + { + displayName: 'Last Name', + name: 'lastName', + type: 'string', + default: '', + description: 'The last name of the contact to create', + }, + { + displayName: 'Phone', + name: 'phone', + type: 'string', + default: '', + description: 'Phone number of the contact.', + }, + { + displayName: 'Custom Properties', + name: 'customProperties', + placeholder: 'Add Custom Property', + description: 'Adds a custom property to set also values which have not been predefined.', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'property', + displayName: 'Property', + values: [ + { + displayName: 'Property Name', + name: 'name', + type: 'string', + default: '', + description: 'Name of the property to set.', + }, + { + displayName: 'Property Value', + name: 'value', + type: 'string', + default: '', + description: 'Value of the property to set.', + }, + ] + }, + ], + }, + ], + }, + + // ---------------------------------- + // contact:update + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'contact', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Email', + name: 'email', + type: 'string', + default: '', + description: 'Email of the contact.', + }, + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: 'First name of the contact', + }, + { + displayName: 'Last Name', + name: 'lastName', + type: 'string', + default: '', + description: 'Last name of the contact', + }, + { + displayName: 'Phone', + name: 'phone', + type: 'string', + default: '', + description: 'Phone number of the contact.', + }, + { + displayName: 'Custom Properties', + name: 'customProperties', + placeholder: 'Add Custom Property', + description: 'Adds a custom property to set also values which have not been predefined.', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'property', + displayName: 'Property', + values: [ + { + displayName: 'Property Name', + name: 'name', + type: 'string', + default: '', + description: 'Name of the property to set.', + }, + { + displayName: 'Property Value', + name: 'value', + type: 'string', + default: '', + description: 'Value of the property to set.', + }, + ] + }, + ], + }, + ], + }, + + // ---------------------------------- + // contact:delete + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to delete.', + }, + + // ---------------------------------- + // contact:get + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to get.', + }, + + // ---------------------------------- + // contact:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'contact', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'contact', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, +] as INodeProperties[] diff --git a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts new file mode 100644 index 00000000000..03ffc386df7 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts @@ -0,0 +1,529 @@ +import { INodeProperties } from "n8n-workflow"; + +import { allCurrencies } from './currencies'; + +export const dealOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'deal', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a deal', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a deal', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a deal', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all deals', + }, + { + name: 'Update', + value: 'update', + description: 'Update a deal', + }, + { + name: 'Create Note', + value: 'createNote', + description: 'Create a deal note', + }, + { + name: 'Update deal note', + value: 'updateNote', + description: 'Update a deal note', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, + +] as INodeProperties[] + +export const dealFields = [ + // ---------------------------------- + // deal:create + // ---------------------------------- + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The title of the deal', + }, + { + displayName: 'Deal\'s contact ID', + name: 'contact', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal\'s contact', + }, + { + displayName: 'Deal value', + name: 'value', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The value of the deal in cents', + }, + { + displayName: 'Currency', + name: 'currency', + type: 'options', + default: 'eur', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + options: allCurrencies, + description: 'The currency of the deal in 3-character ISO format', + }, + { + displayName: 'Deal pipeline ID', + name: 'group', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The pipeline ID of the deal', + }, + { + displayName: 'Deal stage ID', + name: 'stage', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The stage ID of the deal', + }, + { + displayName: 'Deal owner ID', + name: 'owner', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The owner ID of the deal', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the deal', + }, + + { + displayName: 'Deal percentage', + name: 'percent', + type: 'number', + default: 0, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'status', + type: 'number', + default: 0, + description: 'The status of the deal', + }, + ] + }, + + // ---------------------------------- + // deal:update + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the deal to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + description: 'The title of the deal', + }, + { + displayName: 'Deal\'s contact ID', + name: 'contact', + type: 'number', + default: 0, + description: 'The ID of the deal\'s contact', + }, + { + displayName: 'Deal value', + name: 'value', + type: 'number', + default: 0, + description: 'The value of the deal in cents', + }, + { + displayName: 'Currency', + name: 'currency', + type: 'options', + options: allCurrencies, + default: 'eur', + description: 'The currency of the deal in 3-character ISO format', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the deal', + }, + { + displayName: 'Deal pipeline ID', + name: 'group', + type: 'string', + default: '', + description: 'The pipeline ID of the deal', + }, + { + displayName: 'Deal stage ID', + name: 'stage', + type: 'string', + default: '', + description: 'The stage ID of the deal', + }, + { + displayName: 'Deal owner ID', + name: 'owner', + type: 'string', + default: '', + description: 'The owner ID of the deal', + }, + { + displayName: 'Deal percentage', + name: 'percent', + type: 'number', + default: 0, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'status', + type: 'number', + default: 0, + description: 'The status of the deal', + }, + ] + }, + + // ---------------------------------- + // deal:delete + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + + // ---------------------------------- + // deal:get + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal', + }, + + // ---------------------------------- + // deal:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, + + // ---------------------------------- + // dealNote:create + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'createNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal Note', + name: 'dealNote', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'createNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The content of the deal note', + }, + + // ---------------------------------- + // dealNote:update + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal note ID', + name: 'dealNoteId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal Note', + name: 'dealNote', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The content of the deal note', + }, + +] as INodeProperties[] \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts new file mode 100644 index 00000000000..846c5cd3553 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts @@ -0,0 +1,719 @@ +import { INodeProperties } from "n8n-workflow"; + +import { allCurrencies } from './currencies'; + +export const ecomOrderOperations = [ + + + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'ecommerceOrder', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a order', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a order', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a order', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all orders', + }, + { + name: 'Update', + value: 'update', + description: 'Update a order', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, +] as INodeProperties[] + +export const ecomOrderFields = [ + + // ---------------------------------- + // ecommerceOrder:create + // ---------------------------------- + { + displayName: 'External ID', + name: 'externalid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', + }, + { + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Order currency', + name: 'currency', + type: 'options', + default: 'eur', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + options: allCurrencies, + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', + }, + { + displayName: 'Connection ID', + name: 'connectionid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the connection from which this order originated.', + }, + { + displayName: 'Customer ID', + name: 'customerid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the customer associated with this order.', + }, + { + displayName: 'Creation Date', + name: 'externalCreatedDate', + type: 'dateTime', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'abandonedDate', + type: 'dateTime', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + displayOptions: { + show: { + operation: [ + 'create' + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product field', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, + + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, + + ] + }, + + // ---------------------------------- + // ecommerceOrder:update + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, + + { + displayName: 'Add Field', + name: 'updateFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'External ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', + }, + { + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', + type: 'number', + default: 0, + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', + type: 'number', + default: 0, + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Order currency', + name: 'currency', + type: 'options', + default: 'eur', + options: allCurrencies, + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', + }, + { + displayName: 'Connection ID', + name: 'connectionid', + type: 'number', + default: 0, + description: 'The id of the connection from which this order originated.', + }, + { + displayName: 'Customer ID', + name: 'customerid', + type: 'number', + default: 0, + description: 'The id of the customer associated with this order.', + }, + { + displayName: 'Creation Date', + name: 'externalupdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'abandonedDate', + type: 'dateTime', + default: '', + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, + + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, + + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product field', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, + + ] + }, + + // ---------------------------------- + // ecommerceOrder:delete + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, + + // ---------------------------------- + // ecommerceOrder:get + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, + + // ---------------------------------- + // ecommerceOrder:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, +] as INodeProperties[] \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts index 8ff4d48adc1..194864f72c2 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts @@ -1,175 +1,173 @@ -export function returnAllCurrencyOptions() { - return [ - { name: 'Euro', value: 'eur' }, - { name: 'United States Dollar', value: 'usd' }, - { name: 'British Pound Sterling', value: 'gbp' }, - { name: 'Swiss Franc', value: 'chf' }, - { name: 'Renminbi', value: 'cny' }, - { name: '--------', value: '' }, - { name: 'United Arab Emirates Dirham', value: 'aed' }, - { name: 'Afghan Afghani', value: 'afn' }, - { name: 'Albanian Lek', value: 'all' }, - { name: 'Armenian Dram', value: 'amd' }, - { name: 'Netherlands Antillean Guilder', value: 'ang' }, - { name: 'Angolan Kwanza', value: 'aoa' }, - { name: 'Argentine Peso', value: 'ars' }, - { name: 'Australian Dollar', value: 'aud' }, - { name: 'Aruban Florin', value: 'awg' }, - { name: 'Azerbaijani Manat', value: 'azn' }, - { name: 'Bosnia-Herzegovina Convertible Mark', value: 'bam' }, - { name: 'Barbadian Dollar', value: 'bbd' }, - { name: 'Bangladeshi Taka', value: 'bdt' }, - { name: 'Bulgarian Lev', value: 'bgn' }, - { name: 'Bahraini Dinar', value: 'bhd' }, - { name: 'Burundian Franc', value: 'bif' }, - { name: 'Bermudan Dollar', value: 'bmd' }, - { name: 'Brunei Dollar', value: 'bnd' }, - { name: 'Bolivian Boliviano', value: 'bob' }, - { name: 'Brazilian Real', value: 'brl' }, - { name: 'Bahamian Dollar', value: 'bsd' }, - { name: 'Bitcoin', value: 'btc' }, - { name: 'Bhutanese Ngultrum', value: 'btn' }, - { name: 'Botswanan Pula', value: 'bwp' }, - { name: 'Belarusian Ruble', value: 'byn' }, - { name: 'Belize Dollar', value: 'bzd' }, - { name: 'Canadian Dollar', value: 'cad' }, - { name: 'Congolese Franc', value: 'cdf' }, - { name: 'Chilean Unit of Account (UF)', value: 'clf' }, - { name: 'Chilean Peso', value: 'clp' }, - { name: 'Chinese Yuan (Offshore)', value: 'cnh' }, - { name: 'Colombian Peso', value: 'cop' }, - { name: 'Costa Rican Colón', value: 'crc' }, - { name: 'Cuban Convertible Peso', value: 'cuc' }, - { name: 'Cuban Peso', value: 'cup' }, - { name: 'Cape Verdean Escudo', value: 'cve' }, - { name: 'Czech Republic Koruna', value: 'czk' }, - { name: 'Djiboutian Franc', value: 'djf' }, - { name: 'Danish Krone', value: 'dkk' }, - { name: 'Dominican Peso', value: 'dop' }, - { name: 'Algerian Dinar', value: 'dzd' }, - { name: 'Egyptian Pound', value: 'egp' }, - { name: 'Eritrean Nakfa', value: 'ern' }, - { name: 'Ethiopian Birr', value: 'etb' }, - { name: 'Fijian Dollar', value: 'fjd' }, - { name: 'Falkland Islands Pound', value: 'fkp' }, - { name: 'Georgian Lari', value: 'gel' }, - { name: 'Guernsey Pound', value: 'ggp' }, - { name: 'Ghanaian Cedi', value: 'ghs' }, - { name: 'Gibraltar Pound', value: 'gip' }, - { name: 'Gambian Dalasi', value: 'gmd' }, - { name: 'Guinean Franc', value: 'gnf' }, - { name: 'Guatemalan Quetzal', value: 'gtq' }, - { name: 'Guyanaese Dollar', value: 'gyd' }, - { name: 'Hong Kong Dollar', value: 'hkd' }, - { name: 'Honduran Lempira', value: 'hnl' }, - { name: 'Croatian Kuna', value: 'hrk' }, - { name: 'Haitian Gourde', value: 'htg' }, - { name: 'Hungarian Forint', value: 'huf' }, - { name: 'Indonesian Rupiah', value: 'idr' }, - { name: 'Israeli New Sheqel', value: 'ils' }, - { name: 'Manx pound', value: 'imp' }, - { name: 'Indian Rupee', value: 'inr' }, - { name: 'Iraqi Dinar', value: 'iqd' }, - { name: 'Iranian Rial', value: 'irr' }, - { name: 'Icelandic Króna', value: 'isk' }, - { name: 'Jersey Pound', value: 'jep' }, - { name: 'Jamaican Dollar', value: 'jmd' }, - { name: 'Jordanian Dinar', value: 'jod' }, - { name: 'Japanese Yen', value: 'jpy' }, - { name: 'Kenyan Shilling', value: 'kes' }, - { name: 'Kyrgystani Som', value: 'kgs' }, - { name: 'Cambodian Riel', value: 'khr' }, - { name: 'Comorian Franc', value: 'kmf' }, - { name: 'North Korean Won', value: 'kpw' }, - { name: 'South Korean Won', value: 'krw' }, - { name: 'Kuwaiti Dinar', value: 'kwd' }, - { name: 'Cayman Islands Dollar', value: 'kyd' }, - { name: 'Kazakhstani Tenge', value: 'kzt' }, - { name: 'Laotian Kip', value: 'lak' }, - { name: 'Lebanese Pound', value: 'lbp' }, - { name: 'Sri Lankan Rupee', value: 'lkr' }, - { name: 'Liberian Dollar', value: 'lrd' }, - { name: 'Lesotho Loti', value: 'lsl' }, - { name: 'Libyan Dinar', value: 'lyd' }, - { name: 'Moroccan Dirham', value: 'mad' }, - { name: 'Moldovan Leu', value: 'mdl' }, - { name: 'Malagasy Ariary', value: 'mga' }, - { name: 'Macedonian Denar', value: 'mkd' }, - { name: 'Myanma Kyat', value: 'mmk' }, - { name: 'Mongolian Tugrik', value: 'mnt' }, - { name: 'Macanese Pataca', value: 'mop' }, - { name: 'Mauritanian Ouguiya (pre-2018)', value: 'mro' }, - { name: 'Mauritanian Ouguiya', value: 'mru' }, - { name: 'Mauritian Rupee', value: 'mur' }, - { name: 'Maldivian Rufiyaa', value: 'mvr' }, - { name: 'Malawian Kwacha', value: 'mwk' }, - { name: 'Mexican Peso', value: 'mxn' }, - { name: 'Malaysian Ringgit', value: 'myr' }, - { name: 'Mozambican Metical', value: 'mzn' }, - { name: 'Namibian Dollar', value: 'nad' }, - { name: 'Nigerian Naira', value: 'ngn' }, - { name: 'Nicaraguan Córdoba', value: 'nio' }, - { name: 'Norwegian Krone', value: 'nok' }, - { name: 'Nepalese Rupee', value: 'npr' }, - { name: 'New Zealand Dollar', value: 'nzd' }, - { name: 'Omani Rial', value: 'omr' }, - { name: 'Panamanian Balboa', value: 'pab' }, - { name: 'Peruvian Nuevo Sol', value: 'pen' }, - { name: 'Papua New Guinean Kina', value: 'pgk' }, - { name: 'Philippine Peso', value: 'php' }, - { name: 'Pakistani Rupee', value: 'pkr' }, - { name: 'Polish Zloty', value: 'pln' }, - { name: 'Paraguayan Guarani', value: 'pyg' }, - { name: 'Qatari Rial', value: 'qar' }, - { name: 'Romanian Leu', value: 'ron' }, - { name: 'Serbian Dinar', value: 'rsd' }, - { name: 'Russian Ruble', value: 'rub' }, - { name: 'Rwandan Franc', value: 'rwf' }, - { name: 'Saudi Riyal', value: 'sar' }, - { name: 'Solomon Islands Dollar', value: 'sbd' }, - { name: 'Seychellois Rupee', value: 'scr' }, - { name: 'Sudanese Pound', value: 'sdg' }, - { name: 'Swedish Krona', value: 'sek' }, - { name: 'Singapore Dollar', value: 'sgd' }, - { name: 'Saint Helena Pound', value: 'shp' }, - { name: 'Sierra Leonean Leone', value: 'sll' }, - { name: 'Somali Shilling', value: 'sos' }, - { name: 'Surinamese Dollar', value: 'srd' }, - { name: 'South Sudanese Pound', value: 'ssp' }, - { name: 'São Tomé and Príncipe Dobra (pre-2018)', value: 'std' }, - { name: 'São Tomé and Príncipe Dobra', value: 'stn' }, - { name: 'Salvadoran Colón', value: 'svc' }, - { name: 'Syrian Pound', value: 'syp' }, - { name: 'Swazi Lilangeni', value: 'szl' }, - { name: 'Thai Baht', value: 'thb' }, - { name: 'Tajikistani Somoni', value: 'tjs' }, - { name: 'Turkmenistani Manat', value: 'tmt' }, - { name: 'Tunisian Dinar', value: 'tnd' }, - { name: "Tongan Pa'anga", value: 'top' }, - { name: 'Turkish Lira', value: 'try' }, - { name: 'Trinidad and Tobago Dollar', value: 'ttd' }, - { name: 'New Taiwan Dollar', value: 'twd' }, - { name: 'Tanzanian Shilling', value: 'tzs' }, - { name: 'Ukrainian Hryvnia', value: 'uah' }, - { name: 'Ugandan Shilling', value: 'ugx' }, - { name: 'Uruguayan Peso', value: 'uyu' }, - { name: 'Uzbekistan Som', value: 'uzs' }, - { name: 'Venezuelan Bolívar Fuerte', value: 'vef' }, - { name: 'Vietnamese Dong', value: 'vnd' }, - { name: 'Vanuatu Vatu', value: 'vuv' }, - { name: 'Samoan Tala', value: 'wst' }, - { name: 'CFA Franc BEAC', value: 'xaf' }, - { name: 'Silver Ounce', value: 'xag' }, - { name: 'Gold Ounce', value: 'xau' }, - { name: 'East Caribbean Dollar', value: 'xcd' }, - { name: 'Special Drawing Rights', value: 'xdr' }, - { name: 'CFA Franc BCEAO', value: 'xof' }, - { name: 'Palladium Ounce', value: 'xpd' }, - { name: 'CFP Franc', value: 'xpf' }, - { name: 'Platinum Ounce', value: 'xpt' }, - { name: 'Yemeni Rial', value: 'yer' }, - { name: 'South African Rand', value: 'zar' }, - { name: 'Zambian Kwacha', value: 'zmw' }, - { name: 'Zimbabwean Dollar', value: 'zwl' } - ] -} \ No newline at end of file +export const allCurrencies = [ + { name: 'Euro', value: 'eur' }, + { name: 'United States Dollar', value: 'usd' }, + { name: 'British Pound Sterling', value: 'gbp' }, + { name: 'Swiss Franc', value: 'chf' }, + { name: 'Renminbi', value: 'cny' }, + { name: '--------', value: '' }, + { name: 'United Arab Emirates Dirham', value: 'aed' }, + { name: 'Afghan Afghani', value: 'afn' }, + { name: 'Albanian Lek', value: 'all' }, + { name: 'Armenian Dram', value: 'amd' }, + { name: 'Netherlands Antillean Guilder', value: 'ang' }, + { name: 'Angolan Kwanza', value: 'aoa' }, + { name: 'Argentine Peso', value: 'ars' }, + { name: 'Australian Dollar', value: 'aud' }, + { name: 'Aruban Florin', value: 'awg' }, + { name: 'Azerbaijani Manat', value: 'azn' }, + { name: 'Bosnia-Herzegovina Convertible Mark', value: 'bam' }, + { name: 'Barbadian Dollar', value: 'bbd' }, + { name: 'Bangladeshi Taka', value: 'bdt' }, + { name: 'Bulgarian Lev', value: 'bgn' }, + { name: 'Bahraini Dinar', value: 'bhd' }, + { name: 'Burundian Franc', value: 'bif' }, + { name: 'Bermudan Dollar', value: 'bmd' }, + { name: 'Brunei Dollar', value: 'bnd' }, + { name: 'Bolivian Boliviano', value: 'bob' }, + { name: 'Brazilian Real', value: 'brl' }, + { name: 'Bahamian Dollar', value: 'bsd' }, + { name: 'Bitcoin', value: 'btc' }, + { name: 'Bhutanese Ngultrum', value: 'btn' }, + { name: 'Botswanan Pula', value: 'bwp' }, + { name: 'Belarusian Ruble', value: 'byn' }, + { name: 'Belize Dollar', value: 'bzd' }, + { name: 'Canadian Dollar', value: 'cad' }, + { name: 'Congolese Franc', value: 'cdf' }, + { name: 'Chilean Unit of Account (UF)', value: 'clf' }, + { name: 'Chilean Peso', value: 'clp' }, + { name: 'Chinese Yuan (Offshore)', value: 'cnh' }, + { name: 'Colombian Peso', value: 'cop' }, + { name: 'Costa Rican Colón', value: 'crc' }, + { name: 'Cuban Convertible Peso', value: 'cuc' }, + { name: 'Cuban Peso', value: 'cup' }, + { name: 'Cape Verdean Escudo', value: 'cve' }, + { name: 'Czech Republic Koruna', value: 'czk' }, + { name: 'Djiboutian Franc', value: 'djf' }, + { name: 'Danish Krone', value: 'dkk' }, + { name: 'Dominican Peso', value: 'dop' }, + { name: 'Algerian Dinar', value: 'dzd' }, + { name: 'Egyptian Pound', value: 'egp' }, + { name: 'Eritrean Nakfa', value: 'ern' }, + { name: 'Ethiopian Birr', value: 'etb' }, + { name: 'Fijian Dollar', value: 'fjd' }, + { name: 'Falkland Islands Pound', value: 'fkp' }, + { name: 'Georgian Lari', value: 'gel' }, + { name: 'Guernsey Pound', value: 'ggp' }, + { name: 'Ghanaian Cedi', value: 'ghs' }, + { name: 'Gibraltar Pound', value: 'gip' }, + { name: 'Gambian Dalasi', value: 'gmd' }, + { name: 'Guinean Franc', value: 'gnf' }, + { name: 'Guatemalan Quetzal', value: 'gtq' }, + { name: 'Guyanaese Dollar', value: 'gyd' }, + { name: 'Hong Kong Dollar', value: 'hkd' }, + { name: 'Honduran Lempira', value: 'hnl' }, + { name: 'Croatian Kuna', value: 'hrk' }, + { name: 'Haitian Gourde', value: 'htg' }, + { name: 'Hungarian Forint', value: 'huf' }, + { name: 'Indonesian Rupiah', value: 'idr' }, + { name: 'Israeli New Sheqel', value: 'ils' }, + { name: 'Manx pound', value: 'imp' }, + { name: 'Indian Rupee', value: 'inr' }, + { name: 'Iraqi Dinar', value: 'iqd' }, + { name: 'Iranian Rial', value: 'irr' }, + { name: 'Icelandic Króna', value: 'isk' }, + { name: 'Jersey Pound', value: 'jep' }, + { name: 'Jamaican Dollar', value: 'jmd' }, + { name: 'Jordanian Dinar', value: 'jod' }, + { name: 'Japanese Yen', value: 'jpy' }, + { name: 'Kenyan Shilling', value: 'kes' }, + { name: 'Kyrgystani Som', value: 'kgs' }, + { name: 'Cambodian Riel', value: 'khr' }, + { name: 'Comorian Franc', value: 'kmf' }, + { name: 'North Korean Won', value: 'kpw' }, + { name: 'South Korean Won', value: 'krw' }, + { name: 'Kuwaiti Dinar', value: 'kwd' }, + { name: 'Cayman Islands Dollar', value: 'kyd' }, + { name: 'Kazakhstani Tenge', value: 'kzt' }, + { name: 'Laotian Kip', value: 'lak' }, + { name: 'Lebanese Pound', value: 'lbp' }, + { name: 'Sri Lankan Rupee', value: 'lkr' }, + { name: 'Liberian Dollar', value: 'lrd' }, + { name: 'Lesotho Loti', value: 'lsl' }, + { name: 'Libyan Dinar', value: 'lyd' }, + { name: 'Moroccan Dirham', value: 'mad' }, + { name: 'Moldovan Leu', value: 'mdl' }, + { name: 'Malagasy Ariary', value: 'mga' }, + { name: 'Macedonian Denar', value: 'mkd' }, + { name: 'Myanma Kyat', value: 'mmk' }, + { name: 'Mongolian Tugrik', value: 'mnt' }, + { name: 'Macanese Pataca', value: 'mop' }, + { name: 'Mauritanian Ouguiya (pre-2018)', value: 'mro' }, + { name: 'Mauritanian Ouguiya', value: 'mru' }, + { name: 'Mauritian Rupee', value: 'mur' }, + { name: 'Maldivian Rufiyaa', value: 'mvr' }, + { name: 'Malawian Kwacha', value: 'mwk' }, + { name: 'Mexican Peso', value: 'mxn' }, + { name: 'Malaysian Ringgit', value: 'myr' }, + { name: 'Mozambican Metical', value: 'mzn' }, + { name: 'Namibian Dollar', value: 'nad' }, + { name: 'Nigerian Naira', value: 'ngn' }, + { name: 'Nicaraguan Córdoba', value: 'nio' }, + { name: 'Norwegian Krone', value: 'nok' }, + { name: 'Nepalese Rupee', value: 'npr' }, + { name: 'New Zealand Dollar', value: 'nzd' }, + { name: 'Omani Rial', value: 'omr' }, + { name: 'Panamanian Balboa', value: 'pab' }, + { name: 'Peruvian Nuevo Sol', value: 'pen' }, + { name: 'Papua New Guinean Kina', value: 'pgk' }, + { name: 'Philippine Peso', value: 'php' }, + { name: 'Pakistani Rupee', value: 'pkr' }, + { name: 'Polish Zloty', value: 'pln' }, + { name: 'Paraguayan Guarani', value: 'pyg' }, + { name: 'Qatari Rial', value: 'qar' }, + { name: 'Romanian Leu', value: 'ron' }, + { name: 'Serbian Dinar', value: 'rsd' }, + { name: 'Russian Ruble', value: 'rub' }, + { name: 'Rwandan Franc', value: 'rwf' }, + { name: 'Saudi Riyal', value: 'sar' }, + { name: 'Solomon Islands Dollar', value: 'sbd' }, + { name: 'Seychellois Rupee', value: 'scr' }, + { name: 'Sudanese Pound', value: 'sdg' }, + { name: 'Swedish Krona', value: 'sek' }, + { name: 'Singapore Dollar', value: 'sgd' }, + { name: 'Saint Helena Pound', value: 'shp' }, + { name: 'Sierra Leonean Leone', value: 'sll' }, + { name: 'Somali Shilling', value: 'sos' }, + { name: 'Surinamese Dollar', value: 'srd' }, + { name: 'South Sudanese Pound', value: 'ssp' }, + { name: 'São Tomé and Príncipe Dobra (pre-2018)', value: 'std' }, + { name: 'São Tomé and Príncipe Dobra', value: 'stn' }, + { name: 'Salvadoran Colón', value: 'svc' }, + { name: 'Syrian Pound', value: 'syp' }, + { name: 'Swazi Lilangeni', value: 'szl' }, + { name: 'Thai Baht', value: 'thb' }, + { name: 'Tajikistani Somoni', value: 'tjs' }, + { name: 'Turkmenistani Manat', value: 'tmt' }, + { name: 'Tunisian Dinar', value: 'tnd' }, + { name: "Tongan Pa'anga", value: 'top' }, + { name: 'Turkish Lira', value: 'try' }, + { name: 'Trinidad and Tobago Dollar', value: 'ttd' }, + { name: 'New Taiwan Dollar', value: 'twd' }, + { name: 'Tanzanian Shilling', value: 'tzs' }, + { name: 'Ukrainian Hryvnia', value: 'uah' }, + { name: 'Ugandan Shilling', value: 'ugx' }, + { name: 'Uruguayan Peso', value: 'uyu' }, + { name: 'Uzbekistan Som', value: 'uzs' }, + { name: 'Venezuelan Bolívar Fuerte', value: 'vef' }, + { name: 'Vietnamese Dong', value: 'vnd' }, + { name: 'Vanuatu Vatu', value: 'vuv' }, + { name: 'Samoan Tala', value: 'wst' }, + { name: 'CFA Franc BEAC', value: 'xaf' }, + { name: 'Silver Ounce', value: 'xag' }, + { name: 'Gold Ounce', value: 'xau' }, + { name: 'East Caribbean Dollar', value: 'xcd' }, + { name: 'Special Drawing Rights', value: 'xdr' }, + { name: 'CFA Franc BCEAO', value: 'xof' }, + { name: 'Palladium Ounce', value: 'xpd' }, + { name: 'CFP Franc', value: 'xpf' }, + { name: 'Platinum Ounce', value: 'xpt' }, + { name: 'Yemeni Rial', value: 'yer' }, + { name: 'South African Rand', value: 'zar' }, + { name: 'Zambian Kwacha', value: 'zmw' }, + { name: 'Zimbabwean Dollar', value: 'zwl' } +] From 2c4702d75c152b27b193bab0f4de44f4112b4ea4 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 12:49:03 +0100 Subject: [PATCH 33/52] format changes --- .../ActiveCampaign/EcomOrderDescription.ts | 1315 ++++++++--------- 1 file changed, 656 insertions(+), 659 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts index 846c5cd3553..968898e2194 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts @@ -3,8 +3,6 @@ import { INodeProperties } from "n8n-workflow"; import { allCurrencies } from './currencies'; export const ecomOrderOperations = [ - - { displayName: 'Operation', name: 'operation', @@ -49,671 +47,670 @@ export const ecomOrderOperations = [ ] as INodeProperties[] export const ecomOrderFields = [ + // ---------------------------------- + // ecommerceOrder:create + // ---------------------------------- + { + displayName: 'External ID', + name: 'externalid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', + }, + { + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Order currency', + name: 'currency', + type: 'options', + default: 'eur', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + options: allCurrencies, + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', + }, + { + displayName: 'Connection ID', + name: 'connectionid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the connection from which this order originated.', + }, + { + displayName: 'Customer ID', + name: 'customerid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the customer associated with this order.', + }, + { + displayName: 'Creation Date', + name: 'externalCreatedDate', + type: 'dateTime', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'abandonedDate', + type: 'dateTime', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + displayOptions: { + show: { + operation: [ + 'create' + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product field', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, - // ---------------------------------- - // ecommerceOrder:create - // ---------------------------------- - { - displayName: 'External ID', - name: 'externalid', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', - }, - { - displayName: 'External checkout ID', - name: 'externalcheckoutid', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', - }, - { - displayName: 'Order source', - name: 'source', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The email address of the customer who placed the order.', - }, - { - displayName: 'Total price', - name: 'totalPrice', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Order currency', - name: 'currency', - type: 'options', - default: 'eur', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - options: allCurrencies, - description: 'The currency of the order (3-digit ISO code, e.g., "USD").', - }, - { - displayName: 'Connection ID', - name: 'connectionid', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the connection from which this order originated.', - }, - { - displayName: 'Customer ID', - name: 'customerid', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the customer associated with this order.', - }, - { - displayName: 'Creation Date', - name: 'externalCreatedDate', - type: 'dateTime', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The date the order was placed.', - }, - { - displayName: 'Abandoning Date', - name: 'abandonedDate', - type: 'dateTime', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', - }, - { - displayName: 'Products', - name: 'orderProducts', - type: 'collection', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add product', - }, - displayOptions: { - show: { - operation: [ - 'create' - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - description: 'All ordered products', - placeholder: 'Add product field', - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The name of the product', - }, - { - displayName: 'Price', - name: 'price', - type: 'number', - default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Product Quantity', - name: 'quantity', - type: 'number', - default: 0, - description: 'The quantity ordered.', - }, - { - displayName: 'Product external ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the product in the external service.', - }, - { - displayName: 'Product Category', - name: 'category', - type: 'string', - default: '', - description: 'The category of the product.', - }, - { - displayName: 'SKU', - name: 'sku', - type: 'string', - default: '', - description: 'The SKU for the product.', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the product.', - }, - { - displayName: 'Image URL', - name: 'imageUrl', - type: 'string', - default: '', - description: 'An Image URL that displays an image of the product.', - }, - { - displayName: 'Product URL', - name: 'productUrl', - type: 'string', - default: '', - description: 'A URL linking to the product in your store.', - }, - ], - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Shipping Amount', - name: 'shippingAmount', - type: 'number', - default: 0, - description: 'The total shipping amount for the order in cents .', - }, + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, - { - displayName: 'Tax Amount', - name: 'taxAmount', - type: 'number', - default: 0, - description: 'The total tax amount for the order in cents.', - }, - { - displayName: 'Discount Amount', - name: 'discountAmount', - type: 'number', - default: 0, - description: 'The total discount amount for the order in cents.', - }, - { - displayName: 'Order URL', - name: 'orderUrl', - type: 'string', - default: '', - description: 'The URL for the order in the external service.', - }, - { - displayName: 'External updated date', - name: 'externalUpdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was updated.', - }, - { - displayName: 'Shipping Method', - name: 'shippingMethod', - type: 'string', - default: '', - description: 'The shipping method of the order.', - }, - { - displayName: 'Order Number', - name: 'orderNumber', - type: 'string', - default: '', - description: 'The order number. This can be different than the externalid.', - }, + ] + }, - ] - }, + // ---------------------------------- + // ecommerceOrder:update + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, - // ---------------------------------- - // ecommerceOrder:update - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, + { + displayName: 'Add Field', + name: 'updateFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'External ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', + }, + { + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', + type: 'number', + default: 0, + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', + type: 'number', + default: 0, + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Order currency', + name: 'currency', + type: 'options', + default: 'eur', + options: allCurrencies, + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', + }, + { + displayName: 'Connection ID', + name: 'connectionid', + type: 'number', + default: 0, + description: 'The id of the connection from which this order originated.', + }, + { + displayName: 'Customer ID', + name: 'customerid', + type: 'number', + default: 0, + description: 'The id of the customer associated with this order.', + }, + { + displayName: 'Creation Date', + name: 'externalupdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'abandonedDate', + type: 'dateTime', + default: '', + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, - { - displayName: 'Add Field', - name: 'updateFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'External ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', - }, - { - displayName: 'External checkout ID', - name: 'externalcheckoutid', - type: 'string', - default: '', - description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', - }, - { - displayName: 'Order source', - name: 'source', - type: 'number', - default: 0, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - description: 'The email address of the customer who placed the order.', - }, - { - displayName: 'Total price', - name: 'totalPrice', - type: 'number', - default: 0, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Order currency', - name: 'currency', - type: 'options', - default: 'eur', - options: allCurrencies, - description: 'The currency of the order (3-digit ISO code, e.g., "USD").', - }, - { - displayName: 'Connection ID', - name: 'connectionid', - type: 'number', - default: 0, - description: 'The id of the connection from which this order originated.', - }, - { - displayName: 'Customer ID', - name: 'customerid', - type: 'number', - default: 0, - description: 'The id of the customer associated with this order.', - }, - { - displayName: 'Creation Date', - name: 'externalupdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was placed.', - }, - { - displayName: 'Abandoning Date', - name: 'abandonedDate', - type: 'dateTime', - default: '', - description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', - }, - { - displayName: 'Shipping Amount', - name: 'shippingAmount', - type: 'number', - default: 0, - description: 'The total shipping amount for the order in cents .', - }, + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, - { - displayName: 'Tax Amount', - name: 'taxAmount', - type: 'number', - default: 0, - description: 'The total tax amount for the order in cents.', - }, - { - displayName: 'Discount Amount', - name: 'discountAmount', - type: 'number', - default: 0, - description: 'The total discount amount for the order in cents.', - }, - { - displayName: 'Order URL', - name: 'orderUrl', - type: 'string', - default: '', - description: 'The URL for the order in the external service.', - }, - { - displayName: 'External updated date', - name: 'externalUpdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was updated.', - }, - { - displayName: 'Shipping Method', - name: 'shippingMethod', - type: 'string', - default: '', - description: 'The shipping method of the order.', - }, - { - displayName: 'Order Number', - name: 'orderNumber', - type: 'string', - default: '', - description: 'The order number. This can be different than the externalid.', - }, + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product field', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, - { - displayName: 'Products', - name: 'orderProducts', - type: 'collection', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add product', - }, - default: {}, - description: 'All ordered products', - placeholder: 'Add product field', - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The name of the product', - }, - { - displayName: 'Price', - name: 'price', - type: 'number', - default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Product Quantity', - name: 'quantity', - type: 'number', - default: 0, - description: 'The quantity ordered.', - }, - { - displayName: 'Product external ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the product in the external service.', - }, - { - displayName: 'Product Category', - name: 'category', - type: 'string', - default: '', - description: 'The category of the product.', - }, - { - displayName: 'SKU', - name: 'sku', - type: 'string', - default: '', - description: 'The SKU for the product.', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the product.', - }, - { - displayName: 'Image URL', - name: 'imageUrl', - type: 'string', - default: '', - description: 'An Image URL that displays an image of the product.', - }, - { - displayName: 'Product URL', - name: 'productUrl', - type: 'string', - default: '', - description: 'A URL linking to the product in your store.', - }, - ], - }, + ] + }, - ] - }, + // ---------------------------------- + // ecommerceOrder:delete + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, - // ---------------------------------- - // ecommerceOrder:delete - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, + // ---------------------------------- + // ecommerceOrder:get + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, - // ---------------------------------- - // ecommerceOrder:get - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, - - // ---------------------------------- - // ecommerceOrder:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, + // ---------------------------------- + // ecommerceOrder:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, ] as INodeProperties[] \ No newline at end of file From 0da9c035874f0d1a160cec50cf4a3e0890b3dda5 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 16:42:18 +0100 Subject: [PATCH 34/52] add ecom customer functionality --- .../ActiveCampaign/ActiveCampaign.node.ts | 112 ++++++- .../ActiveCampaign/EcomCustomerDescription.ts | 290 ++++++++++++++++++ 2 files changed, 399 insertions(+), 3 deletions(-) create mode 100644 packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 127d06c4594..ae163d7482f 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -30,6 +30,11 @@ import { ecomOrderFields } from './EcomOrderDescription'; +import { + ecomCustomerOperations, + ecomCustomerFields +} from './EcomCustomerDescription'; + interface CustomProperty { name: string; value: string; @@ -93,9 +98,13 @@ export class ActiveCampaign implements INodeType { value: 'deal', }, { - name: "E-commerce order", - value: "ecommerceOrder" - } + name: "E-commerce Order", + value: "ecommerceOrder", + }, + { + name: "E-Commerce Customer", + value: "ecommerceCustomer", + }, ], default: 'contact', description: 'The resource to operate on.', @@ -107,6 +116,7 @@ export class ActiveCampaign implements INodeType { ...contactOperations, ...dealOperations, ...ecomOrderOperations, + ...ecomCustomerOperations, // ---------------------------------- // contact @@ -123,6 +133,11 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- ...ecomOrderFields, + // ---------------------------------- + // ecommerceCustomer + // ---------------------------------- + ...ecomCustomerFields, + ], }; @@ -444,6 +459,95 @@ export class ActiveCampaign implements INodeType { } else { throw new Error(`The operation "${operation}" is not known`); } + } else if (resource === 'ecommerceCustomer') { + if (operation === 'create') { + // ---------------------------------- + // ecommerceCustomer:create + // ---------------------------------- + + requestMethod = 'POST'; + + endpoint = '/api/3/ecomCustomers'; + + dataKey = 'ecommerceCustomer'; + + body.ecomCustomer = { + connectionid: this.getNodeParameter('connectionid', i) as string, + externalid: this.getNodeParameter('externalid', i) as string, + email: this.getNodeParameter('email', i) as string, + } as IDataObject; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + if (additionalFields.acceptsMarketing) { + if (additionalFields.acceptsMarketing == true) { + additionalFields.acceptsMarketing = '1'; + } else { + additionalFields.acceptsMarketing = '0'; + } + } + addAdditionalFields(body.ecomOrder as IDataObject, additionalFields); + + } else if (operation === 'update') { + // ---------------------------------- + // ecommerceCustomer:update + // ---------------------------------- + + requestMethod = 'PUT'; + + const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number; + endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`; + + dataKey = 'ecommerceCustomer'; + body.ecomCustomer = {} as IDataObject; + + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + if (updateFields.acceptsMarketing) { + if (updateFields.acceptsMarketing == true) { + updateFields.acceptsMarketing = '1'; + } else { + updateFields.acceptsMarketing = '0'; + } + } + addAdditionalFields(body.ecomCustomer as IDataObject, updateFields); + + } else if (operation === 'delete') { + // ---------------------------------- + // ecommerceCustomer:delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number; + endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`; + + } else if (operation === 'get') { + // ---------------------------------- + // ecommerceCustomer:get + // ---------------------------------- + + requestMethod = 'GET'; + + const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number; + endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`; + + } else if (operation === 'getAll') { + // ---------------------------------- + // ecommerceCustomers:getAll + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + dataKey = 'ecommerceCustomers'; + endpoint = `/api/3/ecomCustomers`; + + } else { + throw new Error(`The operation "${operation}" is not known`); + } } else { throw new Error(`The resource "${resource}" is not known!`); @@ -463,6 +567,8 @@ export class ActiveCampaign implements INodeType { } } + console.log(body) + return [this.helpers.returnJsonArray(returnData)]; } } diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts new file mode 100644 index 00000000000..4399ca3fa08 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts @@ -0,0 +1,290 @@ +import { INodeProperties } from "n8n-workflow"; + +export const ecomCustomerOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'ecommerceCustomer', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a ecommerceCustomer', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a ecommerceCustomer', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a ecommerceCustomer', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all ecommerceCustomer', + }, + { + name: 'Update', + value: 'update', + description: 'Update a ecommerceCustomer', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, +] as INodeProperties[] + +export const ecomCustomerFields = [ + // ---------------------------------- + // ecommerceCustomer:create + // ---------------------------------- + { + displayName: 'Service ID', + name: 'connectionid', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + description: 'The id of the connection object for the service where the customer originates.', + }, + { + displayName: 'Customer ID', + name: 'externalid', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + description: 'The id of the customer in the external service.', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + description: 'The email address of the customer.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Accepts Marketing', + name: 'acceptsMarketing', + type: 'boolean', + default: false, + description: 'Indication of whether customer has opt-ed in to marketing communications.', + }, + ], + }, + + // ---------------------------------- + // ecommerceCustomer:update + // ---------------------------------- + { + displayName: 'Customer ID', + name: 'ecommerceCustomerId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the ecommerceCustomer to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Service ID', + name: 'connectionid', + type: 'string', + default: '', + description: 'The id of the connection object for the service where the customer originates.', + }, + { + displayName: 'Customer ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the customer in the external service.', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + description: 'The email address of the customer.', + }, + { + displayName: 'Accepts Marketing', + name: 'acceptsMarketing', + type: 'boolean', + default: false, + description: 'Indication of whether customer has opt-ed in to marketing communications.', + }, + ], + }, + + // ---------------------------------- + // ecommerceCustomer:delete + // ---------------------------------- + { + displayName: 'Customer ID', + name: 'ecommerceCustomerId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the ecommerceCustomer to update.', + }, + + // ---------------------------------- + // ecommerceCustomer:get + // ---------------------------------- + { + displayName: 'Customer ID', + name: 'ecommerceCustomerId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the ecommerceCustomer to update.', + }, + + // ---------------------------------- + // ecommerceCustomer:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceCustomer', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, +] as INodeProperties[] From 9a3a0d150b2572ad29e10fd2dbd0ded42c6cc53d Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 17:58:46 +0100 Subject: [PATCH 35/52] add ecom order products option decrisption --- .../ActiveCampaign/ActiveCampaign.node.ts | 39 ++---- .../ActiveCampaign/EcomCustomerDescription.ts | 10 +- .../EcomOrderProductsDescription.ts | 127 ++++++++++++++++++ .../nodes/ActiveCampaign/GenericFunctions.ts | 8 +- 4 files changed, 152 insertions(+), 32 deletions(-) create mode 100644 packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index ae163d7482f..67153c18aa8 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -98,13 +98,17 @@ export class ActiveCampaign implements INodeType { value: 'deal', }, { - name: "E-commerce Order", - value: "ecommerceOrder", + name: 'E-commerce Order', + value: 'ecommerceOrder', }, { - name: "E-Commerce Customer", - value: "ecommerceCustomer", + name: 'E-Commerce Customer', + value: 'ecommerceCustomer', }, + { + name: 'E-commerce Order Products', + value: 'ecomerceOrderProducts' + } ], default: 'contact', description: 'The resource to operate on.', @@ -254,8 +258,6 @@ export class ActiveCampaign implements INodeType { endpoint = '/api/3/deals'; - dataKey = 'deal'; - body.deal = { title: this.getNodeParameter('title', i) as string, contact: this.getNodeParameter('contact', i) as string, @@ -291,8 +293,8 @@ export class ActiveCampaign implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/api/3/deals/${dealId}`; - dataKey = 'deal'; body.deal = {} as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.deal as IDataObject, updateFields); @@ -328,7 +330,6 @@ export class ActiveCampaign implements INodeType { qs.limit = this.getNodeParameter('limit', i) as number; } - dataKey = 'deals'; endpoint = `/api/3/deals`; } else if (operation === 'createNote') { @@ -358,7 +359,6 @@ export class ActiveCampaign implements INodeType { const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`; - } else { throw new Error(`The operation "${operation}" is not known`); } @@ -372,8 +372,6 @@ export class ActiveCampaign implements INodeType { endpoint = '/api/3/ecomOrders'; - dataKey = 'ecommerceOrder'; - body.ecomOrder = { source: this.getNodeParameter('source', i) as string, email: this.getNodeParameter('email', i) as string, @@ -415,7 +413,6 @@ export class ActiveCampaign implements INodeType { const orderId = this.getNodeParameter('orderId', i) as number; endpoint = `/api/3/ecomOrders/${orderId}`; - dataKey = 'ecommerceOrder'; body.ecomOrder = {} as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; @@ -453,7 +450,6 @@ export class ActiveCampaign implements INodeType { qs.limit = this.getNodeParameter('limit', i) as number; } - dataKey = 'ecommerceOrders'; endpoint = `/api/3/ecomOrders`; } else { @@ -469,8 +465,6 @@ export class ActiveCampaign implements INodeType { endpoint = '/api/3/ecomCustomers'; - dataKey = 'ecommerceCustomer'; - body.ecomCustomer = { connectionid: this.getNodeParameter('connectionid', i) as string, externalid: this.getNodeParameter('externalid', i) as string, @@ -478,14 +472,14 @@ export class ActiveCampaign implements INodeType { } as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - if (additionalFields.acceptsMarketing) { + if (additionalFields.acceptsMarketing !== undefined) { if (additionalFields.acceptsMarketing == true) { additionalFields.acceptsMarketing = '1'; } else { additionalFields.acceptsMarketing = '0'; } - } - addAdditionalFields(body.ecomOrder as IDataObject, additionalFields); + } + addAdditionalFields(body.ecomCustomer as IDataObject, additionalFields); } else if (operation === 'update') { // ---------------------------------- @@ -497,11 +491,10 @@ export class ActiveCampaign implements INodeType { const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number; endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`; - dataKey = 'ecommerceCustomer'; body.ecomCustomer = {} as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - if (updateFields.acceptsMarketing) { + if (updateFields.acceptsMarketing != undefined) { if (updateFields.acceptsMarketing == true) { updateFields.acceptsMarketing = '1'; } else { @@ -542,7 +535,6 @@ export class ActiveCampaign implements INodeType { qs.limit = this.getNodeParameter('limit', i) as number; } - dataKey = 'ecommerceCustomers'; endpoint = `/api/3/ecomCustomers`; } else { @@ -567,9 +559,6 @@ export class ActiveCampaign implements INodeType { } } - console.log(body) - return [this.helpers.returnJsonArray(returnData)]; } -} - +} \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts index 4399ca3fa08..53842df995f 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts @@ -16,27 +16,27 @@ export const ecomCustomerOperations = [ { name: 'Create', value: 'create', - description: 'Create a ecommerceCustomer', + description: 'Create a E-commerce Customer', }, { name: 'Delete', value: 'delete', - description: 'Delete a ecommerceCustomer', + description: 'Delete a E-commerce Customer', }, { name: 'Get', value: 'get', - description: 'Get data of a ecommerceCustomer', + description: 'Get data of a E-commerce Customer', }, { name: 'Get All', value: 'getAll', - description: 'Get data of all ecommerceCustomer', + description: 'Get data of all E-commerce Customer', }, { name: 'Update', value: 'update', - description: 'Update a ecommerceCustomer', + description: 'Update a E-commerce Customer', }, ], default: 'create', diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts new file mode 100644 index 00000000000..ec28fafe8a0 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts @@ -0,0 +1,127 @@ +import { INodeProperties } from "n8n-workflow"; + +import { allCurrencies } from './currencies'; + +export const ecomOrderProductsOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + options: [ + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all orders', + }, + { + name: 'Get by Product ID', + value: 'getByProductId', + description: 'Get data of a order', + }, + { + name: 'Get by Order ID', + value: 'getByOrderId', + description: 'Get data of a order', + }, + + ], + default: 'create', + description: 'The operation to perform.', + }, +] as INodeProperties[] + +export const ecomOrderProductsFields = [ + // ---------------------------------- + // ecommerceOrderProducts:getByOrderId + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'getByOrderId', + ], + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, + + // ---------------------------------- + // ecommerceOrderProducts:getByProductId + // ---------------------------------- + { + displayName: 'Product ID', + name: 'procuctId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'getByProductId', + ], + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, + + // ---------------------------------- + // ecommerceOrderProducts:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrderProducts', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, +] as INodeProperties[] \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts index 932f73e2c15..769effe9eff 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts @@ -105,10 +105,14 @@ export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IE if (dataKey === undefined) { returnData.push.apply(returnData, responseData); - itemsReceived += returnData.length; + if (returnData != undefined) { + itemsReceived += returnData.length; + } } else { returnData.push.apply(returnData, responseData[dataKey]); - itemsReceived += responseData[dataKey].length; + if (responseData[dataKey] != undefined) { + itemsReceived += responseData[dataKey].length; + } } query.offset = itemsReceived; From e764748aa11c4502b1a2b4bc8afea0da43686d47 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 21:18:58 +0100 Subject: [PATCH 36/52] add ecommerce order products functionality --- .../ActiveCampaign/ActiveCampaign.node.ts | 53 ++++++++++++++++++- .../EcomOrderProductsDescription.ts | 15 +++--- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 67153c18aa8..2c2f03a2a70 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -34,6 +34,7 @@ import { ecomCustomerOperations, ecomCustomerFields } from './EcomCustomerDescription'; +import { ecomOrderProductsOperations, ecomOrderProductsFields } from './EcomOrderProductsDescription'; interface CustomProperty { name: string; @@ -107,7 +108,7 @@ export class ActiveCampaign implements INodeType { }, { name: 'E-commerce Order Products', - value: 'ecomerceOrderProducts' + value: 'ecommerceOrderProducts' } ], default: 'contact', @@ -121,6 +122,7 @@ export class ActiveCampaign implements INodeType { ...dealOperations, ...ecomOrderOperations, ...ecomCustomerOperations, + ...ecomOrderProductsOperations, // ---------------------------------- // contact @@ -142,6 +144,11 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- ...ecomCustomerFields, + // ---------------------------------- + // ecommerceOrderProducts + // ---------------------------------- + ...ecomOrderProductsFields, + ], }; @@ -478,7 +485,7 @@ export class ActiveCampaign implements INodeType { } else { additionalFields.acceptsMarketing = '0'; } - } + } addAdditionalFields(body.ecomCustomer as IDataObject, additionalFields); } else if (operation === 'update') { @@ -540,6 +547,48 @@ export class ActiveCampaign implements INodeType { } else { throw new Error(`The operation "${operation}" is not known`); } + } else if (resource === 'ecommerceOrderProducts') { + if (operation === 'getByProductId') { + // ---------------------------------- + // ecommerceOrderProducts:getByProductId + // ---------------------------------- + + requestMethod = 'GET'; + + const procuctId = this.getNodeParameter('procuctId', i) as number; + endpoint = `/api/3/ecomOrderProducts/${procuctId}`; + + + } else if (operation === 'getByOrderId') { + // ---------------------------------- + // ecommerceOrderProducts:getByOrderId + // ---------------------------------- + + requestMethod = 'GET'; + + const orderId = this.getNodeParameter('orderId', i) as number; + endpoint = `/api/3/ecomOrders/${orderId}/orderProducts`; + + } else if (operation === 'getAll') { + // ---------------------------------- + // ecommerceOrderProductss:getAll + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + endpoint = `/api/3/ecomOrderProducts`; + + } else { + throw new Error(`The operation "${operation}" is not known`); + } + + console.log(endpoint); + console.log(body) } else { throw new Error(`The resource "${resource}" is not known!`); diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts index ec28fafe8a0..fbff8787d9a 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts @@ -1,7 +1,5 @@ import { INodeProperties } from "n8n-workflow"; -import { allCurrencies } from './currencies'; - export const ecomOrderProductsOperations = [ { displayName: 'Operation', @@ -18,21 +16,20 @@ export const ecomOrderProductsOperations = [ { name: 'Get All', value: 'getAll', - description: 'Get data of all orders', + description: 'Get data of all order products', }, { name: 'Get by Product ID', value: 'getByProductId', - description: 'Get data of a order', + description: 'Get data of a ordered product', }, { name: 'Get by Order ID', value: 'getByOrderId', - description: 'Get data of a order', + description: 'Get data of an order\'s products', }, - ], - default: 'create', + default: 'getAll', description: 'The operation to perform.', }, ] as INodeProperties[] @@ -56,7 +53,7 @@ export const ecomOrderProductsFields = [ ], }, }, - description: 'The id of the e-commerce order.', + description: 'The ID of the order whose products you\'d like returned.', }, // ---------------------------------- @@ -77,7 +74,7 @@ export const ecomOrderProductsFields = [ ], }, }, - description: 'The id of the e-commerce order.', + description: 'The ID of the product you\'d like returned.', }, // ---------------------------------- From bc6acaff7292065df723e1210b2a043cc6a235f9 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 21:47:23 +0100 Subject: [PATCH 37/52] tslint changes --- .../ActiveCampaign/ActiveCampaign.node.ts | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 2c2f03a2a70..0b63c45a02e 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -196,9 +196,11 @@ export class ActiveCampaign implements INodeType { } dataKey = 'contact'; + body.contact = { email: this.getNodeParameter('email', i) as string, } as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.contact as IDataObject, additionalFields); @@ -269,22 +271,22 @@ export class ActiveCampaign implements INodeType { title: this.getNodeParameter('title', i) as string, contact: this.getNodeParameter('contact', i) as string, value: this.getNodeParameter('value', i) as number, - currency: this.getNodeParameter('currency', i) as string + currency: this.getNodeParameter('currency', i) as string, } as IDataObject; - const group = this.getNodeParameter('group', i) as string + const group = this.getNodeParameter('group', i) as string; if (group !== '') { - addAdditionalFields(body.deal as IDataObject, { group }) + addAdditionalFields(body.deal as IDataObject, { group }); } - const owner = this.getNodeParameter('owner', i) as string + const owner = this.getNodeParameter('owner', i) as string; if (owner !== '') { - addAdditionalFields(body.deal as IDataObject, { owner }) + addAdditionalFields(body.deal as IDataObject, { owner }); } - const stage = this.getNodeParameter('stage', i) as string + const stage = this.getNodeParameter('stage', i) as string; if (stage !== '') { - addAdditionalFields(body.deal as IDataObject, { stage }) + addAdditionalFields(body.deal as IDataObject, { stage }); } const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; @@ -343,11 +345,11 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- // deal:createNote // ---------------------------------- - requestMethod = 'POST' + requestMethod = 'POST'; body.note = { note: this.getNodeParameter('dealNote', i) as string, - } as IDataObject + } as IDataObject; const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/api/3/deals/${dealId}/notes`; @@ -356,11 +358,11 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- // deal:updateNote // ---------------------------------- - requestMethod = 'PUT' + requestMethod = 'PUT'; body.note = { note: this.getNodeParameter('dealNote', i) as string, - } as IDataObject + } as IDataObject; const dealId = this.getNodeParameter('dealId', i) as number; const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; @@ -480,7 +482,7 @@ export class ActiveCampaign implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.acceptsMarketing !== undefined) { - if (additionalFields.acceptsMarketing == true) { + if (additionalFields.acceptsMarketing === true) { additionalFields.acceptsMarketing = '1'; } else { additionalFields.acceptsMarketing = '0'; @@ -501,8 +503,8 @@ export class ActiveCampaign implements INodeType { body.ecomCustomer = {} as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - if (updateFields.acceptsMarketing != undefined) { - if (updateFields.acceptsMarketing == true) { + if (updateFields.acceptsMarketing !== undefined) { + if (updateFields.acceptsMarketing === true) { updateFields.acceptsMarketing = '1'; } else { updateFields.acceptsMarketing = '0'; @@ -587,9 +589,6 @@ export class ActiveCampaign implements INodeType { throw new Error(`The operation "${operation}" is not known`); } - console.log(endpoint); - console.log(body) - } else { throw new Error(`The resource "${resource}" is not known!`); } From 7da53ad943a4692905889fe8c119f34795f28ea0 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 21:49:49 +0100 Subject: [PATCH 38/52] more tslint changes --- .../nodes-base/nodes/ActiveCampaign/ContactDescription.ts | 4 ++-- packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts | 4 ++-- .../nodes/ActiveCampaign/EcomCustomerDescription.ts | 4 ++-- .../nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts | 4 ++-- .../nodes/ActiveCampaign/EcomOrderProductsDescription.ts | 4 ++-- packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts | 4 ++-- packages/nodes-base/nodes/ActiveCampaign/currencies.ts | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts index b4448245056..02c699e4b05 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts @@ -42,7 +42,7 @@ export const contactOperations = [ default: 'create', description: 'The operation to perform.', }, -] as INodeProperties[] +] as INodeProperties[]; export const contactFields = [ // ---------------------------------- @@ -348,4 +348,4 @@ export const contactFields = [ default: 100, description: 'How many results to return.', }, -] as INodeProperties[] +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts index 03ffc386df7..dac1b0aa3d8 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts @@ -55,7 +55,7 @@ export const dealOperations = [ description: 'The operation to perform.', }, -] as INodeProperties[] +] as INodeProperties[]; export const dealFields = [ // ---------------------------------- @@ -526,4 +526,4 @@ export const dealFields = [ description: 'The content of the deal note', }, -] as INodeProperties[] \ No newline at end of file +] as INodeProperties[]; \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts index 53842df995f..78c09afad86 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts @@ -42,7 +42,7 @@ export const ecomCustomerOperations = [ default: 'create', description: 'The operation to perform.', }, -] as INodeProperties[] +] as INodeProperties[]; export const ecomCustomerFields = [ // ---------------------------------- @@ -287,4 +287,4 @@ export const ecomCustomerFields = [ default: 100, description: 'How many results to return.', }, -] as INodeProperties[] +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts index 968898e2194..a1c0993dfea 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts @@ -44,7 +44,7 @@ export const ecomOrderOperations = [ default: 'create', description: 'The operation to perform.', }, -] as INodeProperties[] +] as INodeProperties[]; export const ecomOrderFields = [ // ---------------------------------- @@ -713,4 +713,4 @@ export const ecomOrderFields = [ default: 100, description: 'How many results to return.', }, -] as INodeProperties[] \ No newline at end of file +] as INodeProperties[]; \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts index fbff8787d9a..29869a74359 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts @@ -32,7 +32,7 @@ export const ecomOrderProductsOperations = [ default: 'getAll', description: 'The operation to perform.', }, -] as INodeProperties[] +] as INodeProperties[]; export const ecomOrderProductsFields = [ // ---------------------------------- @@ -121,4 +121,4 @@ export const ecomOrderProductsFields = [ default: 100, description: 'How many results to return.', }, -] as INodeProperties[] \ No newline at end of file +] as INodeProperties[]; \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts index 769effe9eff..fe607b80b97 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts @@ -105,12 +105,12 @@ export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IE if (dataKey === undefined) { returnData.push.apply(returnData, responseData); - if (returnData != undefined) { + if (returnData !== undefined) { itemsReceived += returnData.length; } } else { returnData.push.apply(returnData, responseData[dataKey]); - if (responseData[dataKey] != undefined) { + if (responseData[dataKey] !== undefined) { itemsReceived += responseData[dataKey].length; } } diff --git a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts index 194864f72c2..e979999eef9 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts @@ -170,4 +170,4 @@ export const allCurrencies = [ { name: 'South African Rand', value: 'zar' }, { name: 'Zambian Kwacha', value: 'zmw' }, { name: 'Zimbabwean Dollar', value: 'zwl' } -] +]; From e02946817103007145617e9df3625c45d81db266 Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 22:17:43 +0100 Subject: [PATCH 39/52] add connection description --- .../ActiveCampaign/ActiveCampaign.node.ts | 101 +++++- .../ActiveCampaign/ConnectionDescription.ts | 324 ++++++++++++++++++ .../ActiveCampaign/ContactDescription.ts | 10 +- .../nodes/ActiveCampaign/DealDescription.ts | 4 +- .../ActiveCampaign/EcomCustomerDescription.ts | 6 +- 5 files changed, 434 insertions(+), 11 deletions(-) create mode 100644 packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 0b63c45a02e..1ae440fd0cf 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -34,7 +34,16 @@ import { ecomCustomerOperations, ecomCustomerFields } from './EcomCustomerDescription'; -import { ecomOrderProductsOperations, ecomOrderProductsFields } from './EcomOrderProductsDescription'; + +import { + ecomOrderProductsOperations, + ecomOrderProductsFields +} from './EcomOrderProductsDescription'; + +import { + connectionOperations, + connectionFields +} from './ConnectionDescription'; interface CustomProperty { name: string; @@ -98,6 +107,10 @@ export class ActiveCampaign implements INodeType { name: 'Deal', value: 'deal', }, + { + name: 'Connection', + value: 'connection' + } { name: 'E-commerce Order', value: 'ecommerceOrder', @@ -120,10 +133,14 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- ...contactOperations, ...dealOperations, + ...connectionOperations, ...ecomOrderOperations, ...ecomCustomerOperations, ...ecomOrderProductsOperations, + // ---------------------------------- + // fields + // ---------------------------------- // ---------------------------------- // contact // ---------------------------------- @@ -134,6 +151,11 @@ export class ActiveCampaign implements INodeType { // ---------------------------------- ...dealFields, + // ---------------------------------- + // connection + // ---------------------------------- + ...connectionFields, + // ---------------------------------- // ecommerceOrder // ---------------------------------- @@ -368,6 +390,83 @@ export class ActiveCampaign implements INodeType { const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`; + } else { + throw new Error(`The operation "${operation}" is not known`); + } + } else if (resource === 'connection') { + if (operation === 'create') { + // ---------------------------------- + // connection:create + // ---------------------------------- + + requestMethod = 'POST'; + + const updateIfExists = this.getNodeParameter('updateIfExists', i) as boolean; + if (updateIfExists === true) { + endpoint = '/api/3/connection/sync'; + } else { + endpoint = '/api/3/connections'; + } + + dataKey = 'connection'; + + body.connection = { + email: this.getNodeParameter('email', i) as string, + } as IDataObject; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + addAdditionalFields(body.connection as IDataObject, additionalFields); + + } else if (operation === 'delete') { + // ---------------------------------- + // connection:delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + const connectionId = this.getNodeParameter('connectionId', i) as number; + endpoint = `/api/3/connections/${connectionId}`; + + } else if (operation === 'get') { + // ---------------------------------- + // connection:get + // ---------------------------------- + + requestMethod = 'GET'; + + const connectionId = this.getNodeParameter('connectionId', i) as number; + endpoint = `/api/3/connections/${connectionId}`; + + } else if (operation === 'getAll') { + // ---------------------------------- + // connections:getAll + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + dataKey = 'connections'; + endpoint = `/api/3/connections`; + + } else if (operation === 'update') { + // ---------------------------------- + // connection:update + // ---------------------------------- + + requestMethod = 'PUT'; + + const connectionId = this.getNodeParameter('connectionId', i) as number; + endpoint = `/api/3/connections/${connectionId}`; + + dataKey = 'connection'; + body.connection = {} as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + addAdditionalFields(body.connection as IDataObject, updateFields); + } else { throw new Error(`The operation "${operation}" is not known`); } diff --git a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts new file mode 100644 index 00000000000..f8c7d1ede40 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts @@ -0,0 +1,324 @@ +import { INodeProperties } from "n8n-workflow"; + +import { allCurrencies } from './currencies'; + +export const connectionOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'connection', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a connection', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a connection', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a connection', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all connections', + }, + { + name: 'Update', + value: 'update', + description: 'Update a connection', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, + +] as INodeProperties[]; + +export const connectionFields = [ + // ---------------------------------- + // connection:create + // ---------------------------------- + { + displayName: 'Service', + name: 'service', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The name of the service.', + }, + { + displayName: 'External accout ID', + name: 'externalid', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The id of the account in the external service.', + }, + { + displayName: 'Account Name', + name: 'name', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', + }, + { + displayName: 'Logo URL', + name: 'logoUrl', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The URL to a logo image for the external service.', + }, + { + displayName: 'Link URL', + name: 'linkUrl', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.', + }, + + // ---------------------------------- + // connection:update + // ---------------------------------- + { + displayName: 'Connection ID', + name: 'connectionId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'connection', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the connection to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'connection', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Service', + name: 'service', + type: 'string', + default: '', + description: 'The name of the service.', + }, + { + displayName: 'External accout ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the account in the external service.', + }, + { + displayName: 'Account Name', + name: 'name', + type: 'string', + default: '', + description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', + }, + { + displayName: 'Logo URL', + name: 'logoUrl', + type: 'string', + default: '', + description: 'The URL to a logo image for the external service.', + }, + { + displayName: 'Link URL', + name: 'linkUrl', + type: 'string', + default: '', + description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.', + }, + { + displayName: 'Status', + name: 'status', + type: 'number', + default: 1, + description: 'The status of the connection (0 = error; 1 = connected)', + }, + { + displayName: 'Syncronisation Status', + name: 'syncStatus', + type: 'number', + default: 1, + description: 'The status of a sync triggered on the connection (0 = sync stopped; 1 = sync running).', + }, + ] + }, + + // ---------------------------------- + // connection:delete + // ---------------------------------- + { + displayName: 'Connection ID', + name: 'connectionId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'connection', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the connection to delete.', + }, + + // ---------------------------------- + // connection:get + // ---------------------------------- + { + displayName: 'Connection ID', + name: 'connectionId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'connection', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the connection to get.', + }, + + // ---------------------------------- + // connection:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'connection', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'connection', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, +] as INodeProperties[]; \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts index 02c699e4b05..8b7a264c090 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts @@ -64,7 +64,7 @@ export const contactFields = [ ], }, }, - description: 'The email of the contact to create', + description: 'The email of the contact to create.', }, { displayName: 'Update if exists', @@ -105,14 +105,14 @@ export const contactFields = [ name: 'firstName', type: 'string', default: '', - description: 'The first name of the contact to create', + description: 'The first name of the contact to create.', }, { displayName: 'Last Name', name: 'lastName', type: 'string', default: '', - description: 'The last name of the contact to create', + description: 'The last name of the contact to create.', }, { displayName: 'Phone', @@ -208,14 +208,14 @@ export const contactFields = [ name: 'firstName', type: 'string', default: '', - description: 'First name of the contact', + description: 'First name of the contact.', }, { displayName: 'Last Name', name: 'lastName', type: 'string', default: '', - description: 'Last name of the contact', + description: 'Last name of the contact.', }, { displayName: 'Phone', diff --git a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts index dac1b0aa3d8..e5219177d7f 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts @@ -359,7 +359,7 @@ export const dealFields = [ ], }, }, - description: 'The ID of the deal', + description: 'The ID of the deal to delete.', }, // ---------------------------------- @@ -381,7 +381,7 @@ export const dealFields = [ ], }, }, - description: 'The ID of the deal', + description: 'The ID of the deal to get.', }, // ---------------------------------- diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts index 78c09afad86..f7f75e3fbb9 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts @@ -148,7 +148,7 @@ export const ecomCustomerFields = [ }, default: 0, required: true, - description: 'ID of the ecommerceCustomer to update.', + description: 'ID of the E-commerce customer to update.', }, { displayName: 'Update Fields', @@ -218,7 +218,7 @@ export const ecomCustomerFields = [ }, default: 0, required: true, - description: 'ID of the ecommerceCustomer to update.', + description: 'ID of the E-commerce customer to delete.', }, // ---------------------------------- @@ -240,7 +240,7 @@ export const ecomCustomerFields = [ }, default: 0, required: true, - description: 'ID of the ecommerceCustomer to update.', + description: 'ID of the E-commerce customer to get.', }, // ---------------------------------- From 5ca63830482931ec81ab3ff5e824eb026ac2282d Mon Sep 17 00:00:00 2001 From: quansenB Date: Sun, 3 Nov 2019 22:25:45 +0100 Subject: [PATCH 40/52] add deepdata integration connection support --- .../ActiveCampaign/ActiveCampaign.node.ts | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 1ae440fd0cf..a7b47f6e207 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -110,7 +110,7 @@ export class ActiveCampaign implements INodeType { { name: 'Connection', value: 'connection' - } + }, { name: 'E-commerce Order', value: 'ecommerceOrder', @@ -272,7 +272,9 @@ export class ActiveCampaign implements INodeType { endpoint = `/api/3/contacts/${contactId}`; dataKey = 'contact'; + body.contact = {} as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.contact as IDataObject, updateFields); @@ -401,21 +403,30 @@ export class ActiveCampaign implements INodeType { requestMethod = 'POST'; - const updateIfExists = this.getNodeParameter('updateIfExists', i) as boolean; - if (updateIfExists === true) { - endpoint = '/api/3/connection/sync'; - } else { - endpoint = '/api/3/connections'; - } - - dataKey = 'connection'; + endpoint = '/api/3/connections'; body.connection = { - email: this.getNodeParameter('email', i) as string, + service: this.getNodeParameter('service', i) as string, + externalid: this.getNodeParameter('externalid', i) as string, + name: this.getNodeParameter('name', i) as string, + logoUrl: this.getNodeParameter('logoUrl', i) as string, + linkUrl: this.getNodeParameter('linkUrl', i) as string, } as IDataObject; - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - addAdditionalFields(body.connection as IDataObject, additionalFields); + } else if (operation === 'update') { + // ---------------------------------- + // connection:update + // ---------------------------------- + + requestMethod = 'PUT'; + + const connectionId = this.getNodeParameter('connectionId', i) as number; + endpoint = `/api/3/connections/${connectionId}`; + + body.connection = {} as IDataObject; + + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + addAdditionalFields(body.connection as IDataObject, updateFields); } else if (operation === 'delete') { // ---------------------------------- @@ -449,24 +460,8 @@ export class ActiveCampaign implements INodeType { qs.limit = this.getNodeParameter('limit', i) as number; } - dataKey = 'connections'; endpoint = `/api/3/connections`; - } else if (operation === 'update') { - // ---------------------------------- - // connection:update - // ---------------------------------- - - requestMethod = 'PUT'; - - const connectionId = this.getNodeParameter('connectionId', i) as number; - endpoint = `/api/3/connections/${connectionId}`; - - dataKey = 'connection'; - body.connection = {} as IDataObject; - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - addAdditionalFields(body.connection as IDataObject, updateFields); - } else { throw new Error(`The operation "${operation}" is not known`); } From baf46f4d89ebb41ae1227dbde4422e0ed91a6d5a Mon Sep 17 00:00:00 2001 From: quansenB Date: Mon, 4 Nov 2019 00:00:59 +0100 Subject: [PATCH 41/52] finish connections work --- .../nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts index f8c7d1ede40..a3844fb1189 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts @@ -243,7 +243,7 @@ export const connectionFields = [ displayOptions: { show: { operation: [ - 'update', + 'delete', ], resource: [ 'connection', @@ -265,7 +265,7 @@ export const connectionFields = [ displayOptions: { show: { operation: [ - 'update', + 'get', ], resource: [ 'connection', From 6c1d1ade1458a6516b77030dc481ef873d7aae52 Mon Sep 17 00:00:00 2001 From: quansenB Date: Mon, 4 Nov 2019 00:21:57 +0100 Subject: [PATCH 42/52] tslint proof allcureencies file --- packages/nodes-base/nodes/utils/allCurrencies.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/utils/allCurrencies.ts b/packages/nodes-base/nodes/utils/allCurrencies.ts index 3fd41695d4a..2924edc3232 100644 --- a/packages/nodes-base/nodes/utils/allCurrencies.ts +++ b/packages/nodes-base/nodes/utils/allCurrencies.ts @@ -1,4 +1,4 @@ -[ +const allCurrencies = [ { name: 'Euro', value: 'eur' }, { name: 'United States Dollar', value: 'usd' }, { name: 'British Pound Sterling', value: 'gbp' }, @@ -170,4 +170,5 @@ { name: 'South African Rand', value: 'zar' }, { name: 'Zambian Kwacha', value: 'zmw' }, { name: 'Zimbabwean Dollar', value: 'zwl' } +// tslint:disable-next-line: semicolon ] \ No newline at end of file From f5648fd6e10dd51c33d83b35cf9d66e074eadf4d Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Tue, 5 Nov 2019 10:17:06 -0500 Subject: [PATCH 43/52] node-setup --- .../credentials/TodoistApi.credentials.ts | 18 ++++ .../nodes/Todoist/GenericFunctions.ts | 101 ++++++++++++++++++ .../nodes-base/nodes/Todoist/Todoist.node.ts | 90 ++++++++++++++++ packages/nodes-base/nodes/Todoist/todoist.png | Bin 0 -> 4475 bytes packages/nodes-base/package.json | 6 +- 5 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 packages/nodes-base/credentials/TodoistApi.credentials.ts create mode 100644 packages/nodes-base/nodes/Todoist/GenericFunctions.ts create mode 100644 packages/nodes-base/nodes/Todoist/Todoist.node.ts create mode 100644 packages/nodes-base/nodes/Todoist/todoist.png diff --git a/packages/nodes-base/credentials/TodoistApi.credentials.ts b/packages/nodes-base/credentials/TodoistApi.credentials.ts new file mode 100644 index 00000000000..cec053e40e9 --- /dev/null +++ b/packages/nodes-base/credentials/TodoistApi.credentials.ts @@ -0,0 +1,18 @@ +import { + ICredentialType, + NodePropertyTypes, +} from 'n8n-workflow'; + + +export class TodoistApi implements ICredentialType { + name = 'todoistApi'; + displayName = 'Todoist API'; + properties = [ + { + displayName: 'API Key', + name: 'apiKey', + type: 'string' as NodePropertyTypes, + default: '', + }, + ]; +} diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts new file mode 100644 index 00000000000..f98b54f1c77 --- /dev/null +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -0,0 +1,101 @@ +import { OptionsWithUri } from 'request'; + +import { + IExecuteFunctions, + IHookFunctions, + ILoadOptionsFunctions, + IExecuteSingleFunctions +} from 'n8n-core'; + +import * as _ from 'lodash'; +import { IDataObject } from 'n8n-workflow'; + +export async function mandrillApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resource: string, method: string, action: string, body: any = {}, headers?: object): Promise { // tslint:disable-line:no-any + const credentials = this.getCredentials('mandrillApi'); + + if (credentials === undefined) { + throw new Error('No credentials got returned!'); + } + + const data = Object.assign({}, body, { key: credentials.apiKey }); + + const endpoint = 'mandrillapp.com/api/1.0'; + + const options: OptionsWithUri = { + headers, + method, + uri: `https://${endpoint}${resource}${action}.json`, + body: data, + json: true + }; + + + try { + return await this.helpers.request!(options); + } catch (error) { + console.error(error); + + const errorMessage = error.response.body.message || error.response.body.Message; + if (error.name === 'Invalid_Key') { + throw new Error('The provided API key is not a valid Mandrill API key'); + } else if (error.name === 'ValidationError') { + throw new Error('The parameters passed to the API call are invalid or not provided when required'); + } else if (error.name === 'GeneralError') { + throw new Error('An unexpected error occurred processing the request. Mandrill developers will be notified.'); + } + + if (errorMessage !== undefined) { + throw errorMessage; + } + throw error.response.body; + } +} + +export function getToEmailArray(toEmail: string): any { // tslint:disable-line:no-any + let toEmailArray; + if (toEmail.split(',').length > 0) { + const array = toEmail.split(','); + toEmailArray = _.map(array, (email) => { + return { + email, + type: 'to' + }; + }); + } else { + toEmailArray = [{ + email: toEmail, + type: 'to' + }]; + } + return toEmailArray; +} + +export function getGoogleAnalyticsDomainsArray(s: string): string[] { + let array: string[] = []; + if (s.split(',').length > 0) { + array = s.split(','); + } else { + array = [s]; + } + return array; +} + +export function getTags(s: string): any[] { // tslint:disable-line:no-any + let array = []; + if (s.split(',').length > 0) { + array = s.split(','); + } else { + array = [s]; + } + return array; +} + +export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any + let result; + try { + result = JSON.parse(json!); + } catch (exception) { + result = []; + } + return result; +} diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts new file mode 100644 index 00000000000..b2f6b7dd220 --- /dev/null +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -0,0 +1,90 @@ +import { + IExecuteSingleFunctions, +} from 'n8n-core'; +import { + IDataObject, + INodeTypeDescription, + INodeExecutionData, + INodeType, + ILoadOptionsFunctions, + INodePropertyOptions, +} from 'n8n-workflow'; +import { + mandrillApiRequest, + getToEmailArray, + getGoogleAnalyticsDomainsArray, + getTags, + validateJSON +} from './GenericFunctions'; + +export class Todoist implements INodeType { + + //https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template + + description: INodeTypeDescription = { + displayName: 'Todoist', + name: 'todoist', + icon: 'file:todoist.png', + group: ['output'], + version: 1, + subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', + description: 'Consume Todoist API', + defaults: { + name: 'Todoist', + color: '#c02428', + }, + inputs: ['main'], + outputs: ['main'], + credentials: [ + { + name: 'todoistApi', + required: true, + } + ], + //multiOptions + properties: [ + { + displayName: 'Testing', + name: 'testing', + placeholder: 'blabla', + type: 'fixedCollection', + default: '', + typeOptions: { + multipleValues: true, + }, + options: [ + { + name: 'label', + displayName: 'label', + values: [ + { + displayName: 'Name', + name: 'name', + type: 'options', + default: '', + options: [ + { + name: 'Message', + value: 'message', + description: 'Send a message.', + }, + ], + }, + { + displayName: 'Content', + name: 'content', + type: 'string', + default: '', + }, + ], + }, + ], + }, + ], + }; + + async executeSingle(this: IExecuteSingleFunctions): Promise { + + + } +} diff --git a/packages/nodes-base/nodes/Todoist/todoist.png b/packages/nodes-base/nodes/Todoist/todoist.png new file mode 100644 index 0000000000000000000000000000000000000000..44691b2e49ded88dcdc5e60c893304c6d2643598 GIT binary patch literal 4475 zcmY*dXIK;3vJJf-dI>dv6s05(1c6Y6(0fOu2SabsAVsRw0E!q9q)JCAhmMV2rG^fn zg(9Me^v=a|@4N54{e83d%*8m%Lb8D2ffxd!^ueYR=tFJRcGRWKS z8hy2kV(P*?J8Y<}<@Bl0&FE0;gi2t8v{yphG+3Qi2sbS#% zKASSNe!GYb06_miM?=jVNrt~i<7YkrRNnafNNz?*H7J9f{-s*7#41r~y3`GAMBPIa zreW;$>}-u$-Fs>QP!}jM&v6sw@sPZPUXRbMc-C~w`bBm2EtVTZUS{55GQ`WQX@JMu z3q6}hczhD2LLwft-0JpgA!Jzo3Vqpga(T6_8(HiTBkUQ|LkP1d3iOAt$Gs?Ic>9t; z!MBZuZ}|KA044u@Ztj@E4>J6+t5b5`dE-QIAoq`|4A{`b+OGhKK#wuAg2la<6soPG2C3%itrqn05U2fDaQ*>mz0^soki;;lFAz4)r40${>uRJ9+dM z(?g>%7Ko1H_knth_JgsL%x-{Yt|k;ofqW3+r>k?)cgZB4rH1L$tdql!xR!(T zt;<;=L%1|}g*6k?6SjBZtEo8+Y4IpDU5wV#Vi-kU0`ZziNm8zeAyPkQ&3Q&*w=yZ0 z%}4WAFe6FP+3`BolBeaRkj~!cx|8EkOFi<9(l%%b2+aOI2i*a ztP3af)XoZ}V8{fAIrb%uZk3Z|p!*o^@-1uxLzFc0XAFDNwK>xzi@rnvW?dAwQ@zl= ziNAjbsTed0**hgC^)P=-jcy#uF3| zcSr@cEJVMI&Gs*%dn3qoRtgV9Io7kCo1^3_BNmk^P`>V?1B#2zB_y>fxk@c~{r+ya zL&f=z;BMG_qgNpUK9?rj^Q{NQ|20q{>Fcu5hras^j$;n?znq4{YWqJg-K>Wd_UY18 z`~|2Bq-eJe3Io}#gfeZ=ia%RdKeeBlqfOjj%4jKmbzbw?9NTqto}BzC^ugRc8%qfj z7a&j?90@0r&hWvw1XQd%#4sZtw?^pci_#nA@+zf=-!QS8`%1-cz4?A;^(^+=sV2mq z$jqpIP6L|e{y$~_6yHut?!TR?zz0 zUDmGA7~V{gq9)H6_f`KIUX8y2#Vf2$? z$T5Ejm{Rvch3@A9s%C~fU5;c1ii{f&g&u~&8xgaBQ|9@-j`NmoJa-(8Fb`PqR~L`> zIi{JHk5PJ?{GxCY%30r6H=kczdC-x1s&s@f>ScBLo^{!s05myyVy{s8`wmjXVNS7P zU%F}8lr+!t?;45@Bd0zlH67p%E}mo`UwHOh=d800PKhc9yv(SUpW#bE zUgPB<)25MMT$Zbza;T^_$V?cOfB-%NrSgIHGjb1Z8D!ogZY*Yqkaz5S^dYyb^|jpW+L?)~>761GcNdM_2Rd}O1w2tfQk7u^UNDv}r*Zos?v~E$A+uYr zs4ANa^YYyV6|3uq#83WC+g;8mbD*vzG?4MLo}247#jSbHm>J!P4MooDC7;bufaA~q+Yf1PP_GzTt8thBS*)ZImMrB#jyEa9jpES{utqYs>x1L-?`ts;MFPcp%jizu zR>`hSygmM#Y{ib8CPR}N?uh*OHEd@0W&vT`GsiAtab&tPsY#e?p#S_$18lItwxZuR z8myAx^6lhPnU(@KW#eDm#{KQ<%=EoOeVv#6Y4Vlnp3n0fzP=}2D)S$q$%pni0%P0a z#+iALRJ`w67hgH?Nc28uW0RGc3=k)N|Gsjvd~UW-U+WZaQ3Qod+8&>#KWPFmodZN) z@xD4w2{qz56Olgaq2R769l7F64Y^$=V^Y^H#~6cEBatFDihj#760XZp>cB^gCB2IC z?SDz;^MjF?@G!;7gz?CgPRHz)2}9+Xw)NDyKwDn!X&-re6PvnQ7lp&Oo==(dzk_;Z zL3ye4Cn<4JeLu{~O>p7(TC4Cc!qtbBl5#sH zDP0|@tQD^D`;XsHPXal>vg-pdA3 z`*Uh+ppNPtQHTgyouAc9B*g6{o_NV>X$)Jie|Noc-HwBr4_HQ))bZp@Y@j4KvyoT^ zCEIW_z}ZbN{zTxbcN`|DHPc(_SsrnK{s&}}H-b7Q&dAmzZDa1MQ%u-6)n-qN_< zx>FlFmrjG=?O-eSif$R1&mGIpjXAsvB)Fepm`iRrEZ|uUNp0~~Hqw(X0{BBwyrF!q z9VJg$?$9(#^Uj`7shK7A6(yqW##5|Q*$PXzbFq=erx58HsvURoZj6tKt1U}8z1|&H zR4)s~3lL3?ZT5Jb2)NV}rpw=(sPN&mUR-J{!J4OqUD`tRxUaon`P)zH98Jg~<5K^R z0NUq0>aRtrQHHG)%ImtmM_$344hs>Mdb^u(=B_XQu8A zO29_-|?9Bl{ng8qq1$7|7QQr&+Z+XDMYuGUpS{$ki-I zZBiX(0j(5TO>@Kzc*HDaq!p{ok9qE|IfmcZU7RY{uxW0{x-`mMVLu|Z+quvs-p6!v zjWv9Oa-O9R){FOkx@qj^XHPcPpojT7AD-+Yk(v=?*1|V{OSvI$oDnh;!M)H}D^b^)* zO(=E;`(1sZRREA9X7YSG{C5#o|I*d4orZAbi>y^FM1dm2In!@xPjm|UiyYU&u6j%x ze}yIJuwpyCJ zT8MXm#0rR~zS;a8TS(kf;;JO_*R}|k2<${~5OX5{8zoc|@jz;zeN3&H_A?1rykYtl zAtkz}h?iu{nB?BGpWLmu$TRA#N9SqTRCb`M1BzRf7RHUfDQd6dHhy=muo-K?PN0cn zMwju}Fl8vN$c}H4k|X0BPN(R^GJ8Ur2X+6FI3BL%bRV}EopKux$$o##H*}Z6;R&r> zD7l_YF9J9U#0)9qxj#3-1@l#dg;b$JfogOT@Ci~T>NVSeXo)zUqoLQ9qA&U=)H5$7 zwuiM3dV6$sp}PC>R>gA^fLxh7NA@HWS{KG+%H(rTxaH5>ygFW~MIJ@H>GaE)b!%8s zp;auqvN`!JNQ4v4cRyzj%fr~X!o|Bx-_mN2C?Bmswq0H$M`TX9)|9$7N)@8o#AsB# zA(E5%v@my<1bB~FdrCBwc-KWQfJF6)ASmXZvM^#T^0q|UyEgLio+uS2@=O8tw%7C_ zDr!lW3U78!I($?-hZ)7b4Ea4faH}KC4cdtPE@A&F2zM5epYFQBo9w!5=k3EukW|OF zcJd@6SR2|rYHn_-98X;xiW|yzYQIx9P1kJvOKz}C`}E{t%(v#KjHQUDD!cKIrVkt1 zPkC^mMZ0Jvz}yf`Q{iTWI*!T%K_p3bNqS3&MlAtS+{fUo-zW)$W E0tIwB)&Kwi literal 0 HcmV?d00001 diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 2b6ddeca773..6af0a99a5c1 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -56,7 +56,8 @@ "dist/credentials/TrelloApi.credentials.js", "dist/credentials/TwilioApi.credentials.js", "dist/credentials/TypeformApi.credentials.js", - "dist/credentials/MandrillApi.credentials.js" + "dist/credentials/MandrillApi.credentials.js", + "dist/credentials/TodoistApi.credentials.js" ], "nodes": [ "dist/nodes/ActiveCampaign/ActiveCampaign.node.js", @@ -122,7 +123,8 @@ "dist/nodes/WriteBinaryFile.node.js", "dist/nodes/Webhook.node.js", "dist/nodes/Xml.node.js", - "dist/nodes/Mandrill/Mandrill.node.js" + "dist/nodes/Mandrill/Mandrill.node.js", + "dist/nodes/Todoist/Todoist.node.js" ] }, "devDependencies": { From 39b1af94b99203a3bbe9e84dede9dd9d8f5e9833 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Tue, 5 Nov 2019 15:56:10 -0500 Subject: [PATCH 44/52] done --- .../nodes/Todoist/GenericFunctions.ts | 75 +----- .../nodes-base/nodes/Todoist/Todoist.node.ts | 243 +++++++++++++++--- packages/nodes-base/nodes/Todoist/todoist.png | Bin 4475 -> 8402 bytes 3 files changed, 212 insertions(+), 106 deletions(-) diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts index f98b54f1c77..3362a8581c0 100644 --- a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -10,39 +10,35 @@ import { import * as _ from 'lodash'; import { IDataObject } from 'n8n-workflow'; -export async function mandrillApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resource: string, method: string, action: string, body: any = {}, headers?: object): Promise { // tslint:disable-line:no-any - const credentials = this.getCredentials('mandrillApi'); +export async function todoistApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resource: string, method: string, body: any = {}, headers?: object): Promise { // tslint:disable-line:no-any + const credentials = this.getCredentials('todoistApi'); if (credentials === undefined) { throw new Error('No credentials got returned!'); } - const data = Object.assign({}, body, { key: credentials.apiKey }); + const headerWithAuthentication = Object.assign({}, headers, { Authorization: `Bearer ${credentials.apiKey}` }); - const endpoint = 'mandrillapp.com/api/1.0'; + const endpoint = 'api.todoist.com/rest/v1'; const options: OptionsWithUri = { - headers, + headers: headerWithAuthentication, method, - uri: `https://${endpoint}${resource}${action}.json`, - body: data, + body, + uri: `https://${endpoint}${resource}`, json: true }; + if (_.isEmpty(options.body)) { + delete options.body + } try { return await this.helpers.request!(options); } catch (error) { - console.error(error); + //console.error(error); const errorMessage = error.response.body.message || error.response.body.Message; - if (error.name === 'Invalid_Key') { - throw new Error('The provided API key is not a valid Mandrill API key'); - } else if (error.name === 'ValidationError') { - throw new Error('The parameters passed to the API call are invalid or not provided when required'); - } else if (error.name === 'GeneralError') { - throw new Error('An unexpected error occurred processing the request. Mandrill developers will be notified.'); - } if (errorMessage !== undefined) { throw errorMessage; @@ -50,52 +46,3 @@ export async function mandrillApiRequest(this: IHookFunctions | IExecuteFunction throw error.response.body; } } - -export function getToEmailArray(toEmail: string): any { // tslint:disable-line:no-any - let toEmailArray; - if (toEmail.split(',').length > 0) { - const array = toEmail.split(','); - toEmailArray = _.map(array, (email) => { - return { - email, - type: 'to' - }; - }); - } else { - toEmailArray = [{ - email: toEmail, - type: 'to' - }]; - } - return toEmailArray; -} - -export function getGoogleAnalyticsDomainsArray(s: string): string[] { - let array: string[] = []; - if (s.split(',').length > 0) { - array = s.split(','); - } else { - array = [s]; - } - return array; -} - -export function getTags(s: string): any[] { // tslint:disable-line:no-any - let array = []; - if (s.split(',').length > 0) { - array = s.split(','); - } else { - array = [s]; - } - return array; -} - -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any - let result; - try { - result = JSON.parse(json!); - } catch (exception) { - result = []; - } - return result; -} diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts index b2f6b7dd220..5484b987bc3 100644 --- a/packages/nodes-base/nodes/Todoist/Todoist.node.ts +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -10,16 +10,12 @@ import { INodePropertyOptions, } from 'n8n-workflow'; import { - mandrillApiRequest, - getToEmailArray, - getGoogleAnalyticsDomainsArray, - getTags, - validateJSON + todoistApiRequest } from './GenericFunctions'; -export class Todoist implements INodeType { +import moment = require('moment'); - //https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template +export class Todoist implements INodeType { description: INodeTypeDescription = { displayName: 'Todoist', @@ -41,50 +37,213 @@ export class Todoist implements INodeType { required: true, } ], - //multiOptions properties: [ - { - displayName: 'Testing', - name: 'testing', - placeholder: 'blabla', - type: 'fixedCollection', + { + displayName: 'Resource', + name: 'resource', + type: 'options', + options: [ + { + name: 'Task', + value: 'task', + description: 'Task resource.', + }, + ], default: '', - typeOptions: { - multipleValues: true, + required: true, + description: 'Resource to consume.', + }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + required: true, + displayOptions: { + show: { + resource: [ + 'task', + ], + }, }, options: [ { - name: 'label', - displayName: 'label', - values: [ - { - displayName: 'Name', - name: 'name', - type: 'options', - default: '', - options: [ - { - name: 'Message', - value: 'message', - description: 'Send a message.', - }, - ], - }, - { - displayName: 'Content', - name: 'content', - type: 'string', - default: '', - }, - ], + name: 'Create', + value: 'create', + description: 'Create a new task', }, ], - }, - ], - }; + default: 'create', + description: 'The operation to perform.', + }, + { + displayName: 'Project', + name: 'project', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getProjects', + }, + displayOptions: { + show: { + resource: [ + 'task', + ], + operation: [ + 'create' + ] + }, + }, + default: [], + description: 'The project you want to add the task to.', + }, + { + displayName: 'Content', + name: 'content', + type: 'string', + typeOptions: { + rows: 5, + }, + displayOptions: { + show: { + resource: [ + 'task', + ], + operation: [ + 'create' + ] + }, + }, + default: [], + required: true, + description: 'Task content', + }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Option', + default: {}, + displayOptions: { + show: { + resource: [ + 'task', + ], + operation: [ + 'create' + ] + }, + }, + options: [ + { + displayName: 'Priority', + name: 'priority', + type: 'number', + typeOptions: { + numberStepSize: 1, + maxValue: 4, + minValue: 1 + }, + default: 1, + description: 'Task priority from 1 (normal) to 4 (urgent).', + }, + { + displayName: 'Due Date Time', + name: 'dueDateTime', + type: 'dateTime', + default: '', + description: 'Specific date and time in RFC3339 format in UTC.', + }, + { + displayName: 'Due String', + name: 'dueString', + type: 'string', + default: '', + description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', + }, + ] + } + ] + }; + + + methods = { + loadOptions: { + // Get all the available projects to display them to user so that he can + // select them easily + async getProjects(this: ILoadOptionsFunctions): Promise { + const returnData: INodePropertyOptions[] = []; + let projects; + try { + projects = await todoistApiRequest.call(this, '/projects', 'GET'); + } catch (err) { + throw new Error(`Todoist Error: ${err}`); + } + for (const project of projects) { + const projectName = project.name; + const projectId = project.id; + + returnData.push({ + name: projectName, + value: projectId, + }); + } + + return returnData + } + }, + }; + async executeSingle(this: IExecuteSingleFunctions): Promise { - + const resource = this.getNodeParameter('resource') as string; + const opeation = this.getNodeParameter('operation') as string; + let response; + + if (resource === 'task' && opeation === 'create') { + + //https://developer.todoist.com/rest/v1/#create-a-new-task + + const content = this.getNodeParameter('content') as string; + const projectId = this.getNodeParameter('project') as number; + const options = this.getNodeParameter('options') as IDataObject; + + + interface IBodyCreateTask { + content: string; + project_id?: number; + parent?: number; + order?: number; + label_ids?: [number]; + priority?: number; + due_string?: string; + due_datetime?: string; + due_date?: string; + due_lang?: string; + } + + const body: IBodyCreateTask = { + content, + project_id: projectId, + priority: (options.priority!) ? parseInt(options.priority, 10) : 1, + } + + if (options.dueDateTime) { + body.due_datetime = moment(options.dueDateTime).utc().format() + } + + if (options.dueString) { + body.due_string = options.dueString + } + + try { + response = await todoistApiRequest.call(this, '/tasks', 'POST', body); + } catch (err) { + throw new Error(`Todoist Error: ${err}`); + } + } + + return { + json: response, + }; } } diff --git a/packages/nodes-base/nodes/Todoist/todoist.png b/packages/nodes-base/nodes/Todoist/todoist.png index 44691b2e49ded88dcdc5e60c893304c6d2643598..5ce577f317a669cf3f0cd6f569bbfbf6ffa7cbcf 100644 GIT binary patch literal 8402 zcmV;@AT8gCP)MBvqYm%^O7pL1}5a>3yy4 z>gw9}eaXsNx|>FjQD;VHeD91tJu}a392^HhKorpdlvQcj1|AB^rYJVOQPs6?S-Ec! z8JQ6oxy6>55xHm9eP8xHhdI8#j8iA;-WxY=eD`<1-*SI9YBuF!*d-`}tjehXFT~TD zn`Z*?P{NS82p3Pry_`Ry$w4{h5Q6bS*3WK4<4jx%u$(QK7QOy;NeRko$l+QlmNlz= zKBY$zGKcnTUP5Eqh>Ied5IOvhxE-ZJ%4F9aHocq^WpTr4QInF> zZ7Y=WHkZ>M4jG%3nf28|UJr6U{FREC<)v9diaxI+z*g$<`wGt@xPFNC>tO15vTWV2boa=YE-a@k_B z7={rJhXEZEuv)E~o13C2){qjhuR8dkn9b&$UQarwTU|CT#AI{nAmcTXn$xYNd_1WjZrb?c6!pAn^r#)h{Tk1 z)?#xP%7h7tu0Rm&7MA7HDI3p;M#{wpnTVJw7MxC}s;aUqL*9y_a91uMcDYl*g!BYB_feeZ!B_HB2ViJF$kR(L3sA~9xm_IIuv?MFZuCN$4 zvR*-C#VCM=LZN6h8i_<8REQZ92nK^_XIU0JL3@qe?I~0?y(|-si0O3FZMSU}vQj7* zaymEDM$qcmOlMUg9`djxM|^f)Ov|w0L_m~Ku=|4XWY!yu`1x2eS6Q`t@#|!Gbdb_{ zt0y4q1=*KSS*4UHGV3hK64$!dQ1kJa>h*C(uI%(Oa#D{(B`zT7=^W$Z;_*08f*yrJ z!Dh2%G8xPP&>;!G-w%FQK^F))Kl7fdqpCPIETmjnnSM_b1d=a#mR76eSy;)*>9U@m zzcf$EWZ7YlB(-QNx#D!>37KA5P8fPzPtUHevW!QZ9L&4mlD@%d&UFN{S`W7Z8iZ;@a9;rBVTIP#n;qm!(n( zEKej7HRl(m3#8%=`20RkIcHerW=W}}1qJuY8p-8tz+K*CJ&ecY#cLMkmNP}eAM`OH zf3BRJUzsbDlFRS(20SQSynF$_R@a7@2pa``X?+pZz?$6<69q-vSY9TiG`}#NEu>S1 zw6Hu)NPc;FrjXTQ0?W98*sv_mLh~TM_4Rc^$n5MacnosGXuPk8m{N^eNI4m2T#9H? zEW-FpnkKrunjq#>jSo~gAKSTnSY$L`e<$zrCoJhwtB zgmJTSR7uHchs8;X1a}jnl$25dFQ>#*=b9(27>T%Mcl)3}OO~}{I+aZ(ol7g5@ucKn zN@2AUH)4J(Y3S1e9JEfUyc3Up>>1`r`y zSP#g1Wn~4`OP4Oeir2UpPqADOLqW&V8W69%H(Sc&Kn!Pyg^Vvbmw?z6utQf03DG}) z8RK~Zuy~T9>&qJ(0AY2ztJYQ5=T=rqggE_vRuGDW;I5QPaY0dtCSu9-2IEu8xmB+% zp-ECS;$E>3qwHCtqB!Mo1-;0ZjXv7?9L{;*0 zfv6ZMBz5;HhNv*^s^)=T%YHi$yE#Wf@E5{d)@~(QvJwgAL;g}YP~aJqRcO5yH&}O; z^AbtSz>J6-QKFj1hIUkCzhg5Mj|H7+EtrVA)tDz4c2y*f#6p_gLefxtArK8alks^Y zu|~33WS|6Am}-z1dI`VTsfX>O6o|?PsYrdy`Xn*3K*<KeeOq=hrYe|y{}5o{Pf*_`CqBmURwV7 zL*d2qdXn=*ZR-g;zyS?@g)6QVf(Kjh3t>}rti~Shhyd>Zl&mL!$jPzhK-hqAPmtqm zlw$)PqO0o45&;V@E&l6G2Nzop{%+T`mmBshwH4ZeWZq) z>V5Tw51y~xX6ZSG!a~b|H?RGGz2n&VgInJ@v}LLL@M}A+nrqx?>!`i3Ym2R;@wdCT z{<`7te;(gceCK7t%;i0oz-CGbL{8v0fI`?%P0*T>8!a_rCcWl$r?Z7vMDkcYptaTF zNT?dDo5f|>EM>j3(?n6p;>LIO*3Ez6tE8`Y^)Y;9!NLt zA?6NL^X-SoR8O^YZx=aUOS&3KZzE}|B||Nwvz{~`Ax+0fXB+A6tei0W$NFAvJwV=h zi3n>T0HRQUg9`*bKoZy!OamH;nE-v&jbG;N(XwvyyZBgGDP+!B*Aock;t5+QoXF?r zU8`C)Oj16}eP6%SdAxLLiu7;E4BQkMKFW@D;$@z(Zr5b1^K{FaxxqW!of$e+I5I{W zrwZKz(VN>Yk8gkGYybH4EzK*p)F(!d#@idBql28OD`9StMjN>CcI#vZH`ZJnZacT_ zI{ufByJQZ52M_}~Y#dx*)w_8-U`0Be2DwqKIu|Atb8ud89kz30V}-kmcf?H{+(fhcRDc2f#Z62U2L$$J>C(VY%5Rp z%wLI0qO@G@WprUBe2;BHmY0w2uEiou0rRyXXOYr~OA7b1bU!pUh~ zjxmhR`-tFledimq&CRLK0gL%|muV_A+%5OjXM1W3J;#jxW_7s3xNSh3JmT!WCim&1 z>d9mChi-cBU?cg)PspRMg}Zv##+{IK^h6(fi^)3Bq>r}dJC7;-tpFVwZ!L~@P4B)z zfA)+fSM42S33)@z5H^iPtIkf6z!UHrGpR`-5?ZkoA_-EgTsnIW-eJw_jjL%rnS&)k z=;&W~k9e)*)nC1S_4Q=uxiiw+92n|}-ZB~+X_N4#HfPbsKUQM*fka_qO+>&wp-TW-u|#UA1D~Ur0NXvnL^pJ zzDhC*33<6Y?_4<2LQJ>Iw|$s9{V~_cL++Ek%(z+XA4&IiZw|MX#~Z`Lht4+KF#p*p z^2awxS|`P#ksI&rAQWA2EU+sIhY z%AW0o7oJO{Wr!9)L1;uvh?zhJy33-HhWM+J4kk5(q1D*R&qSoCoYU9bu9%Vx1w~0# zSy^-`emHBA=e0Lqc;mJcOFOnE+M7$Jp3Gn)bW53Na`qm5b>HsnkDns*4BV4i!tSI* z{EOoEzx11ZHEPo*$ z4%~%Yfg7#_Wgv#^Q3h7{8W_InCScj;)r?#;B*xiLCN2fto}#83f~2^GqL#5TE<_TG zGQvHcR0QIiB@ey&{B?&d`|HW%iAr<*xex!f{LTN9pPRu(U4Ken;k{CPYo9M9KJZKqiR(tDVJ(4{wA#-6D`_!OVHfrJ<$^$Y~1W_n)&!gLl6Jh!+Svnm<#M@u^j|N z0EK8l7>Jy1z^W#%qHlUuT?I8O$Kr5}abjHdZ3t>2m&*87Y(zDL4I5zt%1f`^b=6JE zXTC{RUMDh4pR+%3)qn|`94V9tbE0ab?MiSxBdi&`LqdQU&MSIg&1v{UB$3WP|K{Sr-!1GKe&vR1 zwSWIQx%4hkWWsXf*%$219dm#Ef!U8 zo?o(6$^ekE`8|9wo3Tduyo@R{4m#ov+~XAq-M-6TaSkG&EY{Pf%h_mGC$Nw1ll=yTR@37+WT z{{EEjWM8E9U{w*jn*-)9W~4zMXu7!dI_aT@B$fdUfE&UFP!u3$6rh)XMvn|33+oQ# zr82p!-Dgji4V%Lvg?N%Gte>5M$Y!joZY5MkcBr5eka+Q|^Pm6Wg#$PJ-|Mga_0=D- zjgFG%&XA~|Y|4dlyb$+g&%W*Y;#c0fanHghb`kTb%{%UYY3sF~{)6RD_xt-A?8BXI zQ%BO&n(3{N_BAn6Jv=<3xqEs44!ChWtsrLrSfB@@H$VhEpm~T<|4b3*{Q)6m2;mqK zyvbNZ@Vd*f#3mcbturJ;78aNNL_e2dU-Dmc6@vyzl`2qB2YLN5<}0^np1cncutDSq z$!AEZ>~;F@{m$#hcE9}b8pmJ*`Pui0V~HeL;(cfSwt8>(uENRD@aTYNur)T`k~CjY z#8bWeNK?7LWoFyQ`NtmiMOm0Uh!&a$LIWuD67v54O`cSc-9dj+FY+PH>3}gN8}kdf zm{?Sz>-IGTNi*MiO5=s+p7c+c$(d(>J5MU|CW#Ot5E8FyTaj4S$sPZ$9ju+HskwXv zy7*Yx9V?eeD2YzX3}lX@tcPI z!C#*-GS!V1P3!_U5IY2m^{!!qoU>2AL9{KNuGcDW3DVIoK)ey;L!%8OeFS zD@uw|j9Yv3#}8ip0bA{%0?`u$|nYtQ)5D3U&>@whWlfKP5SWhV&~CHZ}*>e9+00nLqcJi znFcAQkJpD_bCrAj2hiEu}KvV6i|Jm))2W$?1f5 zkw5(^^Z7g8y{T?y%hu@8J>r4uX1CN#_wLI6>Oqp@3lKkoB~>REFL=KAsb>$=ES}uy z80nQynv$bEk)C>Ss7V~@iu88Ny}j~aS8SkOAFeBP*OI>Ob9)bHzxX8)1;`je1$6iq zXdd9wJTG_xCSJaL8A@5R&M)Ol$*7BoSUC8C*;R{73a&)R>Gy))i(xgmFRi0E^dDHf!|-h%hA^m`dpj!@Ae6w z9$RVN74EAo+}gzrAM_5?CMJ8}Wn!jg-gHG8(=Z6}8w|86ksfV(H1BhWCXtHK` zc^Uc#V*=b@IS``}_M|47_FM7U zw@GwEAW+T}VWQ=iFPDFBB|4lvl0<}vBKfaZU)y$YaqCX<$;rrM)5^#W%WVf1`u1sm z)1#d@&i33GnW~L`5eS`SzA!!^@6DW>Cs2NH_{&c z#SfCHg)-qvB#AxFX88(Ue{u88#p&Dr{>+xEgC|;z&vm&5w{jEv;+avj4IYb*q45}N+8dwTlOEocH#hzM$aeAhpXDVFC=1cj11>-Wp&@us z95bQ$G048g%UcssUS=XmE|t+L7Pl`+3jR0~2>Y@b9fvHstS4RWjmIAT{mmn<)$RJj zSZ(H&2Z^=;yGJygykjl@?}yHRs8;J6iw5vd}A!4NG?*3hJS z)gzvL_ie;#oL6AIv0Q=7Ew5Kdfe+XMegxCTv}LA1(nZ#?_T_(2dOOL{qp7;%#5AI` z)y{3Jv9w$lxwS5Qx}F_4oEU6R4GgQDqgvmDG%&&UjYdaI;lV+-*&G<^mqrI5Z+^1h zG1B8VkNHPT_MyJ;XU2uo-QmGz2c?NZkzx4abh1L3QT> zhvsrPgKR9V5t}2VXG=KA)TJOPDsw9rulfM#?9qo#7<~ZOm_6OX z+`jMPZP)+dmTTEBw1!6-%LAi&^N7-aDlm4+Ix@_iGP9<>z*x69)P~GPe4rXe`$wDk z@!pWBmmO zA*9J_iDCJq98cf`&bf>rY2LRkW+NoU^FO$2dh7M1r%&oK$$cZ~lcV;bgG*C8ET7%u z|J>n~_7CYphf2Nm`JN^uZi1$EcDxM<4RNel9-)d#`90=?j>LXcWJOe&sk6fr|CH&=w1y?E&eqnEhDQG0qK=0 zXho5tJQL=;I6?^}m4FhHd2jKZH-6Vx7i?>)U_(AI7#ZyejkJ|NHEawb0a;5X8!Myx zll|K&69@7Gy9)h#H_dg@;68ckm}Y7yjMQ!R@82BWr;qMSn(NS#HeoV##ZNWKL)(fy z+jH#)F7Dq>7B7;Z{VxJ-5Z&t85E!8#SG-ni87f|mm6VvFr)*YNB2}<5JO(0BL3!?p zH%v$c?VLHhZ=tcy(cZqX^8mNwU|`2C+x~4!ZQC!le{7{^i>u+fz|k#i<4yC8H=gg= zd9ma0Qrm%*8 z{)_1G>g+28>{mTZ)F~1JDVz;hUQa0Ca(jzeVs}I`IIavyVa7|6y!+RW=U@0Kd+#00 zo&Og7-aWCq?~{Mi!9sVq<$5V{vt(G ziL&lps%}sG5@+QRW-d6LIAK?k8J{bfNs-l!c+4QYEV-S?Q$+;pSt5CfDu|cgB_-Vz zu-ZkhoJ;Z8-590Nx+9-X>zTB}xj}MS)!{Bgcp~yRrX`{;$8HoNT#9A#98dCwclA6e z#)xYTagrL*-;@f^BLVT3m^@5^p4fpmbZdYqf;~6|!z|%N(G@F#XOJkNtipOx*NVGT z9;l)nedt|8IS?2|#v||N@v+?aMIQ(fATU1e(yusZ{D~?WaSLxm6}V}3hJJ{EMmj8J zRfBh+A07kf*p-WB+kuG&g!G&S^hY=Jp$8v$3LWr^TaW~n4BhA{4qgB$U`^2(cWD4b z)66u-MO_`raB>h9eJKj4(%depbWe`a=(BXIix#w3kK`}}ojrs^Gdj3ON1+Ew(17Y; zzoI~L@8_v75T3%y;4W2gT3uaTML33uL1q|`N{C7UbHmDDd^Dnpc2vPs=E{WvT~*+w z0>bO?B0LKu5D)}RPY9~k123bWC(wWu86AvEr-e>SOG{`(@(*LtXXtqXMh7?~UZELO z-?5JLoR7w3bSp|}fHEFmt{&)D&o*(Feg}bPF-hghg#xPd;|R(Jnr@`KaUcd)r>Cds z2sMxg$c|9};{9DFoB+8fg2DL zCIBQ<@#slFl^&1*CI>X=9lmnWchG1M52J;CnS*Y0M6}~6bigk~gE?SaJcvg8Qq`eG z31w<+sDjefr$?G#APtnMj8H`*9z>NEsOC|E1*Yal<$eE_0qKkyhsLsax65AVP; zm?GFoqg$%cXvAGgdQ>5PYV|PA`)Y(ndNzeBh(SdK0b%~sz|oC2E)=K{q9}+HPqRl2mJ_#g2147JthFX#A~QYhAQA0EG12}0R*&%auFTyR?q_k3tqYC zmpoJ=K!exQ%s%)AK$td$f~vsDQAI=nRhliJ_8aLXIs#Ubu0NgXm1K=1QL~TU6!E+7 zz6(GAfv<5WCi?XS{0`dHmc2z}5KXrQ$;bxXhM0ciB0Uqkq> zTqvN5M%;pcfaiTNQO%}Y0$r=I2ep3?KGq1G@Fdkd%#Q-4(xOX-c51~SoAb#^qpR6YEp3M*W>sFvUc z)eow6)OFD`CXE=W>!Dv((idYOx(M`HbO17pKp&wxL-h|2(yt0IAjXHJXiAq_0yJU- oyaM>>!8k2rWXyraBpCMp0okPjZu)q$t^fc407*qoM6N<$f_Nw|7ytkO literal 4475 zcmY*dXIK;3vJJf-dI>dv6s05(1c6Y6(0fOu2SabsAVsRw0E!q9q)JCAhmMV2rG^fn zg(9Me^v=a|@4N54{e83d%*8m%Lb8D2ffxd!^ueYR=tFJRcGRWKS z8hy2kV(P*?J8Y<}<@Bl0&FE0;gi2t8v{yphG+3Qi2sbS#% zKASSNe!GYb06_miM?=jVNrt~i<7YkrRNnafNNz?*H7J9f{-s*7#41r~y3`GAMBPIa zreW;$>}-u$-Fs>QP!}jM&v6sw@sPZPUXRbMc-C~w`bBm2EtVTZUS{55GQ`WQX@JMu z3q6}hczhD2LLwft-0JpgA!Jzo3Vqpga(T6_8(HiTBkUQ|LkP1d3iOAt$Gs?Ic>9t; z!MBZuZ}|KA044u@Ztj@E4>J6+t5b5`dE-QIAoq`|4A{`b+OGhKK#wuAg2la<6soPG2C3%itrqn05U2fDaQ*>mz0^soki;;lFAz4)r40${>uRJ9+dM z(?g>%7Ko1H_knth_JgsL%x-{Yt|k;ofqW3+r>k?)cgZB4rH1L$tdql!xR!(T zt;<;=L%1|}g*6k?6SjBZtEo8+Y4IpDU5wV#Vi-kU0`ZziNm8zeAyPkQ&3Q&*w=yZ0 z%}4WAFe6FP+3`BolBeaRkj~!cx|8EkOFi<9(l%%b2+aOI2i*a ztP3af)XoZ}V8{fAIrb%uZk3Z|p!*o^@-1uxLzFc0XAFDNwK>xzi@rnvW?dAwQ@zl= ziNAjbsTed0**hgC^)P=-jcy#uF3| zcSr@cEJVMI&Gs*%dn3qoRtgV9Io7kCo1^3_BNmk^P`>V?1B#2zB_y>fxk@c~{r+ya zL&f=z;BMG_qgNpUK9?rj^Q{NQ|20q{>Fcu5hras^j$;n?znq4{YWqJg-K>Wd_UY18 z`~|2Bq-eJe3Io}#gfeZ=ia%RdKeeBlqfOjj%4jKmbzbw?9NTqto}BzC^ugRc8%qfj z7a&j?90@0r&hWvw1XQd%#4sZtw?^pci_#nA@+zf=-!QS8`%1-cz4?A;^(^+=sV2mq z$jqpIP6L|e{y$~_6yHut?!TR?zz0 zUDmGA7~V{gq9)H6_f`KIUX8y2#Vf2$? z$T5Ejm{Rvch3@A9s%C~fU5;c1ii{f&g&u~&8xgaBQ|9@-j`NmoJa-(8Fb`PqR~L`> zIi{JHk5PJ?{GxCY%30r6H=kczdC-x1s&s@f>ScBLo^{!s05myyVy{s8`wmjXVNS7P zU%F}8lr+!t?;45@Bd0zlH67p%E}mo`UwHOh=d800PKhc9yv(SUpW#bE zUgPB<)25MMT$Zbza;T^_$V?cOfB-%NrSgIHGjb1Z8D!ogZY*Yqkaz5S^dYyb^|jpW+L?)~>761GcNdM_2Rd}O1w2tfQk7u^UNDv}r*Zos?v~E$A+uYr zs4ANa^YYyV6|3uq#83WC+g;8mbD*vzG?4MLo}247#jSbHm>J!P4MooDC7;bufaA~q+Yf1PP_GzTt8thBS*)ZImMrB#jyEa9jpES{utqYs>x1L-?`ts;MFPcp%jizu zR>`hSygmM#Y{ib8CPR}N?uh*OHEd@0W&vT`GsiAtab&tPsY#e?p#S_$18lItwxZuR z8myAx^6lhPnU(@KW#eDm#{KQ<%=EoOeVv#6Y4Vlnp3n0fzP=}2D)S$q$%pni0%P0a z#+iALRJ`w67hgH?Nc28uW0RGc3=k)N|Gsjvd~UW-U+WZaQ3Qod+8&>#KWPFmodZN) z@xD4w2{qz56Olgaq2R769l7F64Y^$=V^Y^H#~6cEBatFDihj#760XZp>cB^gCB2IC z?SDz;^MjF?@G!;7gz?CgPRHz)2}9+Xw)NDyKwDn!X&-re6PvnQ7lp&Oo==(dzk_;Z zL3ye4Cn<4JeLu{~O>p7(TC4Cc!qtbBl5#sH zDP0|@tQD^D`;XsHPXal>vg-pdA3 z`*Uh+ppNPtQHTgyouAc9B*g6{o_NV>X$)Jie|Noc-HwBr4_HQ))bZp@Y@j4KvyoT^ zCEIW_z}ZbN{zTxbcN`|DHPc(_SsrnK{s&}}H-b7Q&dAmzZDa1MQ%u-6)n-qN_< zx>FlFmrjG=?O-eSif$R1&mGIpjXAsvB)Fepm`iRrEZ|uUNp0~~Hqw(X0{BBwyrF!q z9VJg$?$9(#^Uj`7shK7A6(yqW##5|Q*$PXzbFq=erx58HsvURoZj6tKt1U}8z1|&H zR4)s~3lL3?ZT5Jb2)NV}rpw=(sPN&mUR-J{!J4OqUD`tRxUaon`P)zH98Jg~<5K^R z0NUq0>aRtrQHHG)%ImtmM_$344hs>Mdb^u(=B_XQu8A zO29_-|?9Bl{ng8qq1$7|7QQr&+Z+XDMYuGUpS{$ki-I zZBiX(0j(5TO>@Kzc*HDaq!p{ok9qE|IfmcZU7RY{uxW0{x-`mMVLu|Z+quvs-p6!v zjWv9Oa-O9R){FOkx@qj^XHPcPpojT7AD-+Yk(v=?*1|V{OSvI$oDnh;!M)H}D^b^)* zO(=E;`(1sZRREA9X7YSG{C5#o|I*d4orZAbi>y^FM1dm2In!@xPjm|UiyYU&u6j%x ze}yIJuwpyCJ zT8MXm#0rR~zS;a8TS(kf;;JO_*R}|k2<${~5OX5{8zoc|@jz;zeN3&H_A?1rykYtl zAtkz}h?iu{nB?BGpWLmu$TRA#N9SqTRCb`M1BzRf7RHUfDQd6dHhy=muo-K?PN0cn zMwju}Fl8vN$c}H4k|X0BPN(R^GJ8Ur2X+6FI3BL%bRV}EopKux$$o##H*}Z6;R&r> zD7l_YF9J9U#0)9qxj#3-1@l#dg;b$JfogOT@Ci~T>NVSeXo)zUqoLQ9qA&U=)H5$7 zwuiM3dV6$sp}PC>R>gA^fLxh7NA@HWS{KG+%H(rTxaH5>ygFW~MIJ@H>GaE)b!%8s zp;auqvN`!JNQ4v4cRyzj%fr~X!o|Bx-_mN2C?Bmswq0H$M`TX9)|9$7N)@8o#AsB# zA(E5%v@my<1bB~FdrCBwc-KWQfJF6)ASmXZvM^#T^0q|UyEgLio+uS2@=O8tw%7C_ zDr!lW3U78!I($?-hZ)7b4Ea4faH}KC4cdtPE@A&F2zM5epYFQBo9w!5=k3EukW|OF zcJd@6SR2|rYHn_-98X;xiW|yzYQIx9P1kJvOKz}C`}E{t%(v#KjHQUDD!cKIrVkt1 zPkC^mMZ0Jvz}yf`Q{iTWI*!T%K_p3bNqS3&MlAtS+{fUo-zW)$W E0tIwB)&Kwi From 9d50fb0c3361eceb3ac98a6f75da2c2aaa5db551 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Tue, 5 Nov 2019 18:50:55 -0500 Subject: [PATCH 45/52] done --- .../nodes-base/nodes/Todoist/Todoist.node.ts | 68 ++++++++++++++++--- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts index 5484b987bc3..db585c3e996 100644 --- a/packages/nodes-base/nodes/Todoist/Todoist.node.ts +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -14,6 +14,7 @@ import { } from './GenericFunctions'; import moment = require('moment'); +import _ = require('lodash') export class Todoist implements INodeType { @@ -94,6 +95,27 @@ export class Todoist implements INodeType { }, default: [], description: 'The project you want to add the task to.', + }, + { + displayName: 'Labels', + name: 'labels', + type: 'multiOptions', + typeOptions: { + loadOptionsMethod: 'getLabels', + }, + displayOptions: { + show: { + resource: [ + 'task', + ], + operation: [ + 'create' + ] + }, + }, + default: [], + required: false, + description: 'Labels', }, { displayName: 'Content', @@ -115,7 +137,7 @@ export class Todoist implements INodeType { default: [], required: true, description: 'Task content', - }, + }, { displayName: 'Options', name: 'options', @@ -187,12 +209,34 @@ export class Todoist implements INodeType { }); } + return returnData + }, + + // Get all the available labels to display them to user so that he can + // select them easily + async getLabels(this: ILoadOptionsFunctions): Promise { + const returnData: INodePropertyOptions[] = []; + let labels; + try { + labels = await todoistApiRequest.call(this, '/labels', 'GET'); + } catch (err) { + throw new Error(`Todoist Error: ${err}`); + } + for (const label of labels) { + const labelName = label.name; + const labelId = label.id; + + returnData.push({ + name: labelName, + value: labelId, + }); + } + return returnData } - }, + } }; - async executeSingle(this: IExecuteSingleFunctions): Promise { const resource = this.getNodeParameter('resource') as string; @@ -205,9 +249,9 @@ export class Todoist implements INodeType { const content = this.getNodeParameter('content') as string; const projectId = this.getNodeParameter('project') as number; + const labels = this.getNodeParameter('labels') as [number]; const options = this.getNodeParameter('options') as IDataObject; - interface IBodyCreateTask { content: string; project_id?: number; @@ -224,17 +268,23 @@ export class Todoist implements INodeType { const body: IBodyCreateTask = { content, project_id: projectId, - priority: (options.priority!) ? parseInt(options.priority, 10) : 1, - } + priority: (options.priority!) ? parseInt(options.priority as string, 10) : 1, + }; if (options.dueDateTime) { - body.due_datetime = moment(options.dueDateTime).utc().format() + body.due_datetime = moment(options.dueDateTime as string).utc().format(); } if (options.dueString) { - body.due_string = options.dueString + body.due_string = options.dueString as string; } + if (!_.isEmpty(labels)) { + body.label_ids = labels + } + + console.log(labels) + try { response = await todoistApiRequest.call(this, '/tasks', 'POST', body); } catch (err) { @@ -243,7 +293,7 @@ export class Todoist implements INodeType { } return { - json: response, + json: response }; } } From 4e1ac1eb2f3eccf6d1a487f18defe70bd1007d75 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Tue, 5 Nov 2019 18:57:04 -0500 Subject: [PATCH 46/52] removed console.log --- packages/nodes-base/nodes/Todoist/Todoist.node.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts index db585c3e996..71eaa9b3d21 100644 --- a/packages/nodes-base/nodes/Todoist/Todoist.node.ts +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -283,8 +283,6 @@ export class Todoist implements INodeType { body.label_ids = labels } - console.log(labels) - try { response = await todoistApiRequest.call(this, '/tasks', 'POST', body); } catch (err) { From 47856f236e2c994319ce88d1ec9b3ecc64986070 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 7 Nov 2019 08:40:12 +0100 Subject: [PATCH 47/52] :zap: Fixed some lint and cosmetic issues --- .../nodes/Todoist/GenericFunctions.ts | 8 +- .../nodes-base/nodes/Todoist/Todoist.node.ts | 148 +++++++++--------- 2 files changed, 74 insertions(+), 82 deletions(-) diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts index 3362a8581c0..9532fabd487 100644 --- a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -8,7 +8,6 @@ import { } from 'n8n-core'; import * as _ from 'lodash'; -import { IDataObject } from 'n8n-workflow'; export async function todoistApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resource: string, method: string, body: any = {}, headers?: object): Promise { // tslint:disable-line:no-any const credentials = this.getCredentials('todoistApi'); @@ -24,20 +23,17 @@ export async function todoistApiRequest(this: IHookFunctions | IExecuteFunctions const options: OptionsWithUri = { headers: headerWithAuthentication, method, - body, uri: `https://${endpoint}${resource}`, json: true }; - if (_.isEmpty(options.body)) { - delete options.body + if (Object.keys(body).length !== 0) { + options.body = body; } try { return await this.helpers.request!(options); } catch (error) { - //console.error(error); - const errorMessage = error.response.body.message || error.response.body.Message; if (errorMessage !== undefined) { diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts index 71eaa9b3d21..54264a33f69 100644 --- a/packages/nodes-base/nodes/Todoist/Todoist.node.ts +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -10,11 +10,22 @@ import { INodePropertyOptions, } from 'n8n-workflow'; import { - todoistApiRequest + todoistApiRequest, } from './GenericFunctions'; -import moment = require('moment'); -import _ = require('lodash') + +interface IBodyCreateTask { + content: string; + project_id?: number; + parent?: number; + order?: number; + label_ids?: number[]; + priority?: number; + due_string?: string; + due_datetime?: string; + due_date?: string; + due_lang?: string; +} export class Todoist implements INodeType { @@ -37,9 +48,9 @@ export class Todoist implements INodeType { name: 'todoistApi', required: true, } - ], + ], properties: [ - { + { displayName: 'Resource', name: 'resource', type: 'options', @@ -50,7 +61,7 @@ export class Todoist implements INodeType { description: 'Task resource.', }, ], - default: '', + default: 'task', required: true, description: 'Resource to consume.', }, @@ -75,22 +86,22 @@ export class Todoist implements INodeType { ], default: 'create', description: 'The operation to perform.', - }, - { + }, + { displayName: 'Project', name: 'project', - type: 'options', - typeOptions: { + type: 'options', + typeOptions: { loadOptionsMethod: 'getProjects', }, displayOptions: { show: { resource: [ 'task', - ], - operation: [ - 'create' - ] + ], + operation: [ + 'create', + ] }, }, default: [], @@ -107,38 +118,38 @@ export class Todoist implements INodeType { show: { resource: [ 'task', - ], - operation: [ - 'create' - ] + ], + operation: [ + 'create', + ] }, }, - default: [], - required: false, + default: [], + required: false, description: 'Labels', - }, - { + }, + { displayName: 'Content', name: 'content', - type: 'string', - typeOptions: { + type: 'string', + typeOptions: { rows: 5, }, displayOptions: { show: { resource: [ 'task', - ], - operation: [ - 'create' - ] + ], + operation: [ + 'create', + ] }, }, - default: [], - required: true, + default: [], + required: true, description: 'Task content', }, - { + { displayName: 'Options', name: 'options', type: 'collection', @@ -148,46 +159,46 @@ export class Todoist implements INodeType { show: { resource: [ 'task', - ], - operation: [ - 'create' - ] + ], + operation: [ + 'create', + ] }, }, options: [ { displayName: 'Priority', name: 'priority', - type: 'number', - typeOptions: { - numberStepSize: 1, - maxValue: 4, - minValue: 1 - }, + type: 'number', + typeOptions: { + numberStepSize: 1, + maxValue: 4, + minValue: 1, + }, default: 1, description: 'Task priority from 1 (normal) to 4 (urgent).', - }, - { + }, + { displayName: 'Due Date Time', name: 'dueDateTime', - type: 'dateTime', + type: 'dateTime', default: '', description: 'Specific date and time in RFC3339 format in UTC.', }, { displayName: 'Due String', name: 'dueString', - type: 'string', + type: 'string', default: '', description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', }, - ] - } - ] - }; - + ] + } + ] + }; - methods = { + + methods = { loadOptions: { // Get all the available projects to display them to user so that he can // select them easily @@ -209,7 +220,7 @@ export class Todoist implements INodeType { }); } - return returnData + return returnData; }, // Get all the available labels to display them to user so that he can @@ -232,39 +243,24 @@ export class Todoist implements INodeType { }); } - return returnData + return returnData; } } - }; - + }; + async executeSingle(this: IExecuteSingleFunctions): Promise { - + const resource = this.getNodeParameter('resource') as string; const opeation = this.getNodeParameter('operation') as string; let response; if (resource === 'task' && opeation === 'create') { - - //https://developer.todoist.com/rest/v1/#create-a-new-task - + //https://developer.todoist.com/rest/v1/#create-a-new-task const content = this.getNodeParameter('content') as string; const projectId = this.getNodeParameter('project') as number; - const labels = this.getNodeParameter('labels') as [number]; + const labels = this.getNodeParameter('labels') as number[]; const options = this.getNodeParameter('options') as IDataObject; - interface IBodyCreateTask { - content: string; - project_id?: number; - parent?: number; - order?: number; - label_ids?: [number]; - priority?: number; - due_string?: string; - due_datetime?: string; - due_date?: string; - due_lang?: string; - } - const body: IBodyCreateTask = { content, project_id: projectId, @@ -272,15 +268,15 @@ export class Todoist implements INodeType { }; if (options.dueDateTime) { - body.due_datetime = moment(options.dueDateTime as string).utc().format(); + body.due_datetime = options.dueDateTime as string; } if (options.dueString) { body.due_string = options.dueString as string; } - if (!_.isEmpty(labels)) { - body.label_ids = labels + if (labels !== undefined && labels.length !== 0) { + body.label_ids = labels; } try { From 74d1f249810fc6596c7b49b133ec22d203e63567 Mon Sep 17 00:00:00 2001 From: quansenB Date: Thu, 7 Nov 2019 10:50:02 +0100 Subject: [PATCH 48/52] change spaces to tabs --- .../ActiveCampaign/ConnectionDescription.ts | 620 ++++---- .../ActiveCampaign/ContactDescription.ts | 680 ++++---- .../nodes/ActiveCampaign/DealDescription.ts | 1022 ++++++------ .../ActiveCampaign/EcomCustomerDescription.ts | 558 +++---- .../ActiveCampaign/EcomOrderDescription.ts | 1394 ++++++++--------- .../EcomOrderProductsDescription.ts | 230 +-- 6 files changed, 2252 insertions(+), 2252 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts index a3844fb1189..2b82d6bebbb 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts @@ -3,322 +3,322 @@ import { INodeProperties } from "n8n-workflow"; import { allCurrencies } from './currencies'; export const connectionOperations = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'connection', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a connection', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a connection', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a connection', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all connections', - }, - { - name: 'Update', - value: 'update', - description: 'Update a connection', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'connection', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a connection', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a connection', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a connection', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all connections', + }, + { + name: 'Update', + value: 'update', + description: 'Update a connection', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, ] as INodeProperties[]; export const connectionFields = [ - // ---------------------------------- - // connection:create - // ---------------------------------- - { - displayName: 'Service', - name: 'service', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], - }, - }, - description: 'The name of the service.', - }, - { - displayName: 'External accout ID', - name: 'externalid', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], - }, - }, - description: 'The id of the account in the external service.', - }, - { - displayName: 'Account Name', - name: 'name', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], - }, - }, - description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', - }, - { - displayName: 'Logo URL', - name: 'logoUrl', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], - }, - }, - description: 'The URL to a logo image for the external service.', - }, - { - displayName: 'Link URL', - name: 'linkUrl', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], - }, - }, - description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.', - }, + // ---------------------------------- + // connection:create + // ---------------------------------- + { + displayName: 'Service', + name: 'service', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The name of the service.', + }, + { + displayName: 'External accout ID', + name: 'externalid', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The id of the account in the external service.', + }, + { + displayName: 'Account Name', + name: 'name', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', + }, + { + displayName: 'Logo URL', + name: 'logoUrl', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The URL to a logo image for the external service.', + }, + { + displayName: 'Link URL', + name: 'linkUrl', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'connection', + ], + }, + }, + description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.', + }, - // ---------------------------------- - // connection:update - // ---------------------------------- - { - displayName: 'Connection ID', - name: 'connectionId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'connection', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the connection to update.', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - description: 'The fields to update.', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'connection', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Service', - name: 'service', - type: 'string', - default: '', - description: 'The name of the service.', - }, - { - displayName: 'External accout ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the account in the external service.', - }, - { - displayName: 'Account Name', - name: 'name', - type: 'string', - default: '', - description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', - }, - { - displayName: 'Logo URL', - name: 'logoUrl', - type: 'string', - default: '', - description: 'The URL to a logo image for the external service.', - }, - { - displayName: 'Link URL', - name: 'linkUrl', - type: 'string', - default: '', - description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.', - }, - { - displayName: 'Status', - name: 'status', - type: 'number', - default: 1, - description: 'The status of the connection (0 = error; 1 = connected)', - }, - { - displayName: 'Syncronisation Status', - name: 'syncStatus', - type: 'number', - default: 1, - description: 'The status of a sync triggered on the connection (0 = sync stopped; 1 = sync running).', - }, - ] - }, + // ---------------------------------- + // connection:update + // ---------------------------------- + { + displayName: 'Connection ID', + name: 'connectionId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'connection', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the connection to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'connection', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Service', + name: 'service', + type: 'string', + default: '', + description: 'The name of the service.', + }, + { + displayName: 'External accout ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the account in the external service.', + }, + { + displayName: 'Account Name', + name: 'name', + type: 'string', + default: '', + description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', + }, + { + displayName: 'Logo URL', + name: 'logoUrl', + type: 'string', + default: '', + description: 'The URL to a logo image for the external service.', + }, + { + displayName: 'Link URL', + name: 'linkUrl', + type: 'string', + default: '', + description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.', + }, + { + displayName: 'Status', + name: 'status', + type: 'number', + default: 1, + description: 'The status of the connection (0 = error; 1 = connected)', + }, + { + displayName: 'Syncronisation Status', + name: 'syncStatus', + type: 'number', + default: 1, + description: 'The status of a sync triggered on the connection (0 = sync stopped; 1 = sync running).', + }, + ] + }, - // ---------------------------------- - // connection:delete - // ---------------------------------- - { - displayName: 'Connection ID', - name: 'connectionId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'connection', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the connection to delete.', - }, + // ---------------------------------- + // connection:delete + // ---------------------------------- + { + displayName: 'Connection ID', + name: 'connectionId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'connection', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the connection to delete.', + }, - // ---------------------------------- - // connection:get - // ---------------------------------- - { - displayName: 'Connection ID', - name: 'connectionId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'connection', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the connection to get.', - }, + // ---------------------------------- + // connection:get + // ---------------------------------- + { + displayName: 'Connection ID', + name: 'connectionId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'connection', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the connection to get.', + }, - // ---------------------------------- - // connection:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'connection', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'connection', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, + // ---------------------------------- + // connection:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'connection', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'connection', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, ] as INodeProperties[]; \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts index 8b7a264c090..25b42b3678b 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts @@ -1,351 +1,351 @@ import { INodeProperties } from "n8n-workflow"; export const contactOperations = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'contact', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a contact', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a contact', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a contact', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all contact', - }, - { - name: 'Update', - value: 'update', - description: 'Update a contact', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'contact', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a contact', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a contact', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a contact', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all contact', + }, + { + name: 'Update', + value: 'update', + description: 'Update a contact', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, ] as INodeProperties[]; export const contactFields = [ - // ---------------------------------- - // contact:create - // ---------------------------------- - { - displayName: 'Email', - name: 'email', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], - }, - }, - description: 'The email of the contact to create.', - }, - { - displayName: 'Update if exists', - name: 'updateIfExists', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], - }, - }, - default: false, - description: 'Update user if it exists already. If not set and user exists it will error instead.', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'First Name', - name: 'firstName', - type: 'string', - default: '', - description: 'The first name of the contact to create.', - }, - { - displayName: 'Last Name', - name: 'lastName', - type: 'string', - default: '', - description: 'The last name of the contact to create.', - }, - { - displayName: 'Phone', - name: 'phone', - type: 'string', - default: '', - description: 'Phone number of the contact.', - }, - { - displayName: 'Custom Properties', - name: 'customProperties', - placeholder: 'Add Custom Property', - description: 'Adds a custom property to set also values which have not been predefined.', - type: 'fixedCollection', - typeOptions: { - multipleValues: true, - }, - default: {}, - options: [ - { - name: 'property', - displayName: 'Property', - values: [ - { - displayName: 'Property Name', - name: 'name', - type: 'string', - default: '', - description: 'Name of the property to set.', - }, - { - displayName: 'Property Value', - name: 'value', - type: 'string', - default: '', - description: 'Value of the property to set.', - }, - ] - }, - ], - }, - ], - }, + // ---------------------------------- + // contact:create + // ---------------------------------- + { + displayName: 'Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'contact', + ], + }, + }, + description: 'The email of the contact to create.', + }, + { + displayName: 'Update if exists', + name: 'updateIfExists', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'contact', + ], + }, + }, + default: false, + description: 'Update user if it exists already. If not set and user exists it will error instead.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'contact', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: 'The first name of the contact to create.', + }, + { + displayName: 'Last Name', + name: 'lastName', + type: 'string', + default: '', + description: 'The last name of the contact to create.', + }, + { + displayName: 'Phone', + name: 'phone', + type: 'string', + default: '', + description: 'Phone number of the contact.', + }, + { + displayName: 'Custom Properties', + name: 'customProperties', + placeholder: 'Add Custom Property', + description: 'Adds a custom property to set also values which have not been predefined.', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'property', + displayName: 'Property', + values: [ + { + displayName: 'Property Name', + name: 'name', + type: 'string', + default: '', + description: 'Name of the property to set.', + }, + { + displayName: 'Property Value', + name: 'value', + type: 'string', + default: '', + description: 'Value of the property to set.', + }, + ] + }, + ], + }, + ], + }, - // ---------------------------------- - // contact:update - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to update.', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - description: 'The fields to update.', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Email', - name: 'email', - type: 'string', - default: '', - description: 'Email of the contact.', - }, - { - displayName: 'First Name', - name: 'firstName', - type: 'string', - default: '', - description: 'First name of the contact.', - }, - { - displayName: 'Last Name', - name: 'lastName', - type: 'string', - default: '', - description: 'Last name of the contact.', - }, - { - displayName: 'Phone', - name: 'phone', - type: 'string', - default: '', - description: 'Phone number of the contact.', - }, - { - displayName: 'Custom Properties', - name: 'customProperties', - placeholder: 'Add Custom Property', - description: 'Adds a custom property to set also values which have not been predefined.', - type: 'fixedCollection', - typeOptions: { - multipleValues: true, - }, - default: {}, - options: [ - { - name: 'property', - displayName: 'Property', - values: [ - { - displayName: 'Property Name', - name: 'name', - type: 'string', - default: '', - description: 'Name of the property to set.', - }, - { - displayName: 'Property Value', - name: 'value', - type: 'string', - default: '', - description: 'Value of the property to set.', - }, - ] - }, - ], - }, - ], - }, + // ---------------------------------- + // contact:update + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'contact', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Email', + name: 'email', + type: 'string', + default: '', + description: 'Email of the contact.', + }, + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: 'First name of the contact.', + }, + { + displayName: 'Last Name', + name: 'lastName', + type: 'string', + default: '', + description: 'Last name of the contact.', + }, + { + displayName: 'Phone', + name: 'phone', + type: 'string', + default: '', + description: 'Phone number of the contact.', + }, + { + displayName: 'Custom Properties', + name: 'customProperties', + placeholder: 'Add Custom Property', + description: 'Adds a custom property to set also values which have not been predefined.', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + options: [ + { + name: 'property', + displayName: 'Property', + values: [ + { + displayName: 'Property Name', + name: 'name', + type: 'string', + default: '', + description: 'Name of the property to set.', + }, + { + displayName: 'Property Value', + name: 'value', + type: 'string', + default: '', + description: 'Value of the property to set.', + }, + ] + }, + ], + }, + ], + }, - // ---------------------------------- - // contact:delete - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to delete.', - }, + // ---------------------------------- + // contact:delete + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to delete.', + }, - // ---------------------------------- - // contact:get - // ---------------------------------- - { - displayName: 'Contact ID', - name: 'contactId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the contact to get.', - }, + // ---------------------------------- + // contact:get + // ---------------------------------- + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'contact', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the contact to get.', + }, - // ---------------------------------- - // contact:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, + // ---------------------------------- + // contact:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'contact', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'contact', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts index e5219177d7f..940157e5f01 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts @@ -3,527 +3,527 @@ import { INodeProperties } from "n8n-workflow"; import { allCurrencies } from './currencies'; export const dealOperations = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'deal', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a deal', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a deal', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a deal', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all deals', - }, - { - name: 'Update', - value: 'update', - description: 'Update a deal', - }, - { - name: 'Create Note', - value: 'createNote', - description: 'Create a deal note', - }, - { - name: 'Update deal note', - value: 'updateNote', - description: 'Update a deal note', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'deal', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a deal', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a deal', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a deal', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all deals', + }, + { + name: 'Update', + value: 'update', + description: 'Update a deal', + }, + { + name: 'Create Note', + value: 'createNote', + description: 'Create a deal note', + }, + { + name: 'Update deal note', + value: 'updateNote', + description: 'Update a deal note', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, ] as INodeProperties[]; export const dealFields = [ - // ---------------------------------- - // deal:create - // ---------------------------------- - { - displayName: 'Title', - name: 'title', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The title of the deal', - }, - { - displayName: 'Deal\'s contact ID', - name: 'contact', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal\'s contact', - }, - { - displayName: 'Deal value', - name: 'value', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The value of the deal in cents', - }, - { - displayName: 'Currency', - name: 'currency', - type: 'options', - default: 'eur', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - options: allCurrencies, - description: 'The currency of the deal in 3-character ISO format', - }, - { - displayName: 'Deal pipeline ID', - name: 'group', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The pipeline ID of the deal', - }, - { - displayName: 'Deal stage ID', - name: 'stage', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The stage ID of the deal', - }, - { - displayName: 'Deal owner ID', - name: 'owner', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The owner ID of the deal', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the deal', - }, + // ---------------------------------- + // deal:create + // ---------------------------------- + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The title of the deal', + }, + { + displayName: 'Deal\'s contact ID', + name: 'contact', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal\'s contact', + }, + { + displayName: 'Deal value', + name: 'value', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The value of the deal in cents', + }, + { + displayName: 'Currency', + name: 'currency', + type: 'options', + default: 'eur', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + options: allCurrencies, + description: 'The currency of the deal in 3-character ISO format', + }, + { + displayName: 'Deal pipeline ID', + name: 'group', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The pipeline ID of the deal', + }, + { + displayName: 'Deal stage ID', + name: 'stage', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The stage ID of the deal', + }, + { + displayName: 'Deal owner ID', + name: 'owner', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The owner ID of the deal', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'deal', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the deal', + }, - { - displayName: 'Deal percentage', - name: 'percent', - type: 'number', - default: 0, - description: 'The percentage of the deal', - }, - { - displayName: 'Deal status', - name: 'status', - type: 'number', - default: 0, - description: 'The status of the deal', - }, - ] - }, + { + displayName: 'Deal percentage', + name: 'percent', + type: 'number', + default: 0, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'status', + type: 'number', + default: 0, + description: 'The status of the deal', + }, + ] + }, - // ---------------------------------- - // deal:update - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the deal to update.', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - description: 'The fields to update.', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Title', - name: 'title', - type: 'string', - default: '', - description: 'The title of the deal', - }, - { - displayName: 'Deal\'s contact ID', - name: 'contact', - type: 'number', - default: 0, - description: 'The ID of the deal\'s contact', - }, - { - displayName: 'Deal value', - name: 'value', - type: 'number', - default: 0, - description: 'The value of the deal in cents', - }, - { - displayName: 'Currency', - name: 'currency', - type: 'options', - options: allCurrencies, - default: 'eur', - description: 'The currency of the deal in 3-character ISO format', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the deal', - }, - { - displayName: 'Deal pipeline ID', - name: 'group', - type: 'string', - default: '', - description: 'The pipeline ID of the deal', - }, - { - displayName: 'Deal stage ID', - name: 'stage', - type: 'string', - default: '', - description: 'The stage ID of the deal', - }, - { - displayName: 'Deal owner ID', - name: 'owner', - type: 'string', - default: '', - description: 'The owner ID of the deal', - }, - { - displayName: 'Deal percentage', - name: 'percent', - type: 'number', - default: 0, - description: 'The percentage of the deal', - }, - { - displayName: 'Deal status', - name: 'status', - type: 'number', - default: 0, - description: 'The status of the deal', - }, - ] - }, + // ---------------------------------- + // deal:update + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the deal to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'deal', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + description: 'The title of the deal', + }, + { + displayName: 'Deal\'s contact ID', + name: 'contact', + type: 'number', + default: 0, + description: 'The ID of the deal\'s contact', + }, + { + displayName: 'Deal value', + name: 'value', + type: 'number', + default: 0, + description: 'The value of the deal in cents', + }, + { + displayName: 'Currency', + name: 'currency', + type: 'options', + options: allCurrencies, + default: 'eur', + description: 'The currency of the deal in 3-character ISO format', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the deal', + }, + { + displayName: 'Deal pipeline ID', + name: 'group', + type: 'string', + default: '', + description: 'The pipeline ID of the deal', + }, + { + displayName: 'Deal stage ID', + name: 'stage', + type: 'string', + default: '', + description: 'The stage ID of the deal', + }, + { + displayName: 'Deal owner ID', + name: 'owner', + type: 'string', + default: '', + description: 'The owner ID of the deal', + }, + { + displayName: 'Deal percentage', + name: 'percent', + type: 'number', + default: 0, + description: 'The percentage of the deal', + }, + { + displayName: 'Deal status', + name: 'status', + type: 'number', + default: 0, + description: 'The status of the deal', + }, + ] + }, - // ---------------------------------- - // deal:delete - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal to delete.', - }, + // ---------------------------------- + // deal:delete + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal to delete.', + }, - // ---------------------------------- - // deal:get - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal to get.', - }, + // ---------------------------------- + // deal:get + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal to get.', + }, - // ---------------------------------- - // deal:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, + // ---------------------------------- + // deal:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'deal', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, - // ---------------------------------- - // dealNote:create - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'createNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal note', - }, - { - displayName: 'Deal Note', - name: 'dealNote', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'createNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The content of the deal note', - }, + // ---------------------------------- + // dealNote:create + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'createNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal Note', + name: 'dealNote', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'createNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The content of the deal note', + }, - // ---------------------------------- - // dealNote:update - // ---------------------------------- - { - displayName: 'Deal ID', - name: 'dealId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal note', - }, - { - displayName: 'Deal note ID', - name: 'dealNoteId', - type: 'number', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The ID of the deal note', - }, - { - displayName: 'Deal Note', - name: 'dealNote', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], - }, - }, - description: 'The content of the deal note', - }, + // ---------------------------------- + // dealNote:update + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal note ID', + name: 'dealNoteId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The ID of the deal note', + }, + { + displayName: 'Deal Note', + name: 'dealNote', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'updateNote', + ], + resource: [ + 'deal', + ], + }, + }, + description: 'The content of the deal note', + }, ] as INodeProperties[]; \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts index f7f75e3fbb9..2b8b0d33cd4 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts @@ -1,290 +1,290 @@ import { INodeProperties } from "n8n-workflow"; export const ecomCustomerOperations = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'ecommerceCustomer', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a E-commerce Customer', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a E-commerce Customer', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a E-commerce Customer', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all E-commerce Customer', - }, - { - name: 'Update', - value: 'update', - description: 'Update a E-commerce Customer', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'ecommerceCustomer', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a E-commerce Customer', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a E-commerce Customer', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a E-commerce Customer', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all E-commerce Customer', + }, + { + name: 'Update', + value: 'update', + description: 'Update a E-commerce Customer', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, ] as INodeProperties[]; export const ecomCustomerFields = [ - // ---------------------------------- - // ecommerceCustomer:create - // ---------------------------------- - { - displayName: 'Service ID', - name: 'connectionid', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - description: 'The id of the connection object for the service where the customer originates.', - }, - { - displayName: 'Customer ID', - name: 'externalid', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - description: 'The id of the customer in the external service.', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - description: 'The email address of the customer.', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Accepts Marketing', - name: 'acceptsMarketing', - type: 'boolean', - default: false, - description: 'Indication of whether customer has opt-ed in to marketing communications.', - }, - ], - }, + // ---------------------------------- + // ecommerceCustomer:create + // ---------------------------------- + { + displayName: 'Service ID', + name: 'connectionid', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + description: 'The id of the connection object for the service where the customer originates.', + }, + { + displayName: 'Customer ID', + name: 'externalid', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + description: 'The id of the customer in the external service.', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + description: 'The email address of the customer.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Accepts Marketing', + name: 'acceptsMarketing', + type: 'boolean', + default: false, + description: 'Indication of whether customer has opt-ed in to marketing communications.', + }, + ], + }, - // ---------------------------------- - // ecommerceCustomer:update - // ---------------------------------- - { - displayName: 'Customer ID', - name: 'ecommerceCustomerId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the E-commerce customer to update.', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - description: 'The fields to update.', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Service ID', - name: 'connectionid', - type: 'string', - default: '', - description: 'The id of the connection object for the service where the customer originates.', - }, - { - displayName: 'Customer ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the customer in the external service.', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - description: 'The email address of the customer.', - }, - { - displayName: 'Accepts Marketing', - name: 'acceptsMarketing', - type: 'boolean', - default: false, - description: 'Indication of whether customer has opt-ed in to marketing communications.', - }, - ], - }, + // ---------------------------------- + // ecommerceCustomer:update + // ---------------------------------- + { + displayName: 'Customer ID', + name: 'ecommerceCustomerId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the E-commerce customer to update.', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + description: 'The fields to update.', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Service ID', + name: 'connectionid', + type: 'string', + default: '', + description: 'The id of the connection object for the service where the customer originates.', + }, + { + displayName: 'Customer ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the customer in the external service.', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + description: 'The email address of the customer.', + }, + { + displayName: 'Accepts Marketing', + name: 'acceptsMarketing', + type: 'boolean', + default: false, + description: 'Indication of whether customer has opt-ed in to marketing communications.', + }, + ], + }, - // ---------------------------------- - // ecommerceCustomer:delete - // ---------------------------------- - { - displayName: 'Customer ID', - name: 'ecommerceCustomerId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the E-commerce customer to delete.', - }, + // ---------------------------------- + // ecommerceCustomer:delete + // ---------------------------------- + { + displayName: 'Customer ID', + name: 'ecommerceCustomerId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the E-commerce customer to delete.', + }, - // ---------------------------------- - // ecommerceCustomer:get - // ---------------------------------- - { - displayName: 'Customer ID', - name: 'ecommerceCustomerId', - type: 'number', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - default: 0, - required: true, - description: 'ID of the E-commerce customer to get.', - }, + // ---------------------------------- + // ecommerceCustomer:get + // ---------------------------------- + { + displayName: 'Customer ID', + name: 'ecommerceCustomerId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: 0, + required: true, + description: 'ID of the E-commerce customer to get.', + }, - // ---------------------------------- - // ecommerceCustomer:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceCustomer', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceCustomer', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, + // ---------------------------------- + // ecommerceCustomer:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceCustomer', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceCustomer', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts index a1c0993dfea..525fa0eb208 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts @@ -3,714 +3,714 @@ import { INodeProperties } from "n8n-workflow"; import { allCurrencies } from './currencies'; export const ecomOrderOperations = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'ecommerceOrder', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a order', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a order', - }, - { - name: 'Get', - value: 'get', - description: 'Get data of a order', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all orders', - }, - { - name: 'Update', - value: 'update', - description: 'Update a order', - }, - ], - default: 'create', - description: 'The operation to perform.', - }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'ecommerceOrder', + ], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a order', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a order', + }, + { + name: 'Get', + value: 'get', + description: 'Get data of a order', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all orders', + }, + { + name: 'Update', + value: 'update', + description: 'Update a order', + }, + ], + default: 'create', + description: 'The operation to perform.', + }, ] as INodeProperties[]; export const ecomOrderFields = [ - // ---------------------------------- - // ecommerceOrder:create - // ---------------------------------- - { - displayName: 'External ID', - name: 'externalid', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', - }, - { - displayName: 'External checkout ID', - name: 'externalcheckoutid', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', - }, - { - displayName: 'Order source', - name: 'source', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The email address of the customer who placed the order.', - }, - { - displayName: 'Total price', - name: 'totalPrice', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Order currency', - name: 'currency', - type: 'options', - default: 'eur', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - options: allCurrencies, - description: 'The currency of the order (3-digit ISO code, e.g., "USD").', - }, - { - displayName: 'Connection ID', - name: 'connectionid', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the connection from which this order originated.', - }, - { - displayName: 'Customer ID', - name: 'customerid', - type: 'number', - default: 0, - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the customer associated with this order.', - }, - { - displayName: 'Creation Date', - name: 'externalCreatedDate', - type: 'dateTime', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The date the order was placed.', - }, - { - displayName: 'Abandoning Date', - name: 'abandonedDate', - type: 'dateTime', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', - }, - { - displayName: 'Products', - name: 'orderProducts', - type: 'collection', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add product', - }, - displayOptions: { - show: { - operation: [ - 'create' - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - description: 'All ordered products', - placeholder: 'Add product field', - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The name of the product', - }, - { - displayName: 'Price', - name: 'price', - type: 'number', - default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Product Quantity', - name: 'quantity', - type: 'number', - default: 0, - description: 'The quantity ordered.', - }, - { - displayName: 'Product external ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the product in the external service.', - }, - { - displayName: 'Product Category', - name: 'category', - type: 'string', - default: '', - description: 'The category of the product.', - }, - { - displayName: 'SKU', - name: 'sku', - type: 'string', - default: '', - description: 'The SKU for the product.', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the product.', - }, - { - displayName: 'Image URL', - name: 'imageUrl', - type: 'string', - default: '', - description: 'An Image URL that displays an image of the product.', - }, - { - displayName: 'Product URL', - name: 'productUrl', - type: 'string', - default: '', - description: 'A URL linking to the product in your store.', - }, - ], - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Shipping Amount', - name: 'shippingAmount', - type: 'number', - default: 0, - description: 'The total shipping amount for the order in cents .', - }, + // ---------------------------------- + // ecommerceOrder:create + // ---------------------------------- + { + displayName: 'External ID', + name: 'externalid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', + }, + { + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Order currency', + name: 'currency', + type: 'options', + default: 'eur', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + options: allCurrencies, + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', + }, + { + displayName: 'Connection ID', + name: 'connectionid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the connection from which this order originated.', + }, + { + displayName: 'Customer ID', + name: 'customerid', + type: 'number', + default: 0, + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the customer associated with this order.', + }, + { + displayName: 'Creation Date', + name: 'externalCreatedDate', + type: 'dateTime', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'abandonedDate', + type: 'dateTime', + default: '', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + displayOptions: { + show: { + operation: [ + 'create' + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product field', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'create', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, - { - displayName: 'Tax Amount', - name: 'taxAmount', - type: 'number', - default: 0, - description: 'The total tax amount for the order in cents.', - }, - { - displayName: 'Discount Amount', - name: 'discountAmount', - type: 'number', - default: 0, - description: 'The total discount amount for the order in cents.', - }, - { - displayName: 'Order URL', - name: 'orderUrl', - type: 'string', - default: '', - description: 'The URL for the order in the external service.', - }, - { - displayName: 'External updated date', - name: 'externalUpdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was updated.', - }, - { - displayName: 'Shipping Method', - name: 'shippingMethod', - type: 'string', - default: '', - description: 'The shipping method of the order.', - }, - { - displayName: 'Order Number', - name: 'orderNumber', - type: 'string', - default: '', - description: 'The order number. This can be different than the externalid.', - }, + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, - ] - }, + ] + }, - // ---------------------------------- - // ecommerceOrder:update - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, + // ---------------------------------- + // ecommerceOrder:update + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, - { - displayName: 'Add Field', - name: 'updateFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'External ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', - }, - { - displayName: 'External checkout ID', - name: 'externalcheckoutid', - type: 'string', - default: '', - description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', - }, - { - displayName: 'Order source', - name: 'source', - type: 'number', - default: 0, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', - }, - { - displayName: 'Customer Email', - name: 'email', - type: 'string', - default: '', - description: 'The email address of the customer who placed the order.', - }, - { - displayName: 'Total price', - name: 'totalPrice', - type: 'number', - default: 0, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Order currency', - name: 'currency', - type: 'options', - default: 'eur', - options: allCurrencies, - description: 'The currency of the order (3-digit ISO code, e.g., "USD").', - }, - { - displayName: 'Connection ID', - name: 'connectionid', - type: 'number', - default: 0, - description: 'The id of the connection from which this order originated.', - }, - { - displayName: 'Customer ID', - name: 'customerid', - type: 'number', - default: 0, - description: 'The id of the customer associated with this order.', - }, - { - displayName: 'Creation Date', - name: 'externalupdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was placed.', - }, - { - displayName: 'Abandoning Date', - name: 'abandonedDate', - type: 'dateTime', - default: '', - description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', - }, - { - displayName: 'Shipping Amount', - name: 'shippingAmount', - type: 'number', - default: 0, - description: 'The total shipping amount for the order in cents .', - }, + { + displayName: 'Add Field', + name: 'updateFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'update', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'External ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED', + }, + { + displayName: 'External checkout ID', + name: 'externalcheckoutid', + type: 'string', + default: '', + description: 'The id of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + }, + { + displayName: 'Order source', + name: 'source', + type: 'number', + default: 0, + description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations).', + }, + { + displayName: 'Customer Email', + name: 'email', + type: 'string', + default: '', + description: 'The email address of the customer who placed the order.', + }, + { + displayName: 'Total price', + name: 'totalPrice', + type: 'number', + default: 0, + description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Order currency', + name: 'currency', + type: 'options', + default: 'eur', + options: allCurrencies, + description: 'The currency of the order (3-digit ISO code, e.g., "USD").', + }, + { + displayName: 'Connection ID', + name: 'connectionid', + type: 'number', + default: 0, + description: 'The id of the connection from which this order originated.', + }, + { + displayName: 'Customer ID', + name: 'customerid', + type: 'number', + default: 0, + description: 'The id of the customer associated with this order.', + }, + { + displayName: 'Creation Date', + name: 'externalupdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was placed.', + }, + { + displayName: 'Abandoning Date', + name: 'abandonedDate', + type: 'dateTime', + default: '', + description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + }, + { + displayName: 'Shipping Amount', + name: 'shippingAmount', + type: 'number', + default: 0, + description: 'The total shipping amount for the order in cents .', + }, - { - displayName: 'Tax Amount', - name: 'taxAmount', - type: 'number', - default: 0, - description: 'The total tax amount for the order in cents.', - }, - { - displayName: 'Discount Amount', - name: 'discountAmount', - type: 'number', - default: 0, - description: 'The total discount amount for the order in cents.', - }, - { - displayName: 'Order URL', - name: 'orderUrl', - type: 'string', - default: '', - description: 'The URL for the order in the external service.', - }, - { - displayName: 'External updated date', - name: 'externalUpdatedDate', - type: 'dateTime', - default: '', - description: 'The date the order was updated.', - }, - { - displayName: 'Shipping Method', - name: 'shippingMethod', - type: 'string', - default: '', - description: 'The shipping method of the order.', - }, - { - displayName: 'Order Number', - name: 'orderNumber', - type: 'string', - default: '', - description: 'The order number. This can be different than the externalid.', - }, + { + displayName: 'Tax Amount', + name: 'taxAmount', + type: 'number', + default: 0, + description: 'The total tax amount for the order in cents.', + }, + { + displayName: 'Discount Amount', + name: 'discountAmount', + type: 'number', + default: 0, + description: 'The total discount amount for the order in cents.', + }, + { + displayName: 'Order URL', + name: 'orderUrl', + type: 'string', + default: '', + description: 'The URL for the order in the external service.', + }, + { + displayName: 'External updated date', + name: 'externalUpdatedDate', + type: 'dateTime', + default: '', + description: 'The date the order was updated.', + }, + { + displayName: 'Shipping Method', + name: 'shippingMethod', + type: 'string', + default: '', + description: 'The shipping method of the order.', + }, + { + displayName: 'Order Number', + name: 'orderNumber', + type: 'string', + default: '', + description: 'The order number. This can be different than the externalid.', + }, - { - displayName: 'Products', - name: 'orderProducts', - type: 'collection', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add product', - }, - default: {}, - description: 'All ordered products', - placeholder: 'Add product field', - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The name of the product', - }, - { - displayName: 'Price', - name: 'price', - type: 'number', - default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', - }, - { - displayName: 'Product Quantity', - name: 'quantity', - type: 'number', - default: 0, - description: 'The quantity ordered.', - }, - { - displayName: 'Product external ID', - name: 'externalid', - type: 'string', - default: '', - description: 'The id of the product in the external service.', - }, - { - displayName: 'Product Category', - name: 'category', - type: 'string', - default: '', - description: 'The category of the product.', - }, - { - displayName: 'SKU', - name: 'sku', - type: 'string', - default: '', - description: 'The SKU for the product.', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - description: 'The description of the product.', - }, - { - displayName: 'Image URL', - name: 'imageUrl', - type: 'string', - default: '', - description: 'An Image URL that displays an image of the product.', - }, - { - displayName: 'Product URL', - name: 'productUrl', - type: 'string', - default: '', - description: 'A URL linking to the product in your store.', - }, - ], - }, + { + displayName: 'Products', + name: 'orderProducts', + type: 'collection', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add product', + }, + default: {}, + description: 'All ordered products', + placeholder: 'Add product field', + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The name of the product', + }, + { + displayName: 'Price', + name: 'price', + type: 'number', + default: 0, + description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + }, + { + displayName: 'Product Quantity', + name: 'quantity', + type: 'number', + default: 0, + description: 'The quantity ordered.', + }, + { + displayName: 'Product external ID', + name: 'externalid', + type: 'string', + default: '', + description: 'The id of the product in the external service.', + }, + { + displayName: 'Product Category', + name: 'category', + type: 'string', + default: '', + description: 'The category of the product.', + }, + { + displayName: 'SKU', + name: 'sku', + type: 'string', + default: '', + description: 'The SKU for the product.', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The description of the product.', + }, + { + displayName: 'Image URL', + name: 'imageUrl', + type: 'string', + default: '', + description: 'An Image URL that displays an image of the product.', + }, + { + displayName: 'Product URL', + name: 'productUrl', + type: 'string', + default: '', + description: 'A URL linking to the product in your store.', + }, + ], + }, - ] - }, + ] + }, - // ---------------------------------- - // ecommerceOrder:delete - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, + // ---------------------------------- + // ecommerceOrder:delete + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'delete', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, - // ---------------------------------- - // ecommerceOrder:get - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - description: 'The id of the e-commerce order.', - }, + // ---------------------------------- + // ecommerceOrder:get + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'get', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + description: 'The id of the e-commerce order.', + }, - // ---------------------------------- - // ecommerceOrder:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, + // ---------------------------------- + // ecommerceOrder:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrder', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, ] as INodeProperties[]; \ No newline at end of file diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts index 29869a74359..1f53c47f0b2 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts @@ -1,124 +1,124 @@ import { INodeProperties } from "n8n-workflow"; export const ecomOrderProductsOperations = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - displayOptions: { - show: { - resource: [ - 'ecommerceOrderProducts', - ], - }, - }, - options: [ - { - name: 'Get All', - value: 'getAll', - description: 'Get data of all order products', - }, - { - name: 'Get by Product ID', - value: 'getByProductId', - description: 'Get data of a ordered product', - }, - { - name: 'Get by Order ID', - value: 'getByOrderId', - description: 'Get data of an order\'s products', - }, - ], - default: 'getAll', - description: 'The operation to perform.', - }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + options: [ + { + name: 'Get All', + value: 'getAll', + description: 'Get data of all order products', + }, + { + name: 'Get by Product ID', + value: 'getByProductId', + description: 'Get data of a ordered product', + }, + { + name: 'Get by Order ID', + value: 'getByOrderId', + description: 'Get data of an order\'s products', + }, + ], + default: 'getAll', + description: 'The operation to perform.', + }, ] as INodeProperties[]; export const ecomOrderProductsFields = [ - // ---------------------------------- - // ecommerceOrderProducts:getByOrderId - // ---------------------------------- - { - displayName: 'Order ID', - name: 'orderId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'getByOrderId', - ], - resource: [ - 'ecommerceOrderProducts', - ], - }, - }, - description: 'The ID of the order whose products you\'d like returned.', - }, + // ---------------------------------- + // ecommerceOrderProducts:getByOrderId + // ---------------------------------- + { + displayName: 'Order ID', + name: 'orderId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'getByOrderId', + ], + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + description: 'The ID of the order whose products you\'d like returned.', + }, - // ---------------------------------- - // ecommerceOrderProducts:getByProductId - // ---------------------------------- - { - displayName: 'Product ID', - name: 'procuctId', - type: 'number', - default: 0, - displayOptions: { - show: { - operation: [ - 'getByProductId', - ], - resource: [ - 'ecommerceOrderProducts', - ], - }, - }, - description: 'The ID of the product you\'d like returned.', - }, + // ---------------------------------- + // ecommerceOrderProducts:getByProductId + // ---------------------------------- + { + displayName: 'Product ID', + name: 'procuctId', + type: 'number', + default: 0, + displayOptions: { + show: { + operation: [ + 'getByProductId', + ], + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + description: 'The ID of the product you\'d like returned.', + }, - // ---------------------------------- - // ecommerceOrderProducts:getAll - // ---------------------------------- - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrderProducts', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrderProducts', - ], - returnAll: [ - false, - ], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 500, - }, - default: 100, - description: 'How many results to return.', - }, + // ---------------------------------- + // ecommerceOrderProducts:getAll + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrderProducts', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'ecommerceOrderProducts', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, ] as INodeProperties[]; \ No newline at end of file From 821556e85adb737005db089f94d481d44f9d55d7 Mon Sep 17 00:00:00 2001 From: Romain Dunand Date: Thu, 7 Nov 2019 18:38:38 +0100 Subject: [PATCH 49/52] Shift column index by startRange instead of keyColumnIndex --- packages/nodes-base/nodes/Google/GoogleSheet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Google/GoogleSheet.ts b/packages/nodes-base/nodes/Google/GoogleSheet.ts index 72391939afc..d2eb887b9f1 100644 --- a/packages/nodes-base/nodes/Google/GoogleSheet.ts +++ b/packages/nodes-base/nodes/Google/GoogleSheet.ts @@ -312,7 +312,7 @@ export class GoogleSheet { // Property exists so add it to the data to update // Get the column name in which the property data can be found - updateColumnName = String.fromCharCode(characterCode + keyColumnOrder.indexOf(propertyName)); + updateColumnName = String.fromCharCode(rangeStart.toUpperCase().charCodeAt(0) + keyColumnOrder.indexOf(propertyName)); updateData.push({ range: `${sheet ? sheet + '!' : ''}${updateColumnName}${updateRowIndex}`, From fcb4f8554c522ea37befca39f807666eb8150b36 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 7 Nov 2019 21:05:34 +0100 Subject: [PATCH 50/52] :books: Add links to example docker-compose setup --- docker/images/n8n/README.md | 7 +++++++ docs/docker.md | 3 +++ 2 files changed, 10 insertions(+) diff --git a/docker/images/n8n/README.md b/docker/images/n8n/README.md index 3250fd4e17c..8ab93f0e0f4 100644 --- a/docker/images/n8n/README.md +++ b/docker/images/n8n/README.md @@ -19,6 +19,7 @@ so also used with internal tools. - [Securing n8n](#securing-n8n) - [Persist data](#persist-data) - [Passing Sensitive Data via File](#passing-sensitive-data-via-file) +- [Example Setup with Lets Encrypt](#example-setup-with-lets-encrypt) - [What does n8n mean and how do you pronounce it](#what-does-n8n-mean-and-how-do-you-pronounce-it) - [Support](#support) - [Upgrading](#upgrading) @@ -193,6 +194,12 @@ The following environment variables support file input: - N8N_BASIC_AUTH_USER_FILE +## Example Setup with Lets Encrypt + +A basic step by step example setup of n8n with docker-compose and Lets Encrypt is available on the +[Server Setup](https://docs.n8n.io/#/server-setup) page. + + ## Setting Timezone To define the timezone n8n should use, the environment variable `GENERIC_TIMEZONE` can diff --git a/docs/docker.md b/docs/docker.md index c092104f519..5b400820d56 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -2,3 +2,6 @@ Detailed information about how to run n8n in Docker can be found in the README of the [Docker Image](https://github.com/n8n-io/n8n/blob/master/docker/images/n8n/README.md). + +A basic step by step example setup of n8n with docker-compose and Lets Encrypt is available on the +[Server Setup](server-setup.md) page. From e4f08382f261792241a7e0b9f54d3183e2708c15 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 7 Nov 2019 21:06:30 +0100 Subject: [PATCH 51/52] :books: Add documentation for Function-Nodes and about Data Structure --- docs/_sidebar.md | 2 + docs/data-structure.md | 39 +++++++++ docs/node-basics.md | 72 ++++++++++++++++ docs/nodes.md | 189 +++++++++++++++++++++++++++++++---------- 4 files changed, 255 insertions(+), 47 deletions(-) create mode 100644 docs/data-structure.md create mode 100644 docs/node-basics.md diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 01cdf780d2c..e92096e1e27 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -13,8 +13,10 @@ - Advanced - [Configuration](configuration.md) + - [Data Structure](data-structure.md) - [Database](database.md) - [Keyboard Shortcuts](keyboard-shortcuts.md) + - [Node Basics](node-basics.md) - [Nodes](nodes.md) - [Security](security.md) - [Sensitive Data](sensitive-data.md) diff --git a/docs/data-structure.md b/docs/data-structure.md new file mode 100644 index 00000000000..e6a6917f629 --- /dev/null +++ b/docs/data-structure.md @@ -0,0 +1,39 @@ +# Data Structure + +For "basic usage" it is not necessarily needed to understand how the data is structured +which gets passed from one node to another. It becomes however important if you want to: + + - create an own node + - write custom expressions + - use the Function or Function Item Node + - you want to get the most out of n8n in general + + +In n8n all data passed between nodes is an array of objects. It has the structure below: + +```json +[ + { + // Each item has to contain a "json" property. But it can be an empty object like {}. + // Any kind of JSON data is allowed. So arrays and the data being deeply nested is fine. + json: { // The actual data n8n operates on (required) + // This data is only an example it could be any kind of JSON data + jsonKeyName: 'keyValue', + anotherJsonKey: { + lowerLevelJsonKey: 1 + } + }, + // Binary data of item. The most items in n8n do not contain any (optional) + binary: { + // The key-name "binaryKeyName" is only an example. Any kind of key-name is possible. + binaryKeyName: { + data: '....', // Base64 encoded binary data (required) + mimeType: 'image/png', // Optional but should be set if possible (optional) + fileExtension: 'png', // Optional but should be set if possible (optional) + fileName: 'example.png', // Optional but should be set if possible (optional) + } + } + }, + ... +] +``` diff --git a/docs/node-basics.md b/docs/node-basics.md new file mode 100644 index 00000000000..c479e62e99a --- /dev/null +++ b/docs/node-basics.md @@ -0,0 +1,72 @@ +# Node Basics + + +## Types + +There are two main node types in n8n Trigger- and Regular-Nodes. + + +### Trigger Nodes + +The Trigger-Nodes start a workflow and supply the initial data. A workflow can contain multiple trigger nodes but with each execution, just one of them will execute as they do not have any input and they are the nodes from which the execution starts. + + +### Regular Nodes + +These nodes do the actual “work”. They can add, remove and edit the data in the flow, request and send data to external APIs and can do everything possible with Node.js in general. + + +## Credentials + +External services need a way to identify and authenticate users. That data, which can range from API key over email/password combination to a very long multi-line private key, get saved in n8n as credentials. + +To make sure that the data is secure, it gets saved to the database encrypted. As encryption key does a random personal encryption key gets used which gets automatically generated on the first start of n8n and then saved under `~/.n8n/config`. + +Nodes in n8n can then request that credential information. As an additional layer of security can credentials only be accessed by node types which specifically got the right to do so. + + +## Expressions + +With the help of expressions, it is possible to set node parameters dynamically by referencing other data. That can be data from the flow, nodes, the environment or self-generated data. They are normal text with placeholders (everything between {{...}}) that can execute JavaScript code which offers access to special variables to access data. + +An expression could look like this: + +My name is: `{{$node["Webhook"].data["query"]["name"]}}` + +This one would return "My name is: " and then attach the value that the node with the name "Webhook" outputs and there select the property "query" and its key "name". So if the node would output this data: + +```json +{ + "query": { + "name": "Jim" + } +} +``` + +the value would be: "My name is: Jim" + +The following special variables are available: + + - **$binary**: Incoming binary data of a node + - **$data**: Incoming JSON data of a node + - **$env**: Environment variables + - **$node**: Data of other nodes (output-data, parameters) + - **$parameters**: Parameters of the current node + +Normally it is not needed to write the JavaScript variables manually as they can be simply selected with the help of the Expression Editor. + + +## Parameters + +On the most nodes in n8n parameters can be set. The values that get set define what exactly a node does. + +That values which are set are by default static and are always the same no matter what data they process. It is however also possible to set the values dynamically with the help of Expressions. With them, it is possible to make the value depending on other factors like the data of flow or parameters of other nodes. + +More information about it can be found under [Expressions](#expressions). + + +## Pausing Node + +Sometimes when creating and debugging a workflow it is helpful to not execute some specific nodes. To make that as simple as possible and not having to disconnect each node, it is possible to pause them. When a node gets paused the data simple passes through the node without being changed. + +There are two ways to pause a node. Either pressing the pause button which gets displayed above the node when hovering over it. Or by selecting the node and pressing “d”. diff --git a/docs/nodes.md b/docs/nodes.md index 5163bf8664a..cf2484c6c7e 100644 --- a/docs/nodes.md +++ b/docs/nodes.md @@ -1,72 +1,167 @@ -# Node +# Nodes + +## Function and Function Item Node + +These are the most powerful nodes in n8n. With these, almost everything can be done if you know how to +write JavaScript code. Both nodes work very similarly. They simply give you access to the incoming data +and you can manipulate it. -## Types +### Difference between both nodes -There are two main node types in n8n Trigger- and Regular-Nodes. +The difference is that the code of the Function-Node does get executed only once and it receives the +full items (JSON and binary data) as an array and expects as return value again an array of items. The items +returned can be totally different from the incoming ones. So is it not just possible to remove and edit +existing items it is also possible to add or return totally new ones. + +The code of the Function Item-Node on the other does get executed once for every item. It receives +as input one item at a time and also just the JSON data. As a return value, it again expects the JSON data +of one single item. That makes it possible to very easily add, remove and edit JSON properties of items +but it is not possible to add new or remove existing items. Accessing and changing binary data is only +possible via the methods `getBinaryData` and `setBinaryData`. + +Both nodes support promises. So instead of returning the item or items directly, it is also possible to +return a promise which resolves accordingly. -### Trigger Nodes +### Function-Node -The Trigger-Nodes start a workflow and supply the initial data. A workflow can contain multiple trigger nodes but with each execution, just one of them will execute as they do not have any input and they are the nodes from which the execution starts. +#### Variable: items +It contains all the items the node received as input. -### Regular Nodes +Information about how the data is structured can be found on the page [Data Structure](data-structure.md) -These nodes do the actual “work”. They can add, remove and edit the data in the flow, request and send data to external APIs and can do everything possible with Node.js in general. +The data can be accessed and manipulated like this: +```typescript +// Sets the JSON data property "myFileName" of the first item to the name of the +// file which is set in the binary property "image" of the same item. +items[0].json.myFileName = items[0].binary.image.fileName; -## Credentials - -External services need a way to identify and authenticate users. That data, which can range from API key over email/password combination to a very long multi-line private key, get saved in n8n as credentials. - -To make sure that the data is secure, it gets saved to the database encrypted. As encryption key does a random personal encryption key gets used which gets automatically generated on the first start of n8n and then saved under `~/.n8n/config`. - -Nodes in n8n can then request that credential information. As an additional layer of security can credentials only be accessed by node types which specifically got the right to do so. - - -## Expressions - -With the help of expressions, it is possible to set node parameters dynamically by referencing other data. That can be data from the flow, nodes, the environment or self-generated data. They are normal text with placeholders (everything between {{...}}) that can execute JavaScript code which offers access to special variables to access data. - -An expression could look like this: - -My name is: `{{$node["Webhook"].data["query"]["name"]}}` - -This one would return "My name is: " and then attach the value that the node with the name "Webhook" outputs and there select the property "query" and its key "name". So if the node would output this data: - -```json -{ - "query": { - "name": "Jim" - } -} +return items; ``` -the value would be: "My name is: Jim" +This example creates 10 dummy items with the ids 0 to 9: -The following special variables are available: +```typescript +const newItems = []; - - **$binary**: Incoming binary data of a node - - **$data**: Incoming JSON data of a node - - **$env**: Environment variables - - **$node**: Data of other nodes (output-data, parameters) - - **$parameters**: Parameters of the current node +for (let i=0;i<10;i++) { + newItems.push({ + json: { + id: i + } + }); +} -Normally it is not needed to write the JavaScript variables manually as they can be simply selected with the help of the Expression Editor. +return newItems; +``` -## Parameters +#### Method: $item(index) -On the most nodes in n8n parameters can be set. The values that get set define what exactly a node does. +With `$item` it is possible to access the data of parent nodes. That can be the item data but also +the parameters. It expects as input an index of the item the data should be returned for. This is +needed because for each item the data returned can be different. This is probably obvious for the +item data itself but maybe less for data like parameters. The reason why it is also needed there is +that they may contain an expression. Expressions get always executed of the context for an item. +If that would not be the case, for example, the Email Send-Node not would be able to send multiple +emails at once to different people. Instead, the same person would receive multiple emails. -That values which are set are by default static and are always the same no matter what data they process. It is however also possible to set the values dynamically with the help of Expressions. With them, it is possible to make the value depending on other factors like the data of flow or parameters of other nodes. +The index is 0 based. So `$item(0)` will return the first item, `$item(1)` the second one, ... -More information about it can be found under [Expressions](#expressions). +Example: + +```typescript +// Returns the value of the JSON data property "myNumber" of Node "Set" (first item) +const myNumber = $item(0).$node["Set"].data["myNumber"]; +// Like above but data of the 6th item +const myNumber = $item(5).$node["Set"].data["myNumber"]; + +// Returns the value of the parameter "channel" of Node "Slack". +// If it contains an expression the value will be resolved with the +// data of the first item. +const channel = $item(0).$node["Slack"].parameter["channel"]; +// Like above but resolved with the value of the 10th item. +const channel = $item(9).$node["Slack"].parameter["channel"]; +``` -## Pausing Node +#### Variable: $node -Sometimes when creating and debugging a workflow it is helpful to not execute some specific nodes. To make that as simple as possible and not having to disconnect each node, it is possible to pause them. When a node gets paused the data simple passes through the node without being changed. +Works exactly like `$item` with the difference that it will always return the data of the first item. -There are two ways to pause a node. Either pressing the pause button which gets displayed above the node when hovering over it. Or by selecting the node and pressing “d”. +```typescript +const myNumber = $node["Set"].data['myNumber']; + +const channel = $node["Slack"].parameter["channel"]; +``` + + +#### Method: getWorkflowStaticData(type) + +Gives access to the static workflow data. +It is possible to save data directly with the workflow. This data should, however, be very small. +A common use case is to for example to save a timestamp of the last item that got processed from +an RSS-Feed or database. It will always return an object. Properties can then read, deleted or +set on that object. When the workflow execution did succeed n8n will check automatically if data +changed and will save it if necessary. + +There are two types of static data. The "global" and the "node" one. Global static data is the +same in the whole workflow. And every node in the workflow can access it. The node static data +, however, is different for every node and only the node which did set it can retrieve it again. + +Example: + +```typescript +// Get the global workflow static data +const staticData = getWorkflowStaticData('global'); +// Get the static data of the node +const staticData = getWorkflowStaticData('node'); + +// Access its data +const lastExecution = staticData.lastExecution; + +// Update its data +staticData.lastExecution = new Date().getTime(); + +// Delete data +delete staticData.lastExecution; +``` + +It is important to know that static data can not be read and written when testing via the UI. +The data will there always be empty and changes will not be persisted. Only when a workflow +is active and it gets called by a Trigger or Webhook will the static data be saved. + + + +### Function Item-Node + + +#### Variable: item + +It contains the "json" data of the currently processed item. + +The data can be accessed and manipulated like this: + +```json +// Uses the data of an already existing key to create a new additional one +item.newIncrementedCounter = item.existingCounter + 1; +return item; +``` + + +#### Method: getBinaryData() + +Returns all the binary data (all keys) of the item which gets currently processed. + + +#### Method: setBinaryData(binaryData) + +Sets all the binary data (all keys) of the item which gets currently processed. + + +#### Method: getWorkflowStaticData(type) + +As described above for Function-Node. From 98ac7f3cc11112d9ce6e82eb0aa9e045ea9b7001 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 7 Nov 2019 21:20:08 +0100 Subject: [PATCH 52/52] :zap: Remove not needed import --- .../nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts index 2b82d6bebbb..e962e4041d5 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts @@ -1,7 +1,5 @@ import { INodeProperties } from "n8n-workflow"; -import { allCurrencies } from './currencies'; - export const connectionOperations = [ { displayName: 'Operation', @@ -321,4 +319,4 @@ export const connectionFields = [ default: 100, description: 'How many results to return.', }, -] as INodeProperties[]; \ No newline at end of file +] as INodeProperties[];