mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
⚡ Add label field to persons, organizations and deals (#1209)
* ⚡ Add label field to persons, organizations and deals * ⚡ Add option no label to label field * ⚡ Add organization:update operation * ⚡ Fix removing label from Organization on Pipedrive-Node Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
83aed4d2b9
commit
da450dcb41
|
@ -75,7 +75,6 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio
|
|||
}
|
||||
|
||||
query.api_token = credentials.apiToken;
|
||||
|
||||
//@ts-ignore
|
||||
responseData = await this.helpers.request(options);
|
||||
|
||||
|
|
|
@ -353,12 +353,11 @@ export class Pipedrive implements INodeType {
|
|||
value: 'getAll',
|
||||
description: 'Get data of all organizations',
|
||||
},
|
||||
// TODO: Currently missing
|
||||
// {
|
||||
// name: 'Update',
|
||||
// value: 'update',
|
||||
// description: 'Update an organization',
|
||||
// },
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update an organization',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
|
@ -840,6 +839,48 @@ export class Pipedrive implements INodeType {
|
|||
default: 'USD',
|
||||
description: 'Currency of the deal. Accepts a 3-character currency code. Like EUR, USD, ...',
|
||||
},
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getDealLabels',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Lost Reason',
|
||||
name: 'lost_reason',
|
||||
|
@ -935,39 +976,6 @@ export class Pipedrive implements INodeType {
|
|||
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.',
|
||||
},
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -1082,6 +1090,48 @@ export class Pipedrive implements INodeType {
|
|||
default: 'USD',
|
||||
description: 'Currency of the deal. Accepts a 3-character currency code. Like EUR, USD, ...',
|
||||
},
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getDealLabels',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Lost Reason',
|
||||
name: 'lost_reason',
|
||||
|
@ -1177,39 +1227,6 @@ export class Pipedrive implements INodeType {
|
|||
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.',
|
||||
},
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -1613,23 +1630,6 @@ export class Pipedrive implements INodeType {
|
|||
},
|
||||
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',
|
||||
|
@ -1663,6 +1663,32 @@ export class Pipedrive implements INodeType {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getOrganizationLabels',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -1710,6 +1736,120 @@ export class Pipedrive implements INodeType {
|
|||
description: 'ID of the organization to get.',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// organization:update
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'number',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'organization',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the organization to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'organization',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getOrganizationLabels',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Organization name',
|
||||
},
|
||||
{
|
||||
displayName: 'Owner ID',
|
||||
name: 'owner_id',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: 'The ID of the user who will be marked as the owner of this Organization. When omitted, the authorized User ID will be used.',
|
||||
},
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
|
@ -1754,6 +1894,39 @@ export class Pipedrive implements INodeType {
|
|||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
|
@ -1764,6 +1937,15 @@ export class Pipedrive implements INodeType {
|
|||
default: '',
|
||||
description: 'Email of the person.',
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getPersonLabels',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'org_id',
|
||||
|
@ -1798,39 +1980,6 @@ export class Pipedrive implements INodeType {
|
|||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -1917,6 +2066,39 @@ export class Pipedrive implements INodeType {
|
|||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
|
@ -1927,6 +2109,15 @@ export class Pipedrive implements INodeType {
|
|||
default: '',
|
||||
description: 'Email of the person.',
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getPersonLabels',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
|
@ -1968,39 +2159,6 @@ export class Pipedrive implements INodeType {
|
|||
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.',
|
||||
},
|
||||
{
|
||||
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.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -2271,6 +2429,84 @@ export class Pipedrive implements INodeType {
|
|||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the person labels to display them to user so that he can
|
||||
// select them easily
|
||||
async getPersonLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const operation = this.getCurrentNodeParameter('operation') as string;
|
||||
const { data } = await pipedriveApiRequest.call(this, 'GET', '/personFields', {});
|
||||
for (const field of data) {
|
||||
if (field.key === 'label') {
|
||||
if (field.options) {
|
||||
for (const option of field.options) {
|
||||
returnData.push({
|
||||
name: option.label,
|
||||
value: option.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
returnData.push({
|
||||
name: 'No Label',
|
||||
value: 'null',
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the labels to display them to user so that he can
|
||||
// select them easily
|
||||
async getOrganizationLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const operation = this.getCurrentNodeParameter('operation') as string;
|
||||
const { data } = await pipedriveApiRequest.call(this, 'GET', '/organizationFields', {});
|
||||
for (const field of data) {
|
||||
if (field.key === 'label') {
|
||||
if (field.options) {
|
||||
for (const option of field.options) {
|
||||
returnData.push({
|
||||
name: option.label,
|
||||
value: option.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
returnData.push({
|
||||
name: 'No Label',
|
||||
value: 'null',
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the labels to display them to user so that he can
|
||||
// select them easily
|
||||
async getDealLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const operation = this.getCurrentNodeParameter('operation') as string;
|
||||
const { data } = await pipedriveApiRequest.call(this, 'GET', '/dealFields', {});
|
||||
for (const field of data) {
|
||||
if (field.key === 'label') {
|
||||
if (field.options) {
|
||||
for (const option of field.options) {
|
||||
returnData.push({
|
||||
name: option.label,
|
||||
value: option.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
returnData.push({
|
||||
name: 'No Label',
|
||||
value: 'null',
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -2455,8 +2691,10 @@ export class Pipedrive implements INodeType {
|
|||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body, updateFields);
|
||||
|
||||
if (body.label === 'null') {
|
||||
body.label = null;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (resource === 'file') {
|
||||
if (operation === 'create') {
|
||||
// ----------------------------------
|
||||
|
@ -2633,6 +2871,24 @@ export class Pipedrive implements INodeType {
|
|||
endpoint = `/organizations`;
|
||||
|
||||
}
|
||||
if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// organization:update
|
||||
// ----------------------------------
|
||||
|
||||
const id = this.getNodeParameter('organizationId', i) as string;
|
||||
|
||||
requestMethod = 'PUT';
|
||||
endpoint = `/organizations/${id}`;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body, updateFields);
|
||||
|
||||
if (body.label === 'null') {
|
||||
body.label = null;
|
||||
}
|
||||
|
||||
}
|
||||
} else if (resource === 'person') {
|
||||
if (operation === 'create') {
|
||||
// ----------------------------------
|
||||
|
@ -2736,6 +2992,10 @@ export class Pipedrive implements INodeType {
|
|||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body, updateFields);
|
||||
|
||||
if (body.label === 'null') {
|
||||
body.label = null;
|
||||
}
|
||||
|
||||
}
|
||||
} else if (resource === 'product') {
|
||||
if (operation === 'getAll') {
|
||||
|
|
Loading…
Reference in a new issue