mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
EsLint changes
This commit is contained in:
parent
08220195a2
commit
7c4a588b70
50
.eslintrc.json
Normal file
50
.eslintrc.json
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:vue/essential",
|
||||
"tslint-eslint-rules"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"vue",
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
"tab"
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"sort-imports": ["error", {
|
||||
"ignoreCase": false,
|
||||
"ignoreMemberSort": false,
|
||||
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
|
||||
}],
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error"]
|
||||
}
|
||||
}
|
|
@ -16,5 +16,9 @@
|
|||
"lerna": "^3.13.1",
|
||||
"run-script-os": "^1.0.7"
|
||||
},
|
||||
"postcss": {}
|
||||
"postcss": {},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/parser": "^2.31.0",
|
||||
"tslint-eslint-rules": "^5.4.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IDataObject
|
||||
INodeTypeDescription
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
contactOperations,
|
||||
contactFields
|
||||
contactFields,
|
||||
contactOperations
|
||||
} from './ContactDescription';
|
||||
|
||||
import {
|
||||
companyOperations,
|
||||
companyFields
|
||||
companyFields,
|
||||
companyOperations
|
||||
} from './CompanyDescription';
|
||||
|
||||
import {
|
||||
dealOperations,
|
||||
dealFields
|
||||
dealFields,
|
||||
dealOperations
|
||||
} from './DealDescription';
|
||||
|
||||
import { agileCrmApiRequest, validateJSON, agileCrmApiRequestUpdate} from './GenericFunctions';
|
||||
import { IContact, IProperty, IContactUpdate } from './ContactInterface';
|
||||
import { IContact, IContactUpdate } from './ContactInterface';
|
||||
import { agileCrmApiRequest, agileCrmApiRequestUpdate, validateJSON} from './GenericFunctions';
|
||||
import { IDeal } from './DealInterface';
|
||||
|
||||
|
||||
export class AgileCrm implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'AgileCRM',
|
||||
name: 'agileCrm',
|
||||
icon: 'file:agilecrm.png',
|
||||
name: 'agileCrm',
|
||||
icon: 'file:agilecrm.png',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
description: 'Consume AgileCRM API',
|
||||
|
@ -39,8 +39,8 @@ export class AgileCrm implements INodeType {
|
|||
color: '#772244',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'agileCrmApi',
|
||||
required: true,
|
||||
|
@ -52,21 +52,21 @@ export class AgileCrm implements INodeType {
|
|||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Company',
|
||||
value: 'company'
|
||||
},
|
||||
{
|
||||
name: 'Contact',
|
||||
value: 'contact'
|
||||
name: 'Company',
|
||||
value: 'company'
|
||||
},
|
||||
{
|
||||
name: 'Deal',
|
||||
value: 'deal'
|
||||
},
|
||||
],
|
||||
name: 'Contact',
|
||||
value: 'contact'
|
||||
},
|
||||
{
|
||||
name: 'Deal',
|
||||
value: 'deal'
|
||||
},
|
||||
],
|
||||
default: 'contact',
|
||||
description: 'Resource to consume.',
|
||||
},
|
||||
|
@ -92,14 +92,13 @@ export class AgileCrm implements INodeType {
|
|||
const returnData: IDataObject[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let responseData;
|
||||
const qs: IDataObject = {};
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
||||
if(resource === 'contact' || resource === 'company'){
|
||||
let idGetter = resource === 'contact' ? 'contactId' : 'companyId';
|
||||
const idGetter = resource === 'contact' ? 'contactId' : 'companyId';
|
||||
|
||||
if(operation === 'get'){
|
||||
const contactId = this.getNodeParameter(idGetter, i) as string;
|
||||
|
@ -122,7 +121,7 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
if(resource === 'contact'){
|
||||
if (returnAll) {
|
||||
const endpoint = `api/contacts`;
|
||||
const endpoint = 'api/contacts';
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {});
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
|
@ -131,7 +130,7 @@ export class AgileCrm implements INodeType {
|
|||
}
|
||||
} else {
|
||||
if (returnAll) {
|
||||
const endpoint = `api/contacts/companies/list`;
|
||||
const endpoint = 'api/contacts/companies/list';
|
||||
responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, {});
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
|
@ -145,7 +144,7 @@ export class AgileCrm implements INodeType {
|
|||
if(operation === 'create'){
|
||||
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||
const body: IContact = {};
|
||||
let properties : IDataObject[] = [];
|
||||
const properties : IDataObject[] = [];
|
||||
|
||||
if (jsonParameters) {
|
||||
const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string;
|
||||
|
@ -218,7 +217,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'email',
|
||||
value: property.email as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
if(additionalFields.addressOptions){
|
||||
//@ts-ignore
|
||||
|
@ -229,7 +228,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'address',
|
||||
value: property.address as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if(additionalFields.phoneOptions){
|
||||
|
@ -241,7 +240,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'phone',
|
||||
value: property.number as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
} else if (resource === 'company') {
|
||||
if(additionalFields.email){
|
||||
|
@ -279,7 +278,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'webiste',
|
||||
value: property.url as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if(additionalFields.customProperties){
|
||||
|
@ -291,7 +290,7 @@ export class AgileCrm implements INodeType {
|
|||
name: property.name,
|
||||
value: property.value as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
body.properties = properties;
|
||||
|
||||
|
@ -302,10 +301,10 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
if(operation === 'update') {
|
||||
const contactId = this.getNodeParameter(idGetter, i) as string;
|
||||
let contactUpdatePayload : IContactUpdate = {id: contactId};
|
||||
const contactUpdatePayload : IContactUpdate = {id: contactId};
|
||||
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||
const body: IContact = {};
|
||||
let properties : IDataObject[] = [];
|
||||
const properties : IDataObject[] = [];
|
||||
|
||||
if (jsonParameters) {
|
||||
const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string;
|
||||
|
@ -372,7 +371,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'email',
|
||||
value: property.email as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
if(additionalFields.addressOptions){
|
||||
//@ts-ignore
|
||||
|
@ -383,7 +382,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'address',
|
||||
value: property.address as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if(additionalFields.phoneOptions){
|
||||
|
@ -395,7 +394,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'phone',
|
||||
value: property.number as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
} else if (resource === 'company') {
|
||||
if(additionalFields.email){
|
||||
|
@ -433,7 +432,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'webiste',
|
||||
value: property.url as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
if(additionalFields.customProperties){
|
||||
//@ts-ignore
|
||||
|
@ -444,7 +443,7 @@ export class AgileCrm implements INodeType {
|
|||
name: property.name,
|
||||
value: property.value as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
body.properties = properties;
|
||||
}
|
||||
|
@ -476,7 +475,7 @@ export class AgileCrm implements INodeType {
|
|||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
if (returnAll) {
|
||||
const endpoint = `api/opportunity`;
|
||||
const endpoint = 'api/opportunity';
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {});
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
|
@ -524,7 +523,7 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
}
|
||||
|
||||
let endpoint = 'api/opportunity'
|
||||
const endpoint = 'api/opportunity';
|
||||
responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, body);
|
||||
}
|
||||
|
||||
|
@ -574,7 +573,7 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
}
|
||||
|
||||
let endpoint = 'api/opportunity/partial-update'
|
||||
const endpoint = 'api/opportunity/partial-update';
|
||||
responseData = await agileCrmApiRequest.call(this, 'PUT', endpoint, body);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const contactOperations = [
|
||||
{
|
||||
|
@ -110,484 +110,484 @@ export const contactFields = [
|
|||
}
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'JSON Parameters',
|
||||
name: 'jsonParameters',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
{
|
||||
displayName: 'JSON Parameters',
|
||||
name: 'jsonParameters',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: ' Additional Fields',
|
||||
name: 'additionalFieldsJson',
|
||||
type: 'json',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
{
|
||||
displayName: ' Additional Fields',
|
||||
name: 'additionalFieldsJson',
|
||||
type: 'json',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
description: `Object of values to set as described <a href="https://github.com/agilecrm/rest-api#1-contacts---companies-api" target="_blank">here</a>.`,
|
||||
},
|
||||
|
||||
description: `Object of values to set as described <a href="https://github.com/agilecrm/rest-api#1-contacts---companies-api" target="_blank">here</a>.`,
|
||||
},
|
||||
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Star Value',
|
||||
name: 'starValue',
|
||||
type: 'options',
|
||||
default: '',
|
||||
required: false,
|
||||
description: 'Rating of contact (Max value 5). This is not applicable for companies.',
|
||||
options: [
|
||||
{
|
||||
name: '0',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: '1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: '2',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
name: '3',
|
||||
value: 3
|
||||
},
|
||||
{
|
||||
name: '4',
|
||||
value: 4
|
||||
},
|
||||
{
|
||||
name: '5',
|
||||
value: 5
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Lead Score',
|
||||
name: 'leadScore',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Score of contact. This is not applicable for companies.',
|
||||
required: false,
|
||||
typeOptions: {
|
||||
minValue: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
multipleValueButtonText: 'Add Tag',
|
||||
},
|
||||
default: [],
|
||||
placeholder: 'Tag',
|
||||
description: 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'First Name',
|
||||
description: 'Contact first name.',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'Last Name',
|
||||
description: 'Contact last name.',
|
||||
},
|
||||
{
|
||||
displayName: 'Company',
|
||||
name: 'company',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'Company',
|
||||
description: 'Company Name.',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'Title',
|
||||
description: 'Professional title.',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'emailOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contact email.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email Properties',
|
||||
name: 'emailProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of Email',
|
||||
options: [
|
||||
{
|
||||
name: 'Work',
|
||||
value: 'work'
|
||||
},
|
||||
{
|
||||
name: 'Personal',
|
||||
value: 'personal'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Email',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Address',
|
||||
name: 'addressOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contacts address.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Address Properties',
|
||||
name: 'addressProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of address.',
|
||||
options: [
|
||||
{
|
||||
name: 'Home',
|
||||
value: 'home'
|
||||
},
|
||||
{
|
||||
name: 'Postal',
|
||||
value: 'postal'
|
||||
}
|
||||
,
|
||||
{
|
||||
name: 'Office',
|
||||
value: 'office'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Address',
|
||||
name: 'address',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Full address.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Website',
|
||||
name: 'websiteOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contacts websites.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Website properties.',
|
||||
name: 'websiteProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of website.',
|
||||
options: [
|
||||
{
|
||||
name: 'URL',
|
||||
value: 'url',
|
||||
},
|
||||
{
|
||||
name: 'SKYPE',
|
||||
value: 'skype',
|
||||
},
|
||||
{
|
||||
name: 'TWITTER',
|
||||
value: 'twitter',
|
||||
},
|
||||
{
|
||||
name: 'LINKEDIN',
|
||||
value: 'linkedin',
|
||||
},
|
||||
{
|
||||
name: 'FACEBOOK',
|
||||
value: 'facebook',
|
||||
},
|
||||
{
|
||||
name: 'XING',
|
||||
value: 'xing',
|
||||
},
|
||||
{
|
||||
name: 'FEED',
|
||||
value: 'feed',
|
||||
},
|
||||
{
|
||||
name: 'GOOGLE_PLUS',
|
||||
value: 'googlePlus',
|
||||
},
|
||||
{
|
||||
name: 'FLICKR',
|
||||
value: 'flickr',
|
||||
},
|
||||
{
|
||||
name: 'GITHUB',
|
||||
value: 'github',
|
||||
},
|
||||
{
|
||||
name: 'YOUTUBE',
|
||||
value: 'youtube',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Website URL',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phoneOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contacts phone.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Phone properties',
|
||||
name: 'phoneProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of phone number.',
|
||||
options: [
|
||||
{
|
||||
name: 'Home',
|
||||
value: 'home'
|
||||
},
|
||||
{
|
||||
name: 'Work',
|
||||
value: 'work'
|
||||
}
|
||||
,
|
||||
{
|
||||
name: 'Mobile',
|
||||
value: 'mobile'
|
||||
},
|
||||
{
|
||||
name: 'Main',
|
||||
value: 'main'
|
||||
},
|
||||
{
|
||||
name: 'Home Fax',
|
||||
value: 'homeFax'
|
||||
},
|
||||
{
|
||||
name: 'Work Fax',
|
||||
value: 'workFax'
|
||||
},
|
||||
{
|
||||
name: 'Other',
|
||||
value: 'other'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'number',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Phone number.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Properties',
|
||||
name: 'customProperties',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Custom Properties',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Property',
|
||||
name: 'customProperty',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Property name.'
|
||||
},
|
||||
{
|
||||
displayName: 'Sub Type',
|
||||
name: 'subtype',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Property sub type.',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Property value.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Star Value',
|
||||
name: 'starValue',
|
||||
type: 'options',
|
||||
default: '',
|
||||
required: false,
|
||||
description: 'Rating of contact (Max value 5). This is not applicable for companies.',
|
||||
options: [
|
||||
{
|
||||
name: '0',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: '1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: '2',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
name: '3',
|
||||
value: 3
|
||||
},
|
||||
{
|
||||
name: '4',
|
||||
value: 4
|
||||
},
|
||||
{
|
||||
name: '5',
|
||||
value: 5
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Lead Score',
|
||||
name: 'leadScore',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Score of contact. This is not applicable for companies.',
|
||||
required: false,
|
||||
typeOptions: {
|
||||
minValue: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
multipleValueButtonText: 'Add Tag',
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
default: [],
|
||||
placeholder: 'Tag',
|
||||
description: 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'First Name',
|
||||
description: 'Contact first name.',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'Last Name',
|
||||
description: 'Contact last name.',
|
||||
},
|
||||
{
|
||||
displayName: 'Company',
|
||||
name: 'company',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'Company',
|
||||
description: 'Company Name.',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: 'Title',
|
||||
description: 'Professional title.',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'emailOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contact email.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email Properties',
|
||||
name: 'emailProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of Email',
|
||||
options: [
|
||||
{
|
||||
name: 'Work',
|
||||
value: 'work'
|
||||
},
|
||||
{
|
||||
name: 'Personal',
|
||||
value: 'personal'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Email',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Address',
|
||||
name: 'addressOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contacts address.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Address Properties',
|
||||
name: 'addressProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of address.',
|
||||
options: [
|
||||
{
|
||||
name: 'Home',
|
||||
value: 'home'
|
||||
},
|
||||
{
|
||||
name: 'Postal',
|
||||
value: 'postal'
|
||||
}
|
||||
,
|
||||
{
|
||||
name: 'Office',
|
||||
value: 'office'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Address',
|
||||
name: 'address',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Full address.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Website',
|
||||
name: 'websiteOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contacts websites.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Website properties.',
|
||||
name: 'websiteProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of website.',
|
||||
options: [
|
||||
{
|
||||
name: 'URL',
|
||||
value: 'url',
|
||||
},
|
||||
{
|
||||
name: 'SKYPE',
|
||||
value: 'skype',
|
||||
},
|
||||
{
|
||||
name: 'TWITTER',
|
||||
value: 'twitter',
|
||||
},
|
||||
{
|
||||
name: 'LINKEDIN',
|
||||
value: 'linkedin',
|
||||
},
|
||||
{
|
||||
name: 'FACEBOOK',
|
||||
value: 'facebook',
|
||||
},
|
||||
{
|
||||
name: 'XING',
|
||||
value: 'xing',
|
||||
},
|
||||
{
|
||||
name: 'FEED',
|
||||
value: 'feed',
|
||||
},
|
||||
{
|
||||
name: 'GOOGLE_PLUS',
|
||||
value: 'googlePlus',
|
||||
},
|
||||
{
|
||||
name: 'FLICKR',
|
||||
value: 'flickr',
|
||||
},
|
||||
{
|
||||
name: 'GITHUB',
|
||||
value: 'github',
|
||||
},
|
||||
{
|
||||
name: 'YOUTUBE',
|
||||
value: 'youtube',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Website URL',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phoneOptions',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Contacts phone.',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Phone properties',
|
||||
name: 'phoneProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Type of phone number.',
|
||||
options: [
|
||||
{
|
||||
name: 'Home',
|
||||
value: 'home'
|
||||
},
|
||||
{
|
||||
name: 'Work',
|
||||
value: 'work'
|
||||
}
|
||||
,
|
||||
{
|
||||
name: 'Mobile',
|
||||
value: 'mobile'
|
||||
},
|
||||
{
|
||||
name: 'Main',
|
||||
value: 'main'
|
||||
},
|
||||
{
|
||||
name: 'Home Fax',
|
||||
value: 'homeFax'
|
||||
},
|
||||
{
|
||||
name: 'Work Fax',
|
||||
value: 'workFax'
|
||||
},
|
||||
{
|
||||
name: 'Other',
|
||||
value: 'other'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'number',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Phone number.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Properties',
|
||||
name: 'customProperties',
|
||||
type: 'fixedCollection',
|
||||
required: false,
|
||||
description: 'Custom Properties',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Property',
|
||||
name: 'customProperty',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Property name.'
|
||||
},
|
||||
{
|
||||
displayName: 'Sub Type',
|
||||
name: 'subtype',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Property sub type.',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
placeholder: '',
|
||||
description: 'Property value.',
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'contact',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
default: '',
|
||||
description: 'Unique identifier for a particular contact',
|
||||
},
|
||||
default: '',
|
||||
description: 'Unique identifier for a particular contact',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
}
|
||||
|
||||
export interface IContact {
|
||||
type?: string,
|
||||
type?: string;
|
||||
star_value?: string;
|
||||
lead_score?: string;
|
||||
tags?: string[];
|
||||
|
@ -18,8 +18,8 @@ import {
|
|||
}
|
||||
|
||||
export interface IContactUpdate {
|
||||
id: string,
|
||||
properties?: IDataObject[],
|
||||
id: string;
|
||||
properties?: IDataObject[];
|
||||
star_value?: string;
|
||||
lead_score?: string;
|
||||
tags?: string[];
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export interface IDealCustomProperty {
|
||||
export interface IDealCustomProperty {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface IDeal {
|
||||
id?: number,
|
||||
expected_value?: number,
|
||||
probability?: number,
|
||||
name?: string,
|
||||
close_date?: number,
|
||||
milestone?: string,
|
||||
contactIds?: string[],
|
||||
customData?: IDealCustomProperty[]
|
||||
id?: number;
|
||||
expected_value?: number;
|
||||
probability?: number;
|
||||
name?: string;
|
||||
close_date?: number;
|
||||
milestone?: string;
|
||||
contactIds?: string[];
|
||||
customData?: IDealCustomProperty[];
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import {
|
||||
OptionsWithUri,
|
||||
OptionsWithUri
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
|
@ -12,7 +12,7 @@ import {
|
|||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { IContactUpdate } from './ContactInterface';
|
||||
import { IContactUpdate, IProperty } from './ContactInterface';
|
||||
|
||||
|
||||
export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
|
@ -51,7 +51,7 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
|
|||
|
||||
}
|
||||
|
||||
export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
const baseUri = 'https://n8nio.agilecrm.com/dev/';
|
||||
const credentials = this.getCredentials('agileCrmApi');
|
||||
const options: OptionsWithUri = {
|
||||
|
@ -68,9 +68,9 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
|||
json: true
|
||||
};
|
||||
|
||||
let successfulUpdates = [];
|
||||
const successfulUpdates = [];
|
||||
let lastSuccesfulUpdateReturn : any;
|
||||
let payload : IContactUpdate = body;
|
||||
const payload : IContactUpdate = body;
|
||||
|
||||
try {
|
||||
// Due to API, we must update each property separately
|
||||
|
@ -82,7 +82,7 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
|||
// Iterate trough properties and show them as individial updates instead of only vague "properties"
|
||||
payload.properties?.map((property : any) => {
|
||||
successfulUpdates.push(`${property.name} `);
|
||||
})
|
||||
});
|
||||
|
||||
delete options.body.properties;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
|||
|
||||
payload.tags?.map((tag : string) => {
|
||||
successfulUpdates.push(`(Tag) ${tag} `);
|
||||
})
|
||||
});
|
||||
|
||||
delete options.body.tags;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue