n8n/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts

3648 lines
86 KiB
TypeScript
Raw Normal View History

2019-06-23 12:21:44 -07:00
import {
BINARY_ENCODING,
2019-06-23 12:21:44 -07:00
IExecuteFunctions,
ILoadOptionsFunctions,
2019-06-23 12:21:44 -07:00
} from 'n8n-core';
import {
IDataObject,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
NodeOperationError,
2019-06-23 12:21:44 -07:00
} from 'n8n-workflow';
import {
ICustomProperties,
2019-06-23 12:21:44 -07:00
pipedriveApiRequest,
pipedriveApiRequestAllItems,
pipedriveEncodeCustomProperties,
pipedriveGetCustomProperties,
pipedriveResolveCustomProperties,
2019-06-23 12:21:44 -07:00
} 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];
}
}
}
2019-06-23 12:21:44 -07:00
export class Pipedrive implements INodeType {
description: INodeTypeDescription = {
displayName: 'Pipedrive',
name: 'pipedrive',
icon: 'file:pipedrive.png',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
2019-06-23 22:24:47 -07:00
description: 'Create and edit data in Pipedrive',
2019-06-23 12:21:44 -07:00
defaults: {
name: 'Pipedrive',
color: '#227722',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'pipedriveApi',
required: true,
2020-06-09 06:48:40 -07:00
displayOptions: {
show: {
authentication: [
'apiToken',
2020-06-09 06:48:40 -07:00
],
},
},
},
{
name: 'pipedriveOAuth2Api',
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
},
},
},
2019-06-23 12:21:44 -07:00
],
properties: [
2020-06-09 06:48:40 -07:00
{
displayName: 'Authentication',
name: 'authentication',
type: 'options',
options: [
{
name: 'API Token',
2020-10-22 06:46:03 -07:00
value: 'apiToken',
2020-06-09 06:48:40 -07:00
},
{
name: 'OAuth2',
value: 'oAuth2',
},
],
default: 'apiToken',
2020-06-24 07:02:44 -07:00
description: 'Method of authentication.',
2020-06-09 06:48:40 -07:00
},
2019-06-23 12:21:44 -07:00
{
displayName: 'Resource',
name: 'resource',
2019-06-23 12:21:44 -07:00
type: 'options',
options: [
{
name: 'Activity',
value: 'activity',
},
{
name: 'Deal',
value: 'deal',
2019-06-23 12:21:44 -07:00
},
{
name: 'File',
value: 'file',
},
{
name: 'Note',
value: 'note',
},
2019-06-23 12:21:44 -07:00
{
name: 'Organization',
value: 'organization',
2019-06-23 12:21:44 -07:00
},
{
name: 'Person',
value: 'person',
},
{
name: 'Product',
value: 'product',
},
],
default: 'deal',
description: 'The resource to operate on.',
},
// ----------------------------------
// operations
// ----------------------------------
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'activity',
],
},
},
options: [
2019-06-23 12:21:44 -07:00
{
name: 'Create',
value: 'create',
description: 'Create an activity',
2019-06-23 12:21:44 -07:00
},
{
name: 'Delete',
value: 'delete',
2019-06-23 12:21:44 -07:00
description: 'Delete an activity',
},
{
name: 'Get',
value: 'get',
description: 'Get data of an activity',
2019-06-23 12:21:44 -07:00
},
{
name: 'Get All',
value: 'getAll',
description: 'Get data of all activities',
},
{
name: 'Update',
value: 'update',
description: 'Update an activity',
},
],
default: 'create',
description: 'The operation to perform.',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'deal',
],
},
},
options: [
2019-06-23 12:21:44 -07:00
{
name: 'Create',
value: 'create',
description: 'Create a deal',
2019-06-23 12:21:44 -07:00
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a deal',
2019-06-23 12:21:44 -07:00
},
{
name: 'Duplicate',
value: 'duplicate',
description: 'Duplicate a deal',
},
2019-06-23 12:21:44 -07:00
{
name: 'Get',
value: 'get',
2019-06-23 12:21:44 -07:00
description: 'Get data of a deal',
},
{
name: 'Get All',
value: 'getAll',
description: 'Get data of all deals',
},
{
name: 'Search',
value: 'search',
description: 'Search a deal',
},
2019-06-23 12:21:44 -07:00
{
name: 'Update',
value: 'update',
description: 'Update a deal',
},
],
default: 'create',
description: 'The operation to perform.',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'file',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a file',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a file',
},
{
name: 'Download',
value: 'download',
description: 'Download a file',
},
{
name: 'Get',
value: 'get',
description: 'Get data of a file',
},
// {
// name: 'Get All',
// value: 'getAll',
// description: 'Get data of all file',
// },
// {
// name: 'Update',
// value: 'update',
// description: 'Update a file',
// },
],
default: 'create',
description: 'The operation to perform.',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'note',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a note',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a note',
},
{
name: 'Get',
value: 'get',
description: 'Get data of a note',
},
{
name: 'Get All',
value: 'getAll',
description: 'Get data of all notes',
},
{
name: 'Update',
value: 'update',
description: 'Update a note',
},
],
default: 'create',
description: 'The operation to perform.',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'organization',
],
2019-06-23 12:21:44 -07:00
},
},
options: [
2019-06-23 12:21:44 -07:00
{
name: 'Create',
value: 'create',
description: 'Create an organization',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete an organization',
},
{
name: 'Get',
value: 'get',
description: 'Get data of an organization',
2019-06-23 12:21:44 -07:00
},
{
name: 'Get All',
value: 'getAll',
description: 'Get data of all organizations',
},
{
name: 'Update',
value: 'update',
description: 'Update an organization',
},
],
default: 'create',
description: 'The operation to perform.',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'person',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a person',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a person',
},
2019-06-23 12:21:44 -07:00
{
name: 'Get',
value: 'get',
description: 'Get data of a person',
2019-06-23 12:21:44 -07:00
},
{
name: 'Get All',
value: 'getAll',
description: 'Get data of all persons',
2019-06-23 12:21:44 -07:00
},
{
name: 'Search',
value: 'search',
description: 'Search all persons',
},
2019-06-23 12:21:44 -07:00
{
name: 'Update',
value: 'update',
2019-06-23 12:21:44 -07:00
description: 'Update a person',
},
],
default: 'create',
description: 'The operation to perform.',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'product',
],
},
},
options: [
{
name: 'Get All',
value: 'getAll',
description: 'Get data of all products',
},
],
default: 'getAll',
2019-06-23 12:21:44 -07:00
description: 'The operation to perform.',
},
2019-06-23 12:21:44 -07:00
// ----------------------------------
// Activity
// ----------------------------------
// ----------------------------------
// activity:create
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'activity',
2019-06-23 12:21:44 -07:00
],
},
},
description: 'The subject of the activity to create',
},
{
displayName: 'Done',
name: 'done',
type: 'options',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'activity',
2019-06-23 12:21:44 -07:00
],
},
},
options: [
{
name: 'Not done',
value: '0',
},
{
name: 'Done',
value: '1',
},
],
default: '0',
description: 'Whether the activity is done or not.',
},
{
displayName: 'Type',
name: 'type',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'activity',
2019-06-23 12:21:44 -07:00
],
},
},
placeholder: 'call',
description: 'Type of the activity like "call", "meeting", ...',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'activity',
2019-06-23 12:21:44 -07:00
],
},
},
default: {},
options: [
{
displayName: 'Deal ID',
name: 'deal_id',
type: 'number',
default: 0,
description: 'ID of the deal this activity will be associated with',
},
{
displayName: 'Due Date',
name: 'due_date',
type: 'dateTime',
default: '',
description: 'Due Date to activity be done YYYY-MM-DD',
},
2019-06-23 12:21:44 -07:00
{
displayName: 'Note',
name: 'note',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
rows: 5,
},
default: '',
description: 'Note of the activity (HTML format)',
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
2019-06-23 12:21:44 -07:00
description: 'ID of the organization this activity will be associated with',
},
{
displayName: 'Person ID',
name: 'person_id',
type: 'number',
default: 0,
description: 'ID of the person this activity will be associated with',
},
{
displayName: 'User ID',
name: 'user_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getUserIds',
},
default: '',
description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
2019-06-23 12:21:44 -07:00
},
{
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.',
},
2020-10-22 06:46:03 -07:00
],
},
],
},
2019-06-23 12:21:44 -07:00
],
},
// ----------------------------------
// activity:delete
// ----------------------------------
{
displayName: 'Activity ID',
name: 'activityId',
type: 'number',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'activity',
],
},
},
default: 0,
required: true,
description: 'ID of the activity to delete.',
},
2019-06-23 12:21:44 -07:00
// ----------------------------------
// activity:get
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Activity ID',
name: 'activityId',
type: 'number',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'get',
],
resource: [
'activity',
],
},
},
default: 0,
2019-06-23 12:21:44 -07:00
required: true,
description: 'ID of the activity to get.',
},
// ----------------------------------
// activity:update
// ----------------------------------
{
displayName: 'Activity ID',
name: 'activityId',
type: 'number',
2019-06-23 12:21:44 -07:00
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'update',
],
resource: [
'activity',
2019-06-23 12:21:44 -07:00
],
},
},
default: 0,
required: true,
description: 'ID of the activity to update.',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Update Fields',
name: 'updateFields',
2019-06-23 12:21:44 -07:00
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'update',
],
resource: [
'activity',
2019-06-23 12:21:44 -07:00
],
},
},
default: {},
options: [
{
displayName: 'Deal ID',
name: 'deal_id',
type: 'number',
default: 0,
description: 'ID of the deal this activity will be associated with',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Due Date',
name: 'due_date',
type: 'dateTime',
default: '',
description: 'Due Date to activity be done YYYY-MM-DD',
},
2019-06-23 12:21:44 -07:00
{
displayName: 'Done',
name: 'done',
type: 'options',
options: [
{
name: 'Not done',
value: '0',
},
{
name: 'Done',
value: '1',
},
],
default: '0',
description: 'Whether the activity is done or not.',
},
{
displayName: 'Note',
name: 'note',
2019-06-23 12:21:44 -07:00
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
rows: 5,
},
2019-06-23 12:21:44 -07:00
default: '',
description: 'Note of the activity (HTML format)',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this activity will be associated with',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Person ID',
name: 'person_id',
type: 'number',
default: 0,
description: 'ID of the person this activity will be associated with',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
description: 'The subject of the activity',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Type',
name: 'type',
type: 'string',
default: '',
placeholder: 'call',
description: 'Type of the activity like "call", "meeting", ...',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'User ID',
name: 'user_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getUserIds',
},
default: '',
description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
2019-06-23 12:21:44 -07:00
},
{
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.',
},
2020-10-22 06:46:03 -07:00
],
},
],
},
],
},
// ----------------------------------
// deal
// ----------------------------------
2019-06-23 12:21:44 -07:00
// ----------------------------------
// deal:create
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Title',
name: 'title',
2019-06-23 12:21:44 -07:00
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'deal',
2019-06-23 12:21:44 -07:00
],
},
},
description: 'The title of the deal to create',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'deal',
2019-06-23 12:21:44 -07:00
],
},
},
default: {},
options: [
{
displayName: 'Currency',
name: 'currency',
type: 'string',
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: 'options',
typeOptions: {
loadOptionsMethod: 'getDealCustomFields',
},
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',
2019-06-23 12:21:44 -07:00
type: 'string',
default: '',
description: 'Reason why the deal was lost.',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this deal will be associated with.',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Person ID',
name: 'person_id',
type: 'number',
default: 0,
description: 'ID of the person this deal will be associated with.',
},
{
displayName: 'Probability',
name: 'probability',
type: 'number',
2019-06-23 12:21:44 -07:00
typeOptions: {
minValue: 0,
maxValue: 100,
2019-06-23 12:21:44 -07:00
},
default: 0,
description: 'Deal success probability percentage.',
},
{
displayName: 'Stage ID',
name: 'stage_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getStageIds',
},
default: '',
description: 'ID of the stage this deal will be placed in a pipeline. If omitted, the deal will be placed in the first stage of the default pipeline. (PIPELINE > STAGE)',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'Open',
value: 'open',
},
{
name: 'Won',
value: 'won',
},
{
name: 'Lost',
value: 'lost',
},
{
name: 'Deleted',
value: 'deleted',
},
],
default: 'open',
description: 'The status of the deal. If not provided it will automatically be set to "open".',
},
{
displayName: 'User ID',
name: 'user_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getUserIds',
},
default: '',
description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
},
{
displayName: 'Value',
name: 'value',
type: 'number',
default: 0,
description: 'Value of the deal. If not set it will automatically be set to 0.',
2019-06-23 12:21:44 -07:00
},
{
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 deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
},
2019-06-23 12:21:44 -07:00
],
},
// ----------------------------------
// deal:delete
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
type: 'number',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'deal',
2019-06-23 12:21:44 -07:00
],
},
},
default: 0,
required: true,
description: 'ID of the deal to delete.',
},
// ----------------------------------
// deal:duplicate
// ----------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
type: 'number',
displayOptions: {
show: {
operation: [
'duplicate',
],
resource: [
'deal',
],
},
},
default: 0,
required: true,
description: 'ID of the deal to duplicate.',
},
// ----------------------------------
// deal:get
// ----------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
type: 'number',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'get',
],
resource: [
'deal',
],
},
},
default: 0,
required: true,
description: 'ID of the deal to get.',
},
2019-06-23 12:21:44 -07:00
// ----------------------------------
// deal:update
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
2019-06-23 12:21:44 -07:00
type: 'number',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'update',
],
resource: [
'deal',
2019-06-23 12:21:44 -07:00
],
},
},
default: 0,
required: true,
description: 'ID of the deal to update.',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'update',
],
resource: [
'deal',
],
},
},
default: {},
options: [
{
displayName: 'Currency',
name: 'currency',
type: 'string',
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: 'options',
typeOptions: {
loadOptionsMethod: 'getDealCustomFields',
},
default: '',
description: 'Name of the custom field to set.',
},
{
displayName: 'Property Value',
name: 'value',
type: 'string',
default: '',
description: 'Value of the property to set.',
},
],
},
],
},
{
displayName: 'User ID',
name: 'user_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getUserIds',
},
default: '',
description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.',
},
{
displayName: 'Label',
name: 'label',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getDealLabels',
},
default: '',
},
{
displayName: 'Lost Reason',
name: 'lost_reason',
type: 'string',
default: '',
description: 'Reason why the deal was lost.',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this deal will be associated with.',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Person ID',
name: 'person_id',
type: 'number',
default: 0,
description: 'ID of the person this deal will be associated with.',
},
{
displayName: 'Probability',
name: 'probability',
type: 'number',
typeOptions: {
minValue: 0,
maxValue: 100,
},
default: 0,
description: 'Deal success probability percentage.',
},
{
displayName: 'Stage ID',
name: 'stage_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getStageIds',
},
default: '',
description: 'ID of the stage this deal will be placed in a pipeline. If omitted, the deal will be placed in the first stage of the default pipeline. (PIPELINE > STAGE)',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'Open',
value: 'open',
},
{
name: 'Won',
value: 'won',
},
{
name: 'Lost',
value: 'lost',
},
{
name: 'Deleted',
value: 'deleted',
},
2019-06-23 12:21:44 -07:00
],
default: 'open',
description: 'The status of the deal. If not provided it will automatically be set to "open".',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
description: 'The title of the deal',
},
{
displayName: 'Value',
name: 'value',
type: 'number',
default: 0,
description: 'Value of the deal. If not set it will automatically be set to 0.',
},
{
displayName: 'Visible to',
name: 'visible_to',
type: 'options',
options: [
{
name: 'Owner & followers (private)',
value: '1',
},
{
name: 'Entire company (shared)',
value: '3',
},
2019-06-23 12:21:44 -07:00
],
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.',
2019-06-23 12:21:44 -07:00
},
],
},
// ----------------------------------
// deal:search
// ----------------------------------
{
displayName: 'Term',
name: 'term',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'deal',
],
},
},
default: '',
description: 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).',
},
{
displayName: 'Exact Match',
name: 'exactMatch',
type: 'boolean',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'deal',
],
},
},
default: false,
description: 'When enabled, only full exact matches against the given term are returned. It is not case sensitive.',
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: [
'search',
],
},
},
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: [
'search',
],
returnAll: [
false,
],
},
},
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 100,
description: 'How many results to return.',
}, {
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'deal',
],
},
},
default: {},
options: [
{
displayName: 'Include Fields',
name: 'includeFields',
type: 'string',
default: '',
description: 'Supports including optional fields in the results which are not provided by default. Example: deal.cc_email',
},
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'string',
default: '',
description: 'Will filter Deals by the provided Organization ID.',
},
{
displayName: 'Person ID',
name: 'personId',
type: 'string',
default: '',
description: 'Will filter Deals by the provided Person ID.',
},
{
displayName: 'Search Fields',
name: 'fields',
type: 'multiOptions',
options: [
{
name: 'Custom Fields',
value: 'custom_fields',
},
{
name: 'Notes',
value: 'notes',
},
{
name: 'Title',
value: 'title',
},
],
default: [
'custom_fields',
'notes',
'title',
],
description: 'A comma-separated string array. The fields to perform the search from. Defaults to all of them.',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'Open',
value: 'open',
},
{
name: 'Won',
value: 'won',
},
{
name: 'Lost',
value: 'lost',
},
],
default: 'open',
description: 'The status of the deal. If not provided it will automatically be set to "open".',
},
],
},
// ----------------------------------
// file
// ----------------------------------
// ----------------------------------
// file:create
// ----------------------------------
{
displayName: 'Binary Property',
name: 'binaryPropertyName',
type: 'string',
default: 'data',
required: true,
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'create',
],
resource: [
'file',
],
},
},
placeholder: '',
description: 'Name of the binary property which contains<br />the data for the file to be created.',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'file',
],
},
},
default: {},
options: [
{
displayName: 'Activity ID',
name: 'activity_id',
type: 'number',
default: 0,
description: 'ID of the activite this file will be associated with.',
},
{
displayName: 'Deal ID',
name: 'deal_id',
type: 'number',
default: 0,
description: 'ID of the deal this file will be associated with',
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this deal will be associated with.',
},
{
displayName: 'Person ID',
name: 'person_id',
type: 'number',
default: 0,
description: 'ID of the person this file will be associated with.',
},
{
displayName: 'Product ID',
name: 'product_id',
type: 'number',
default: 0,
description: 'ID of the person this file will be associated with.',
},
],
},
// ----------------------------------
// file:delete
// ----------------------------------
{
displayName: 'File ID',
name: 'fileId',
type: 'number',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'file',
],
},
},
default: 0,
required: true,
description: 'ID of the file to delete.',
},
// ----------------------------------
// file:download
// ----------------------------------
{
displayName: 'File ID',
name: 'fileId',
type: 'number',
displayOptions: {
show: {
operation: [
'download',
],
resource: [
'file',
],
},
},
default: 0,
required: true,
description: 'ID of the file to download.',
},
{
displayName: 'Binary Property',
name: 'binaryPropertyName',
type: 'string',
required: true,
default: 'data',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'download',
],
resource: [
'file',
],
},
},
description: 'Name of the binary property to which to<br />write the data of the downloaded file.',
},
// ----------------------------------
// file:get
// ----------------------------------
{
displayName: 'File ID',
name: 'fileId',
type: 'number',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'get',
],
resource: [
'file',
],
},
},
default: 0,
required: true,
description: 'ID of the file to get.',
},
// ----------------------------------
// note
// ----------------------------------
// ----------------------------------
// note:create
// ----------------------------------
{
displayName: 'Content',
name: 'content',
typeOptions: {
rows: 5,
},
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'note',
],
},
},
description: 'The content of the note to create',
},
// {
// displayName: 'Additional Fields',
// name: 'additionalFields',
// type: 'collection',
// placeholder: 'Add Field',
// displayOptions: {
// show: {
// operation: [
// 'create',
// 'getAll',
// ],
// resource: [
// 'note',
// ],
// },
// },
// default: {},
// options: [
// {
// displayName: 'Deal ID',
// name: 'deal_id',
// type: 'number',
// default: 0,
// description: 'ID of the deal this note will be associated with',
// },
// {
// displayName: 'Organization ID',
// name: 'org_id',
// type: 'options',
// typeOptions: {
// loadOptionsMethod: 'getOrganizationIds',
// },
// default: '',
// description: 'ID of the organization this deal will be associated with.',
// },
// {
// displayName: 'Person ID',
// name: 'person_id',
// type: 'number',
// default: 0,
// description: 'ID of the person this note will be associated with.',
// },
// ],
// },
// ----------------------------------
// note:delete
// ----------------------------------
{
displayName: 'Note ID',
name: 'noteId',
type: 'number',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'note',
],
},
},
default: 0,
required: true,
description: 'ID of the note to delete.',
},
// ----------------------------------
// note:get
// ----------------------------------
{
displayName: 'Note ID',
name: 'noteId',
type: 'number',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'get',
],
resource: [
'note',
],
},
},
default: 0,
required: true,
description: 'ID of the note to get.',
},
// ----------------------------------
// note:update
// ----------------------------------
{
displayName: 'Note ID',
name: 'noteId',
type: 'number',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'update',
],
resource: [
'note',
],
},
},
default: 0,
required: true,
description: 'ID of the note to update.',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
2020-10-22 06:46:03 -07:00
'update',
],
resource: [
'note',
],
},
},
default: {},
options: [
{
displayName: 'Content',
name: 'content',
typeOptions: {
rows: 5,
},
type: 'string',
default: '',
description: 'The content of the note',
},
{
displayName: 'Deal ID',
name: 'deal_id',
type: 'number',
default: 0,
description: 'ID of the deal this note will be associated with',
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this deal will be associated with.',
},
{
displayName: 'Person ID',
name: 'person_id',
type: 'number',
default: 0,
description: 'ID of the person this note will be associated with.',
},
],
},
2019-06-23 12:21:44 -07:00
// ----------------------------------
// organization
2019-06-23 12:21:44 -07:00
// ----------------------------------
// ----------------------------------
// organization:create
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
required: true,
2019-06-23 12:21:44 -07:00
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'organization',
2019-06-23 12:21:44 -07:00
],
},
},
description: 'The name of the organization to create',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
2019-06-23 12:21:44 -07:00
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'organization',
2019-06-23 12:21:44 -07:00
],
},
},
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.',
},
2020-10-22 06:46:03 -07:00
],
},
],
},
{
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.',
},
],
},
// ----------------------------------
// organization:delete
// ----------------------------------
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'number',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'organization',
],
},
},
default: 0,
required: true,
description: 'ID of the organization to delete.',
},
// ----------------------------------
// organization:get
// ----------------------------------
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'number',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'organization',
],
},
},
default: 0,
required: true,
description: 'ID of the organization to get.',
},
2019-06-23 12:21:44 -07:00
// ----------------------------------
// organization:update
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'number',
default: '',
required: true,
2019-06-23 12:21:44 -07:00
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'organization',
2019-06-23 12:21:44 -07:00
],
},
},
description: 'The ID of the organization to create',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Update Fields',
name: 'updateFields',
2019-06-23 12:21:44 -07:00
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'organization',
2019-06-23 12:21:44 -07:00
],
},
},
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.',
},
],
},
],
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Label',
name: 'label',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationLabels',
},
default: '',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Name',
name: 'name',
type: 'string',
2019-06-23 12:21:44 -07:00
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.',
2019-06-23 12:21:44 -07:00
},
{
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.',
2019-06-23 12:21:44 -07:00
},
],
},
// ----------------------------------
// person
// ----------------------------------
// ----------------------------------
// person:create
// ----------------------------------
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'person',
],
},
},
description: 'The name of the person to create',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'person',
],
},
},
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: 'options',
typeOptions: {
loadOptionsMethod: 'getPersonCustomFields',
},
default: '',
description: 'Name of the custom field to set.',
},
{
displayName: 'Property Value',
name: 'value',
type: 'string',
default: '',
description: 'Value of the property to set.',
},
2020-10-22 06:46:03 -07:00
],
},
],
},
{
displayName: 'Email',
name: 'email',
type: 'string',
typeOptions: {
multipleValues: true,
},
default: '',
description: 'Email of the person.',
},
{
displayName: 'Label',
name: 'label',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getPersonLabels',
},
default: '',
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this deal will be associated with.',
},
{
displayName: 'Phone',
name: 'phone',
type: 'string',
typeOptions: {
multipleValues: true,
},
default: '',
description: 'Phone number of the person.',
},
{
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.',
},
2019-06-23 12:21:44 -07:00
],
},
// ----------------------------------
// person:delete
// ----------------------------------
{
displayName: 'Person ID',
name: 'personId',
type: 'number',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'person',
],
},
},
default: 0,
required: true,
description: 'ID of the person to delete.',
},
// ----------------------------------
// person:get
// ----------------------------------
{
displayName: 'Person ID',
name: 'personId',
type: 'number',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'person',
],
},
},
default: 0,
required: true,
description: 'ID of the person to get.',
},
2019-06-23 12:21:44 -07:00
// ----------------------------------
// person:update
2019-06-23 12:21:44 -07:00
// ----------------------------------
{
displayName: 'Person ID',
name: 'personId',
type: 'number',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'person',
2019-06-23 12:21:44 -07:00
],
},
},
default: 0,
required: true,
description: 'ID of the person to update.',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
description: 'The fields to update.',
2019-06-23 12:21:44 -07:00
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'person',
2019-06-23 12:21:44 -07:00
],
},
},
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: 'options',
typeOptions: {
loadOptionsMethod: 'getPersonCustomFields',
},
default: '',
description: 'Name of the custom field to set.',
},
{
displayName: 'Property Value',
name: 'value',
type: 'string',
default: '',
description: 'Value of the property to set.',
},
],
},
],
},
2019-06-23 12:21:44 -07:00
{
displayName: 'Email',
name: 'email',
type: 'string',
typeOptions: {
multipleValues: true,
},
default: '',
description: 'Email of the person.',
},
{
displayName: 'Label',
name: 'label',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getPersonLabels',
},
default: '',
},
2019-06-23 12:21:44 -07:00
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'The name of the person',
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this deal will be associated with.',
2019-06-23 12:21:44 -07:00
},
{
displayName: 'Phone',
name: 'phone',
type: 'string',
typeOptions: {
multipleValues: true,
},
default: '',
description: 'Phone number of the person.',
},
{
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 deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
},
],
},
// ----------------------------------
// activity / deal / note / organization / person / product
// ----------------------------------
{
displayName: 'Resolve Properties',
name: 'resolveProperties',
type: 'boolean',
displayOptions: {
show: {
resource: [
'activity',
'deal',
'organization',
'person',
'product',
],
operation: [
'get',
'getAll',
],
},
},
default: false,
description: 'By default do custom properties get returned only as ID instead of their actual name. Also option fields contain only the ID instead of their actual value. If this option gets set they get automatically resolved.',
},
{
displayName: 'Encode Properties',
name: 'encodeProperties',
type: 'boolean',
displayOptions: {
show: {
resource: [
'activity',
'deal',
'organization',
'person',
'product',
],
operation: [
'update',
],
},
},
default: false,
description: 'By default do custom properties have to be set as ID instead of their actual name. Also option fields have to be set as ID instead of their actual value. If this option gets set they get automatically encoded.',
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: [
'getAll',
],
},
},
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',
],
returnAll: [
false,
],
},
},
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 100,
description: 'How many results to return.',
},
// ----------------------------------
// person:getAll
// ----------------------------------
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'person',
],
},
},
default: {},
options: [
{
displayName: 'Filter ID',
name: 'filterId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getFilters',
},
default: '',
description: 'ID of the filter to use.',
},
{
displayName: 'First Char',
name: 'firstChar',
type: 'string',
default: '',
description: 'If supplied, only persons whose name starts with the specified letter will be returned ',
},
],
},
// ----------------------------------
// person:search
// ----------------------------------
{
displayName: 'Term',
name: 'term',
type: 'string',
2020-07-23 14:10:20 -07:00
required: true,
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'person',
],
},
},
default: '',
description: 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'person',
],
},
},
default: {},
options: [
{
displayName: 'Exact Match',
name: 'exactMatch',
type: 'boolean',
default: false,
description: 'When enabled, only full exact matches against the given term are returned. It is not case sensitive.',
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated string array. The fields to perform the search from. Defaults to all of them.',
},
{
displayName: 'Include Fields',
name: 'includeFields',
type: 'string',
default: '',
description: 'Supports including optional fields in the results which are not provided by default.',
},
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'string',
default: '',
description: 'Will filter Deals by the provided Organization ID.',
},
{
displayName: 'RAW Data',
name: 'rawData',
type: 'boolean',
default: false,
description: `Returns the data exactly in the way it got received from the API.`,
},
],
},
// ----------------------------------
// note:create/getAll
// ----------------------------------
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'create',
2020-10-22 06:46:03 -07:00
'getAll',
],
resource: [
'note',
],
},
},
default: {},
options: [
{
displayName: 'Deal ID',
name: 'deal_id',
type: 'number',
default: 0,
description: 'ID of the deal this note will be associated with',
},
{
displayName: 'Organization ID',
name: 'org_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizationIds',
},
default: '',
description: 'ID of the organization this deal will be associated with.',
},
{
displayName: 'Person ID',
name: 'person_id',
type: 'number',
default: 0,
description: 'ID of the person this note will be associated with.',
},
],
},
// ----------------------------------
// activity:getAll
// ----------------------------------
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'activity',
],
},
},
default: {},
options: [
{
displayName: 'Done',
name: 'done',
type: 'boolean',
default: false,
description: 'Whether the Activity is done or not. 0 = Not done, 1 = Done. If omitted returns both Done and Not done activities.',
},
{
displayName: 'End Date',
name: 'end_date',
type: 'dateTime',
default: '',
description: 'Use the Activity due date where you wish to stop fetching Activities from. Insert due date in YYYY-MM-DD format.',
},
{
displayName: 'Filter ID ',
name: 'filterId',
type: 'string',
default: '',
description: 'The ID of the Filter to use (will narrow down results if used together with user_id parameter)',
},
{
displayName: 'Star Date',
name: 'start_date',
type: 'dateTime',
default: '',
description: 'Use the Activity due date where you wish to begin fetching Activities from. Insert due date in YYYY-MM-DD format.',
},
{
displayName: 'Type',
name: 'type',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getActivityTypes',
},
default: [],
description: 'Type of the Activity.',
},
{
displayName: 'User ID',
name: 'user_id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getUserIds',
},
default: '',
description: 'The ID of the User whose Activities will be fetched. If omitted, the User associated with the API token will be used. If 0, Activities for all company Users will be fetched based on the permission sets.',
},
],
},
2019-06-23 12:21:44 -07:00
],
};
methods = {
loadOptions: {
// Get all Organizations to display them to user so that he can
// select them easily
async getActivityTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/activityTypes', {});
for (const activity of data) {
returnData.push({
name: activity.name,
value: activity.key_string,
});
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
return returnData;
},
// Get all Organizations to display them to user so that he can
// select them easily
async getOrganizationIds(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/organizations', {});
for (const org of data) {
returnData.push({
name: org.name,
value: org.id,
});
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
return returnData;
},
// Get all Organizations to display them to user so that he can
// select them easily
async getUserIds(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/users', {});
for (const user of data) {
if (user.active_flag === true) {
returnData.push({
name: user.name,
value: user.id,
});
}
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
return returnData;
},
// Get all Stages to display them to user so that he can
// select them easily
async getStageIds(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/stages', {});
for (const stage of data) {
returnData.push({
name: `${stage.pipeline_name} > ${stage.name}`,
value: stage.id,
});
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
return returnData;
},
// Get all the Organization Custom Fields to display them to user so that he can
// select them easily
async getOrganizationCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/organizationFields', {});
for (const field of data) {
if (field.key.length === 40) {
returnData.push({
name: field.name,
value: field.key,
});
}
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
return returnData;
},
// Get all the Deal Custom Fields to display them to user so that he can
// select them easily
async getDealCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/dealFields', {});
for (const field of data) {
if (field.key.length === 40) {
returnData.push({
name: field.name,
value: field.key,
});
}
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
return returnData;
},
// Get all the Person Custom Fields to display them to user so that he can
// select them easily
async getPersonCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/personFields', {});
for (const field of data) {
if (field.key.length === 40) {
returnData.push({
name: field.name,
value: field.key,
});
}
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
return returnData;
},
// Get all the filters to display them to user so that he can
// select them easily
async getFilters(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { data } = await pipedriveApiRequest.call(this, 'GET', '/filters', {}, { type: 'people' });
for (const filter of data) {
const filterName = filter.name;
const filterId = filter.id;
returnData.push({
name: filterName,
value: filterId,
});
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
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,
});
}
}
}
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
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,
});
}
}
}
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
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,
});
}
}
}
}
returnData.sort((a, b) => {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if (aName < bName) { return -1; }
if (aName > bName) { return 1; }
return 0;
});
if (operation === 'update') {
returnData.push({
name: 'No Label',
value: 'null',
});
}
return returnData;
},
2020-10-22 06:46:03 -07:00
},
};
2019-06-23 12:21:44 -07:00
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
// For Post
let body: IDataObject;
// For FormData
let formData: IDataObject;
2019-06-23 12:21:44 -07:00
// For Query string
let qs: IDataObject;
let downloadFile: boolean;
2019-06-23 12:21:44 -07:00
let requestMethod: string;
let endpoint: string;
let returnAll = false;
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
let customProperties: ICustomProperties | undefined;
if (['get', 'getAll', 'update'].includes(operation) && ['activity', 'deal', 'organization', 'person', 'product'].includes(resource)) {
// Request the custom properties once in the beginning to not query it multiple
// times if multiple items get updated
let getCustomProperties = false;
if (['update'].includes(operation)) {
getCustomProperties = this.getNodeParameter('encodeProperties', 0, false) as boolean;
} else {
getCustomProperties = this.getNodeParameter('resolveProperties', 0, false) as boolean;
}
if (getCustomProperties === true) {
customProperties = await pipedriveGetCustomProperties.call(this, resource);
}
}
2019-06-23 12:21:44 -07:00
for (let i = 0; i < items.length; i++) {
2019-06-23 12:21:44 -07:00
requestMethod = 'GET';
endpoint = '';
downloadFile = false;
2019-06-23 12:21:44 -07:00
body = {};
formData = {};
2019-06-23 12:21:44 -07:00
qs = {};
if (resource === 'activity') {
if (operation === 'create') {
// ----------------------------------
// activity:create
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'POST';
endpoint = '/activities';
2019-06-23 12:21:44 -07:00
body.subject = this.getNodeParameter('subject', i) as string;
body.done = this.getNodeParameter('done', i) as string;
body.type = this.getNodeParameter('type', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(body, additionalFields);
2019-06-23 12:21:44 -07:00
} else if (operation === 'delete') {
// ----------------------------------
// activity:delete
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'DELETE';
2019-06-23 12:21:44 -07:00
const activityId = this.getNodeParameter('activityId', i) as number;
endpoint = `/activities/${activityId}`;
} else if (operation === 'get') {
// ----------------------------------
// activity:get
// ----------------------------------
requestMethod = 'GET';
const activityId = this.getNodeParameter('activityId', i) as number;
endpoint = `/activities/${activityId}`;
2019-06-23 12:21:44 -07:00
} else if (operation === 'getAll') {
// ----------------------------------
// activity:getAll
// ----------------------------------
requestMethod = 'GET';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(qs, additionalFields);
if (qs.type) {
qs.type = (qs.type as string[]).join(',');
}
endpoint = `/activities`;
} else if (operation === 'update') {
// ----------------------------------
// activity:update
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'PUT';
2019-06-23 12:21:44 -07:00
const activityId = this.getNodeParameter('activityId', i) as number;
endpoint = `/activities/${activityId}`;
2019-06-23 12:21:44 -07:00
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
addAdditionalFields(body, updateFields);
2019-06-23 12:21:44 -07:00
}
} else if (resource === 'deal') {
if (operation === 'create') {
// ----------------------------------
// deal:create
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'POST';
endpoint = '/deals';
2019-06-23 12:21:44 -07:00
body.title = this.getNodeParameter('title', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(body, additionalFields);
2019-06-23 12:21:44 -07:00
} else if (operation === 'delete') {
// ----------------------------------
// deal:delete
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'DELETE';
2019-06-23 12:21:44 -07:00
const dealId = this.getNodeParameter('dealId', i) as number;
endpoint = `/deals/${dealId}`;
} else if (operation === 'duplicate') {
// ----------------------------------
// deal:duplicate
// ----------------------------------
requestMethod = 'POST';
const dealId = this.getNodeParameter('dealId', i) as number;
endpoint = `/deals/${dealId}/duplicate`;
} else if (operation === 'get') {
// ----------------------------------
// deal:get
// ----------------------------------
requestMethod = 'GET';
const dealId = this.getNodeParameter('dealId', i) as number;
endpoint = `/deals/${dealId}`;
2019-06-23 12:21:44 -07:00
} else if (operation === 'getAll') {
// ----------------------------------
// deal:getAll
// ----------------------------------
requestMethod = 'GET';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
endpoint = `/deals`;
} else if (operation === 'update') {
// ----------------------------------
// deal:update
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'PUT';
2019-06-23 12:21:44 -07:00
const dealId = this.getNodeParameter('dealId', i) as number;
endpoint = `/deals/${dealId}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
addAdditionalFields(body, updateFields);
if (body.label === 'null') {
body.label = null;
}
} else if (operation === 'search') {
// ----------------------------------
// deal:search
// ----------------------------------
requestMethod = 'GET';
qs.term = this.getNodeParameter('term', i) as string;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
qs.exact_match = this.getNodeParameter('exactMatch', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.fields) {
qs.fields = (additionalFields.fields as string[]).join(',');
}
if (additionalFields.organizationId) {
qs.organization_id = parseInt(additionalFields.organizationId as string, 10);
}
if (additionalFields.includeFields) {
qs.include_fields = additionalFields.includeFields as string;
}
if (additionalFields.personId) {
qs.person_id = parseInt(additionalFields.personId as string, 10);
}
if (additionalFields.status) {
qs.status = additionalFields.status as string;
}
endpoint = `/deals/search`;
}
} else if (resource === 'file') {
if (operation === 'create') {
// ----------------------------------
// file:create
// ----------------------------------
requestMethod = 'POST';
endpoint = '/files';
const item = items[i];
if (item.binary === undefined) {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
}
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
if (item.binary[binaryPropertyName] === undefined) {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
}
const fileBufferData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING);
formData.file = {
value: fileBufferData,
options: {
contentType: item.binary[binaryPropertyName].mimeType,
filename: item.binary[binaryPropertyName].fileName,
2020-10-22 06:46:03 -07:00
},
};
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(formData, additionalFields);
} else if (operation === 'delete') {
// ----------------------------------
// file:delete
// ----------------------------------
requestMethod = 'DELETE';
const fileId = this.getNodeParameter('fileId', i) as number;
endpoint = `/files/${fileId}`;
} else if (operation === 'download') {
// ----------------------------------
// file:download
// ----------------------------------
requestMethod = 'GET';
downloadFile = true;
const fileId = this.getNodeParameter('fileId', i) as number;
endpoint = `/files/${fileId}/download`;
} else if (operation === 'get') {
// ----------------------------------
// file:get
// ----------------------------------
requestMethod = 'GET';
const fileId = this.getNodeParameter('fileId', i) as number;
endpoint = `/files/${fileId}`;
}
} else if (resource === 'note') {
if (operation === 'create') {
// ----------------------------------
// note:create
// ----------------------------------
requestMethod = 'POST';
endpoint = '/notes';
body.content = this.getNodeParameter('content', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(body, additionalFields);
} else if (operation === 'delete') {
// ----------------------------------
// note:delete
// ----------------------------------
requestMethod = 'DELETE';
const noteId = this.getNodeParameter('noteId', i) as number;
endpoint = `/notes/${noteId}`;
} else if (operation === 'get') {
// ----------------------------------
// note:get
// ----------------------------------
requestMethod = 'GET';
const noteId = this.getNodeParameter('noteId', i) as number;
endpoint = `/notes/${noteId}`;
} else if (operation === 'getAll') {
// ----------------------------------
// note:getAll
// ----------------------------------
requestMethod = 'GET';
endpoint = `/notes`;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(qs, additionalFields);
} else if (operation === 'update') {
// ----------------------------------
// note:update
// ----------------------------------
requestMethod = 'PUT';
const noteId = this.getNodeParameter('noteId', i) as number;
endpoint = `/notes/${noteId}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
addAdditionalFields(body, updateFields);
}
} else if (resource === 'organization') {
if (operation === 'create') {
// ----------------------------------
// organization:create
// ----------------------------------
requestMethod = 'POST';
endpoint = '/organizations';
body.name = this.getNodeParameter('name', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(body, additionalFields);
2019-06-23 12:21:44 -07:00
} else if (operation === 'delete') {
// ----------------------------------
// organization:delete
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'DELETE';
2019-06-23 12:21:44 -07:00
const organizationId = this.getNodeParameter('organizationId', i) as number;
endpoint = `/organizations/${organizationId}`;
} else if (operation === 'get') {
// ----------------------------------
// organization:get
// ----------------------------------
requestMethod = 'GET';
const organizationId = this.getNodeParameter('organizationId', i) as number;
endpoint = `/organizations/${organizationId}`;
} else if (operation === 'getAll') {
// ----------------------------------
// organization:getAll
// ----------------------------------
requestMethod = 'GET';
2019-06-23 12:21:44 -07:00
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
2019-06-23 12:21:44 -07:00
endpoint = `/organizations`;
2019-06-23 12:21:44 -07:00
}
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') {
// ----------------------------------
// person:create
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'POST';
endpoint = '/persons';
2019-06-23 12:21:44 -07:00
body.name = this.getNodeParameter('name', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(body, additionalFields);
2019-06-23 12:21:44 -07:00
} else if (operation === 'delete') {
// ----------------------------------
// person:delete
// ----------------------------------
requestMethod = 'DELETE';
const personId = this.getNodeParameter('personId', i) as number;
endpoint = `/persons/${personId}`;
} else if (operation === 'get') {
// ----------------------------------
// person:get
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'GET';
2019-06-23 12:21:44 -07:00
const personId = this.getNodeParameter('personId', i) as number;
endpoint = `/persons/${personId}`;
2019-06-23 12:21:44 -07:00
} else if (operation === 'getAll') {
// ----------------------------------
// persons:getAll
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'GET';
2019-06-23 12:21:44 -07:00
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
2019-06-23 12:21:44 -07:00
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.filterId) {
qs.filter_id = additionalFields.filterId as string;
}
if (additionalFields.firstChar) {
qs.first_char = additionalFields.firstChar as string;
}
endpoint = `/persons`;
2019-06-23 12:21:44 -07:00
} else if (operation === 'search') {
// ----------------------------------
// persons:search
// ----------------------------------
requestMethod = 'GET';
qs.term = this.getNodeParameter('term', i) as string;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.fields) {
qs.fields = additionalFields.fields as string;
}
if (additionalFields.exactMatch) {
qs.exact_match = additionalFields.exactMatch as boolean;
}
if (additionalFields.organizationId) {
qs.organization_id = parseInt(additionalFields.organizationId as string, 10);
}
if (additionalFields.includeFields) {
qs.include_fields = additionalFields.includeFields as string;
}
endpoint = `/persons/search`;
} else if (operation === 'update') {
// ----------------------------------
// person:update
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'PUT';
2019-06-23 12:21:44 -07:00
const personId = this.getNodeParameter('personId', i) as number;
endpoint = `/persons/${personId}`;
2019-06-23 12:21:44 -07:00
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
addAdditionalFields(body, updateFields);
2019-06-23 12:21:44 -07:00
if (body.label === 'null') {
body.label = null;
}
}
} else if (resource === 'product') {
if (operation === 'getAll') {
// ----------------------------------
// product:getAll
// ----------------------------------
2019-06-23 12:21:44 -07:00
requestMethod = 'GET';
2019-06-23 12:21:44 -07:00
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
2019-06-23 12:21:44 -07:00
endpoint = `/products`;
2019-06-23 12:21:44 -07:00
}
2019-06-23 12:21:44 -07:00
} else {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
2019-06-23 12:21:44 -07:00
}
let responseData;
if (returnAll === true) {
2019-06-23 12:21:44 -07:00
responseData = await pipedriveApiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
2019-06-23 12:21:44 -07:00
} else {
if (customProperties !== undefined) {
pipedriveEncodeCustomProperties(customProperties!, body);
}
responseData = await pipedriveApiRequest.call(this, requestMethod, endpoint, body, qs, formData, downloadFile);
2019-06-23 12:21:44 -07:00
}
if (resource === 'file' && operation === 'download') {
const newItem: INodeExecutionData = {
json: items[i].json,
binary: {},
};
if (items[i].binary !== undefined) {
// Create a shallow copy of the binary data so that the old
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Object.assign(newItem.binary, items[i].binary);
}
items[i] = newItem;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(responseData.data);
2019-06-23 12:21:44 -07:00
} else {
if (responseData.data === null) {
responseData.data = [];
}
if (operation === 'search' && responseData.data && responseData.data.items) {
responseData.data = responseData.data.items;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.rawData !== true) {
responseData.data = responseData.data.map((item: { result_score: number, item: object }) => {
return {
result_score: item.result_score,
...item.item,
};
});
}
}
if (Array.isArray(responseData.data)) {
returnData.push.apply(returnData, responseData.data as IDataObject[]);
} else {
returnData.push(responseData.data as IDataObject);
}
2019-06-23 12:21:44 -07:00
}
}
if (customProperties !== undefined) {
for (const item of returnData) {
await pipedriveResolveCustomProperties(customProperties, item);
}
}
if (resource === 'file' && operation === 'download') {
// For file downloads the files get attached to the existing items
return this.prepareOutputData(items);
} else {
// For all other ones does the output items get replaced
return [this.helpers.returnJsonArray(returnData)];
}
2019-06-23 12:21:44 -07:00
}
}