mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
✨ Add more functionality to Pipedrive-Node
This commit is contained in:
parent
1cc00d9101
commit
d80b703dfd
|
@ -13,6 +13,29 @@ import {
|
||||||
pipedriveApiRequestAllItems,
|
pipedriveApiRequestAllItems,
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
|
interface CustomProperty {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the additional fields to the body
|
||||||
|
*
|
||||||
|
* @param {IDataObject} body The body object to add fields to
|
||||||
|
* @param {IDataObject} additionalFields The fields to add
|
||||||
|
*/
|
||||||
|
function addAdditionalFields(body: IDataObject, additionalFields: IDataObject) {
|
||||||
|
for (const key of Object.keys(additionalFields)) {
|
||||||
|
if (key === 'customProperties' && (additionalFields.customProperties as IDataObject).property !== undefined) {
|
||||||
|
for (const customProperty of (additionalFields.customProperties as IDataObject)!.property! as CustomProperty[]) {
|
||||||
|
body[customProperty.name] = customProperty.value;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
body[key] = additionalFields[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Pipedrive implements INodeType {
|
export class Pipedrive implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
|
@ -50,6 +73,11 @@ export class Pipedrive implements INodeType {
|
||||||
value: 'createDeal',
|
value: 'createDeal',
|
||||||
description: 'Creates a deal',
|
description: 'Creates a deal',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Create Organization',
|
||||||
|
value: 'createOrganization',
|
||||||
|
description: 'Creates a Organization',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Create Person',
|
name: 'Create Person',
|
||||||
value: 'createPerson',
|
value: 'createPerson',
|
||||||
|
@ -65,6 +93,11 @@ export class Pipedrive implements INodeType {
|
||||||
value: 'deleteDeal',
|
value: 'deleteDeal',
|
||||||
description: 'Delete a deal',
|
description: 'Delete a deal',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Delete Organization',
|
||||||
|
value: 'deleteOrganization',
|
||||||
|
description: 'Delete a Organization',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Delete Person',
|
name: 'Delete Person',
|
||||||
value: 'deletePerson',
|
value: 'deletePerson',
|
||||||
|
@ -237,6 +270,39 @@ export class Pipedrive implements INodeType {
|
||||||
default: 0,
|
default: 0,
|
||||||
description: 'ID of the user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
|
description: 'ID of the user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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.',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -375,6 +441,125 @@ export class Pipedrive implements INodeType {
|
||||||
default: '3',
|
default: '3',
|
||||||
description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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.',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// createOrganization
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Name',
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'createOrganization',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The name of the organization to create',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Additional Fields',
|
||||||
|
name: 'additionalFields',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'createOrganization',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Visible to',
|
||||||
|
name: 'visible_to',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Owner & followers (private)',
|
||||||
|
value: '1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Entire company (shared)',
|
||||||
|
value: '3',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: '3',
|
||||||
|
description: 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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.',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -453,11 +638,45 @@ export class Pipedrive implements INodeType {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: '3',
|
default: '3',
|
||||||
description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
description: 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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.',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// deleteActivity
|
// deleteActivity
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -477,6 +696,7 @@ export class Pipedrive implements INodeType {
|
||||||
description: 'ID of the activity to delete.',
|
description: 'ID of the activity to delete.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// deleteDeal
|
// deleteDeal
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -496,6 +716,27 @@ export class Pipedrive implements INodeType {
|
||||||
description: 'ID of the deal to delete.',
|
description: 'ID of the deal to delete.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// deleteOrganization
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Organization ID',
|
||||||
|
name: 'organizationId',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'deleteOrganization',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: 0,
|
||||||
|
required: true,
|
||||||
|
description: 'ID of the organization to delete.',
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// deletePerson
|
// deletePerson
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -820,9 +1061,43 @@ export class Pipedrive implements INodeType {
|
||||||
default: 0,
|
default: 0,
|
||||||
description: 'ID of the user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
|
description: 'ID of the user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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.',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// updateDeal
|
// updateDeal
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -957,6 +1232,39 @@ export class Pipedrive implements INodeType {
|
||||||
default: '3',
|
default: '3',
|
||||||
description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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.',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1045,6 +1353,39 @@ export class Pipedrive implements INodeType {
|
||||||
default: '3',
|
default: '3',
|
||||||
description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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.',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1085,7 +1426,7 @@ export class Pipedrive implements INodeType {
|
||||||
body.done = this.getNodeParameter('done', i) as string;
|
body.done = this.getNodeParameter('done', i) as string;
|
||||||
body.type = this.getNodeParameter('type', i) as string;
|
body.type = this.getNodeParameter('type', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
Object.assign(body, additionalFields);
|
addAdditionalFields(body, additionalFields);
|
||||||
|
|
||||||
} else if (operation === 'createDeal') {
|
} else if (operation === 'createDeal') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -1097,7 +1438,19 @@ export class Pipedrive implements INodeType {
|
||||||
|
|
||||||
body.title = this.getNodeParameter('title', i) as string;
|
body.title = this.getNodeParameter('title', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
Object.assign(body, additionalFields);
|
addAdditionalFields(body, additionalFields);
|
||||||
|
|
||||||
|
} else if (operation === 'createOrganization') {
|
||||||
|
// ----------------------------------
|
||||||
|
// createOrganization
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
requestMethod = 'POST';
|
||||||
|
endpoint = '/organizations';
|
||||||
|
|
||||||
|
body.name = this.getNodeParameter('name', i) as string;
|
||||||
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
addAdditionalFields(body, additionalFields);
|
||||||
|
|
||||||
} else if (operation === 'createPerson') {
|
} else if (operation === 'createPerson') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -1109,7 +1462,7 @@ export class Pipedrive implements INodeType {
|
||||||
|
|
||||||
body.name = this.getNodeParameter('name', i) as string;
|
body.name = this.getNodeParameter('name', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
Object.assign(body, additionalFields);
|
addAdditionalFields(body, additionalFields);
|
||||||
|
|
||||||
} else if (operation === 'deleteActivity') {
|
} else if (operation === 'deleteActivity') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -1131,6 +1484,16 @@ export class Pipedrive implements INodeType {
|
||||||
const dealId = this.getNodeParameter('dealId', i) as number;
|
const dealId = this.getNodeParameter('dealId', i) as number;
|
||||||
endpoint = `/deals/${dealId}`;
|
endpoint = `/deals/${dealId}`;
|
||||||
|
|
||||||
|
} else if (operation === 'deleteOrganization') {
|
||||||
|
// ----------------------------------
|
||||||
|
// deleteOrganization
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
requestMethod = 'DELETE';
|
||||||
|
|
||||||
|
const organizationId = this.getNodeParameter('organizationId', i) as number;
|
||||||
|
endpoint = `/organizations/${organizationId}`;
|
||||||
|
|
||||||
} else if (operation === 'deletePerson') {
|
} else if (operation === 'deletePerson') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// deletePerson
|
// deletePerson
|
||||||
|
@ -1234,7 +1597,7 @@ export class Pipedrive implements INodeType {
|
||||||
endpoint = `/activities/${activityId}`;
|
endpoint = `/activities/${activityId}`;
|
||||||
|
|
||||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||||
Object.assign(body, updateFields);
|
addAdditionalFields(body, updateFields);
|
||||||
|
|
||||||
} else if (operation === 'updateDeal') {
|
} else if (operation === 'updateDeal') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -1247,7 +1610,7 @@ export class Pipedrive implements INodeType {
|
||||||
endpoint = `/deals/${dealId}`;
|
endpoint = `/deals/${dealId}`;
|
||||||
|
|
||||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||||
Object.assign(body, updateFields);
|
addAdditionalFields(body, updateFields);
|
||||||
|
|
||||||
} else if (operation === 'updatePerson') {
|
} else if (operation === 'updatePerson') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -1260,7 +1623,7 @@ export class Pipedrive implements INodeType {
|
||||||
endpoint = `/persons/${personId}`;
|
endpoint = `/persons/${personId}`;
|
||||||
|
|
||||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||||
Object.assign(body, updateFields);
|
addAdditionalFields(body, updateFields);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`The operation "${operation}" is not known!`);
|
throw new Error(`The operation "${operation}" is not known!`);
|
||||||
|
|
Loading…
Reference in a new issue