2019-08-20 23:45:03 -07:00
|
|
|
import {
|
2019-10-25 07:56:15 -07:00
|
|
|
IExecuteFunctions,
|
2019-08-20 23:45:03 -07:00
|
|
|
} from 'n8n-core';
|
|
|
|
import {
|
|
|
|
IDataObject,
|
|
|
|
INodeTypeDescription,
|
|
|
|
INodeExecutionData,
|
|
|
|
INodeType,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
import {
|
|
|
|
activeCampaignApiRequest,
|
|
|
|
activeCampaignApiRequestAllItems,
|
|
|
|
} 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-10-25 06:47:43 -07:00
|
|
|
/**
|
|
|
|
* Add one additional field to the body
|
|
|
|
*
|
|
|
|
* @param {IDataObject} body The body object to add the field to
|
|
|
|
* @param {IDataObject} additionalField The field to add
|
|
|
|
*/
|
|
|
|
function addAdditionalField(body: IDataObject, additionalField: string | number) {
|
|
|
|
body.additionalField = additionalField;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-20 23:45:03 -07:00
|
|
|
export class ActiveCampaign implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'ActiveCampaign',
|
|
|
|
name: 'activeCampaign',
|
|
|
|
icon: 'file:activeCampaign.png',
|
|
|
|
group: ['transform'],
|
|
|
|
version: 1,
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
description: 'Create and edit data in ActiveCampaign',
|
|
|
|
defaults: {
|
|
|
|
name: 'ActiveCampaign',
|
|
|
|
color: '#356ae6',
|
|
|
|
},
|
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'activeCampaignApi',
|
|
|
|
required: true,
|
|
|
|
}
|
|
|
|
],
|
|
|
|
properties: [
|
2019-10-24 11:15:57 -07:00
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// resources
|
|
|
|
// ----------------------------------
|
2019-08-20 23:45:03 -07:00
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Contact',
|
|
|
|
value: 'contact',
|
|
|
|
},
|
2019-10-24 11:15:57 -07:00
|
|
|
{
|
|
|
|
name: 'Deal',
|
|
|
|
value: 'deal',
|
|
|
|
}
|
2019-08-20 23:45:03 -07:00
|
|
|
],
|
|
|
|
default: 'contact',
|
|
|
|
description: 'The resource to operate on.',
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// operations
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Create',
|
|
|
|
value: 'create',
|
|
|
|
description: 'Create a contact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Delete',
|
|
|
|
value: 'delete',
|
|
|
|
description: 'Delete a contact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get',
|
|
|
|
value: 'get',
|
|
|
|
description: 'Get data of a contact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get All',
|
|
|
|
value: 'getAll',
|
|
|
|
description: 'Get data of all contact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Update',
|
|
|
|
value: 'update',
|
|
|
|
description: 'Update a contact',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'create',
|
|
|
|
description: 'The operation to perform.',
|
|
|
|
},
|
|
|
|
|
2019-10-24 11:15:57 -07:00
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Create',
|
|
|
|
value: 'create',
|
|
|
|
description: 'Create a deal',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Delete',
|
|
|
|
value: 'delete',
|
|
|
|
description: 'Delete a deal',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get',
|
|
|
|
value: 'get',
|
|
|
|
description: 'Get data of a deal',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get All',
|
|
|
|
value: 'getAll',
|
|
|
|
description: 'Get data of all deals',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Update',
|
|
|
|
value: 'update',
|
|
|
|
description: 'Update a deal',
|
|
|
|
},
|
2019-10-24 11:21:28 -07:00
|
|
|
{
|
|
|
|
name: 'Create Note',
|
|
|
|
value: 'createNote',
|
|
|
|
description: 'Create a deal note',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Update deal note',
|
|
|
|
value: 'updateNote',
|
|
|
|
description: 'Update a deal note',
|
|
|
|
},
|
2019-10-24 11:15:57 -07:00
|
|
|
],
|
|
|
|
default: 'create',
|
|
|
|
description: 'The operation to perform.',
|
|
|
|
},
|
|
|
|
|
2019-08-20 23:45:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// contact
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:create
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Email',
|
|
|
|
name: 'email',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The email of the contact to create',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Update if exists',
|
|
|
|
name: 'updateIfExists',
|
|
|
|
type: 'boolean',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: false,
|
|
|
|
description: 'Update user if it exists already. If not set and user exists it will error instead.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Additional Fields',
|
|
|
|
name: 'additionalFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: {},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'First Name',
|
2019-09-11 12:56:45 -07:00
|
|
|
name: 'firstName',
|
2019-08-20 23:45:03 -07:00
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The first name of the contact to create',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Last Name',
|
2019-09-11 12:56:45 -07:00
|
|
|
name: 'lastName',
|
2019-08-20 23:45:03 -07:00
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The last name of the contact to create',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Phone',
|
|
|
|
name: 'phone',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Phone number of the contact.',
|
|
|
|
},
|
2019-09-04 09:50:02 -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.',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2019-08-20 23:45:03 -07:00
|
|
|
],
|
|
|
|
},
|
2019-10-25 05:24:24 -07:00
|
|
|
|
2019-08-20 23:45:03 -07:00
|
|
|
// ----------------------------------
|
|
|
|
// contact:update
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Contact ID',
|
|
|
|
name: 'contactId',
|
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: 0,
|
|
|
|
required: true,
|
|
|
|
description: 'ID of the contact to update.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Update Fields',
|
|
|
|
name: 'updateFields',
|
|
|
|
type: 'collection',
|
|
|
|
description: 'The fields to update.',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: {},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Email',
|
|
|
|
name: 'email',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Email of the contact.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'First Name',
|
2019-09-11 12:56:45 -07:00
|
|
|
name: 'firstName',
|
2019-08-20 23:45:03 -07:00
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'First name of the contact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Last Name',
|
2019-09-11 12:56:45 -07:00
|
|
|
name: 'lastName',
|
2019-08-20 23:45:03 -07:00
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Last name of the contact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Phone',
|
|
|
|
name: 'phone',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Phone number of the contact.',
|
|
|
|
},
|
2019-09-04 09:50:02 -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.',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2019-08-20 23:45:03 -07:00
|
|
|
],
|
|
|
|
},
|
2019-10-24 17:50:03 -07:00
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:delete
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Contact ID',
|
|
|
|
name: 'contactId',
|
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'delete',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: 0,
|
|
|
|
required: true,
|
|
|
|
description: 'ID of the contact to delete.',
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:get
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Contact ID',
|
|
|
|
name: 'contactId',
|
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'get',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: 0,
|
|
|
|
required: true,
|
|
|
|
description: 'ID of the contact to get.',
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:getAll
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Return All',
|
|
|
|
name: 'returnAll',
|
|
|
|
type: 'boolean',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: false,
|
|
|
|
description: 'If all results should be returned or only up to a given limit.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Limit',
|
|
|
|
name: 'limit',
|
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'contact',
|
|
|
|
],
|
|
|
|
returnAll: [
|
|
|
|
false,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
typeOptions: {
|
|
|
|
minValue: 1,
|
|
|
|
maxValue: 500,
|
|
|
|
},
|
|
|
|
default: 100,
|
|
|
|
description: 'How many results to return.',
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2019-10-24 11:15:57 -07:00
|
|
|
// ----------------------------------
|
|
|
|
// deal
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:create
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Title',
|
2019-10-25 05:50:15 -07:00
|
|
|
name: 'dealTitle',
|
2019-10-24 11:15:57 -07:00
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The title of the deal',
|
|
|
|
},
|
|
|
|
{
|
2019-10-24 11:50:57 -07:00
|
|
|
displayName: 'Deal\'s contact ID',
|
2019-10-25 05:50:15 -07:00
|
|
|
name: 'dealContactId',
|
2019-10-24 11:15:57 -07:00
|
|
|
type: 'number',
|
2019-10-25 05:50:15 -07:00
|
|
|
default: 0,
|
2019-10-24 11:15:57 -07:00
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-10-24 11:50:57 -07:00
|
|
|
description: 'The ID of the deal\'s contact',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Deal value',
|
|
|
|
name: 'dealValue',
|
|
|
|
type: 'number',
|
2019-10-25 05:50:15 -07:00
|
|
|
default: 0,
|
2019-10-24 11:15:57 -07:00
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The value of the deal in cents',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Currency',
|
2019-10-25 05:50:15 -07:00
|
|
|
name: 'dealCurrency',
|
2019-10-24 11:15:57 -07:00
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The currency of the deal in 3-character ISO format',
|
|
|
|
},
|
|
|
|
{
|
2019-10-25 07:15:01 -07:00
|
|
|
displayName: 'Additional Fields',
|
|
|
|
name: 'additionalFields',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
2019-10-24 11:15:57 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
default: {},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Description',
|
|
|
|
name: 'dealDescription',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The description of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal group ID',
|
|
|
|
name: 'dealGroup',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The group ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal stage ID',
|
|
|
|
name: 'dealStage',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The stage ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal owner ID',
|
|
|
|
name: 'dealOwner',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The owner ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal percentage',
|
|
|
|
name: 'dealPercentage',
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
description: 'The percentage of the deal',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Deal status',
|
|
|
|
name: 'dealStatus',
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
description: 'The status of the deal',
|
|
|
|
},
|
|
|
|
]
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 05:24:24 -07:00
|
|
|
|
2019-10-24 11:15:57 -07:00
|
|
|
// ----------------------------------
|
2019-10-24 17:50:03 -07:00
|
|
|
// deal:update
|
2019-10-24 11:15:57 -07:00
|
|
|
// ----------------------------------
|
2019-10-25 05:51:46 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal ID',
|
|
|
|
name: 'dealId',
|
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-10-25 05:50:15 -07:00
|
|
|
default: 0,
|
2019-10-25 07:15:01 -07:00
|
|
|
required: true,
|
2019-10-25 07:25:16 -07:00
|
|
|
description: 'ID of the deal to update.',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
|
|
|
{
|
2019-10-25 07:25:16 -07:00
|
|
|
displayName: 'Update Fields',
|
|
|
|
name: 'updateFields',
|
2019-10-25 07:15:01 -07:00
|
|
|
type: 'collection',
|
2019-10-25 07:25:16 -07:00
|
|
|
description: 'The fields to update.',
|
2019-10-25 07:15:01 -07:00
|
|
|
placeholder: 'Add Field',
|
2019-10-24 11:15:57 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
2019-10-25 07:25:16 -07:00
|
|
|
'update',
|
2019-10-24 11:15:57 -07:00
|
|
|
],
|
|
|
|
resource: [
|
2019-10-25 07:25:16 -07:00
|
|
|
'contact',
|
2019-10-24 11:15:57 -07:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
default: {},
|
|
|
|
options: [
|
2019-10-25 07:25:16 -07:00
|
|
|
{
|
|
|
|
displayName: 'Title',
|
|
|
|
name: 'dealTitle',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The title of the deal',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Deal\'s contact ID',
|
|
|
|
name: 'dealContactId',
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
description: 'The ID of the deal\'s contact',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Deal value',
|
|
|
|
name: 'dealValue',
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
description: 'The value of the deal in cents',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Currency',
|
|
|
|
name: 'dealCurrency',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The currency of the deal in 3-character ISO format',
|
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Description',
|
|
|
|
name: 'dealDescription',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The description of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal group ID',
|
|
|
|
name: 'dealGroup',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The group ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal stage ID',
|
|
|
|
name: 'dealStage',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The stage ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal owner ID',
|
|
|
|
name: 'dealOwner',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'The owner ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:15:01 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal percentage',
|
|
|
|
name: 'dealPercentage',
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
description: 'The percentage of the deal',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Deal status',
|
|
|
|
name: 'dealStatus',
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
description: 'The status of the deal',
|
|
|
|
},
|
|
|
|
]
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 07:30:58 -07:00
|
|
|
|
2019-10-24 17:50:03 -07:00
|
|
|
// ----------------------------------
|
|
|
|
// deal:delete
|
|
|
|
// ----------------------------------
|
2019-10-24 11:15:57 -07:00
|
|
|
{
|
2019-10-24 17:50:03 -07:00
|
|
|
displayName: 'Deal ID',
|
|
|
|
name: 'dealId',
|
|
|
|
type: 'number',
|
2019-10-25 05:51:46 -07:00
|
|
|
default: 0,
|
2019-10-24 17:50:03 -07:00
|
|
|
required: true,
|
2019-10-24 11:15:57 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
2019-10-24 17:50:03 -07:00
|
|
|
'delete',
|
2019-10-24 11:15:57 -07:00
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-10-24 17:50:03 -07:00
|
|
|
description: 'The ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-24 17:50:03 -07:00
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:get
|
|
|
|
// ----------------------------------
|
2019-10-24 11:15:57 -07:00
|
|
|
{
|
2019-10-24 17:50:03 -07:00
|
|
|
displayName: 'Deal ID',
|
|
|
|
name: 'dealId',
|
|
|
|
type: 'number',
|
2019-10-25 05:51:46 -07:00
|
|
|
default: 0,
|
2019-10-24 17:50:03 -07:00
|
|
|
required: true,
|
2019-10-24 11:15:57 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
2019-10-24 17:50:03 -07:00
|
|
|
'get',
|
2019-10-24 11:15:57 -07:00
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-10-24 17:50:03 -07:00
|
|
|
description: 'The ID of the deal',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-25 05:24:24 -07:00
|
|
|
|
2019-10-24 17:50:03 -07:00
|
|
|
// ----------------------------------
|
|
|
|
// deal:getAll
|
|
|
|
// ----------------------------------
|
2019-10-24 11:15:57 -07:00
|
|
|
{
|
2019-10-24 17:50:03 -07:00
|
|
|
displayName: 'Return All',
|
|
|
|
name: 'returnAll',
|
|
|
|
type: 'boolean',
|
2019-10-24 11:15:57 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
2019-10-24 17:50:03 -07:00
|
|
|
'getAll',
|
2019-10-24 11:15:57 -07:00
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-10-24 17:50:03 -07:00
|
|
|
default: false,
|
|
|
|
description: 'If all results should be returned or only up to a given limit.',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
|
|
|
{
|
2019-10-24 17:50:03 -07:00
|
|
|
displayName: 'Limit',
|
|
|
|
name: 'limit',
|
2019-10-24 11:15:57 -07:00
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
2019-10-24 17:50:03 -07:00
|
|
|
'getAll',
|
2019-10-24 11:15:57 -07:00
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
2019-10-24 17:50:03 -07:00
|
|
|
returnAll: [
|
|
|
|
false,
|
|
|
|
],
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
|
|
|
},
|
2019-10-24 17:50:03 -07:00
|
|
|
typeOptions: {
|
|
|
|
minValue: 1,
|
|
|
|
maxValue: 500,
|
|
|
|
},
|
|
|
|
default: 100,
|
|
|
|
description: 'How many results to return.',
|
2019-10-24 11:15:57 -07:00
|
|
|
},
|
2019-10-24 11:21:28 -07:00
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// dealNote:create
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Deal ID',
|
|
|
|
name: 'dealId',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'createNote',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The ID of the deal note',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Deal Note',
|
|
|
|
name: 'dealNote',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'createNote',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The content of the deal note',
|
|
|
|
},
|
2019-10-24 11:50:57 -07:00
|
|
|
|
2019-10-24 11:21:28 -07:00
|
|
|
// ----------------------------------
|
|
|
|
// dealNote:update
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'Deal ID',
|
|
|
|
name: 'dealId',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'updateNote',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The ID of the deal note',
|
|
|
|
},
|
2019-10-25 07:48:53 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal note ID',
|
|
|
|
name: 'dealNoteId',
|
|
|
|
type: 'number',
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'updateNote',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The ID of the deal note',
|
|
|
|
},
|
2019-10-24 11:21:28 -07:00
|
|
|
{
|
|
|
|
displayName: 'Deal Note',
|
|
|
|
name: 'dealNote',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'updateNote',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'deal',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The content of the deal note',
|
|
|
|
},
|
2019-08-20 23:45:03 -07:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
const items = this.getInputData();
|
|
|
|
const returnData: IDataObject[] = [];
|
|
|
|
|
|
|
|
let resource: string;
|
|
|
|
let operation: string;
|
|
|
|
|
|
|
|
// For Post
|
|
|
|
let body: IDataObject;
|
|
|
|
// For Query string
|
|
|
|
let qs: IDataObject;
|
|
|
|
|
|
|
|
let requestMethod: string;
|
2019-09-11 12:56:45 -07:00
|
|
|
let endpoint: string;
|
2019-08-20 23:45:03 -07:00
|
|
|
let returnAll = false;
|
2019-09-11 12:56:45 -07:00
|
|
|
let dataKey: string | undefined;
|
2019-08-20 23:45:03 -07:00
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
2019-09-11 12:56:45 -07:00
|
|
|
dataKey = undefined;
|
2019-08-20 23:45:03 -07:00
|
|
|
resource = this.getNodeParameter('resource', 0) as string;
|
|
|
|
operation = this.getNodeParameter('operation', 0) as string;
|
|
|
|
|
|
|
|
requestMethod = 'GET';
|
2019-09-11 12:56:45 -07:00
|
|
|
endpoint = '';
|
2019-08-20 23:45:03 -07:00
|
|
|
body = {} as IDataObject;
|
|
|
|
qs = {} as IDataObject;
|
|
|
|
|
|
|
|
if (resource === 'contact') {
|
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:create
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'POST';
|
|
|
|
|
|
|
|
const updateIfExists = this.getNodeParameter('updateIfExists', i) as boolean;
|
|
|
|
if (updateIfExists === true) {
|
2019-09-11 12:56:45 -07:00
|
|
|
endpoint = '/api/3/contact/sync';
|
2019-08-20 23:45:03 -07:00
|
|
|
} else {
|
2019-09-11 12:56:45 -07:00
|
|
|
endpoint = '/api/3/contacts';
|
2019-08-20 23:45:03 -07:00
|
|
|
}
|
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
dataKey = 'contact';
|
|
|
|
body.contact = {
|
|
|
|
email: this.getNodeParameter('email', i) as string,
|
|
|
|
} as IDataObject;
|
2019-08-20 23:45:03 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
2019-09-11 12:56:45 -07:00
|
|
|
addAdditionalFields(body.contact as IDataObject, additionalFields);
|
2019-08-20 23:45:03 -07:00
|
|
|
|
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:delete
|
|
|
|
// ----------------------------------
|
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
requestMethod = 'DELETE';
|
2019-08-20 23:45:03 -07:00
|
|
|
|
|
|
|
const contactId = this.getNodeParameter('contactId', i) as number;
|
2019-09-11 12:56:45 -07:00
|
|
|
endpoint = `/api/3/contacts/${contactId}`;
|
2019-08-20 23:45:03 -07:00
|
|
|
|
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:get
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'GET';
|
|
|
|
|
|
|
|
const contactId = this.getNodeParameter('contactId', i) as number;
|
2019-09-11 12:56:45 -07:00
|
|
|
endpoint = `/api/3/contacts/${contactId}`;
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------
|
2019-10-25 07:48:53 -07:00
|
|
|
// contacts:getAll
|
2019-09-11 12:56:45 -07:00
|
|
|
// ----------------------------------
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
requestMethod = 'GET';
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
|
|
if (returnAll === false) {
|
|
|
|
qs.limit = this.getNodeParameter('limit', i) as number;
|
|
|
|
}
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
dataKey = 'contacts';
|
|
|
|
endpoint = `/api/3/contacts`;
|
2019-08-20 23:45:03 -07:00
|
|
|
|
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------
|
|
|
|
// contact:update
|
|
|
|
// ----------------------------------
|
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
requestMethod = 'PUT';
|
2019-08-20 23:45:03 -07:00
|
|
|
|
|
|
|
const contactId = this.getNodeParameter('contactId', i) as number;
|
2019-09-11 12:56:45 -07:00
|
|
|
endpoint = `/api/3/contacts/${contactId}`;
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-09-11 12:56:45 -07:00
|
|
|
dataKey = 'contact';
|
|
|
|
body.contact = {} as IDataObject;
|
2019-08-20 23:45:03 -07:00
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
2019-09-11 12:56:45 -07:00
|
|
|
addAdditionalFields(body.contact as IDataObject, updateFields);
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-10-25 07:30:58 -07:00
|
|
|
} else {
|
2019-10-25 07:48:53 -07:00
|
|
|
throw new Error(`The operation "${operation}" is not known`);
|
2019-08-20 23:45:03 -07:00
|
|
|
}
|
2019-10-25 05:24:24 -07:00
|
|
|
} else if (resource === 'deal') {
|
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:create
|
|
|
|
// ----------------------------------
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-10-25 05:24:24 -07:00
|
|
|
requestMethod = 'POST';
|
|
|
|
|
2019-10-25 07:25:16 -07:00
|
|
|
endpoint = '/api/3/deals';
|
|
|
|
|
2019-10-25 05:24:24 -07:00
|
|
|
dataKey = 'deal';
|
2019-10-25 07:15:01 -07:00
|
|
|
|
2019-10-25 06:47:43 -07:00
|
|
|
body.deal = {
|
|
|
|
title: this.getNodeParameter('dealTitle', i) as string,
|
|
|
|
contact: this.getNodeParameter('dealContactId', i) as string,
|
|
|
|
value: this.getNodeParameter('dealValue', i) as number,
|
|
|
|
} as IDataObject;
|
2019-10-25 05:50:15 -07:00
|
|
|
|
2019-10-25 07:15:01 -07:00
|
|
|
let currency = this.getNodeParameter('dealCurrency', i).toString().toLowerCase() as string
|
|
|
|
addAdditionalField(body.deal as IDataObject, currency)
|
2019-10-25 06:47:43 -07:00
|
|
|
|
2019-10-25 07:15:01 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
addAdditionalFields(body.deal as IDataObject, additionalFields);
|
2019-10-25 05:50:15 -07:00
|
|
|
|
2019-10-25 05:24:24 -07:00
|
|
|
|
2019-10-25 07:25:16 -07:00
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:update
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'PUT';
|
|
|
|
|
|
|
|
const dealId = this.getNodeParameter('dealId', i) as number;
|
|
|
|
endpoint = `/api/3/deals/${dealId}`;
|
|
|
|
|
|
|
|
dataKey = 'deal';
|
|
|
|
body.deal = {} as IDataObject;
|
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
|
|
addAdditionalFields(body.deal as IDataObject, updateFields);
|
|
|
|
|
2019-10-25 05:24:24 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:delete
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
|
|
|
|
const dealId = this.getNodeParameter('dealId', i) as number;
|
|
|
|
endpoint = `/api/3/deals/${dealId}`;
|
|
|
|
|
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:get
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'GET';
|
|
|
|
|
|
|
|
const dealId = this.getNodeParameter('dealId', i) as number;
|
|
|
|
endpoint = `/api/3/deals/${dealId}`;
|
|
|
|
|
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------
|
2019-10-25 07:48:53 -07:00
|
|
|
// deals:getAll
|
2019-10-25 05:24:24 -07:00
|
|
|
// ----------------------------------
|
2019-08-20 23:45:03 -07:00
|
|
|
|
2019-10-25 05:24:24 -07:00
|
|
|
requestMethod = 'GET';
|
|
|
|
|
|
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
|
|
if (returnAll === false) {
|
|
|
|
qs.limit = this.getNodeParameter('limit', i) as number;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataKey = 'deals';
|
|
|
|
endpoint = `/api/3/deals`;
|
2019-10-25 07:48:53 -07:00
|
|
|
|
|
|
|
} else if (operation === 'createNote') {
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:createNote
|
|
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'POST'
|
|
|
|
|
|
|
|
body.note = {
|
|
|
|
note: this.getNodeParameter('createNote', i) as string,
|
|
|
|
}
|
|
|
|
|
|
|
|
const dealId = this.getNodeParameter('dealId', i) as number;
|
|
|
|
endpoint = `/api/3/deals/${dealId}/notes`;
|
|
|
|
|
|
|
|
} else if (operation === 'updateNote') {
|
|
|
|
// ----------------------------------
|
|
|
|
// deal:updateNote
|
|
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'POST'
|
|
|
|
|
|
|
|
body.note = {
|
|
|
|
note: this.getNodeParameter('updateNote', i) as string,
|
|
|
|
}
|
|
|
|
|
|
|
|
const dealId = this.getNodeParameter('dealId', i) as number;
|
|
|
|
const dealNoteId = this.getNodeParameter('dealNoteId', i) as number;
|
|
|
|
endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`;
|
|
|
|
|
2019-10-25 05:24:24 -07:00
|
|
|
} else {
|
2019-10-25 07:48:53 -07:00
|
|
|
throw new Error(`The operation "${operation}" is not known`);
|
2019-10-25 05:24:24 -07:00
|
|
|
}
|
2019-10-25 07:30:58 -07:00
|
|
|
} else {
|
|
|
|
throw new Error(`The resource "${resource}" is not known!`);
|
|
|
|
}
|
2019-10-25 05:24:24 -07:00
|
|
|
|
2019-10-25 07:30:58 -07:00
|
|
|
let responseData;
|
|
|
|
if (returnAll === true) {
|
|
|
|
responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey);
|
|
|
|
} else {
|
|
|
|
responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey);
|
2019-08-20 23:45:03 -07:00
|
|
|
}
|
|
|
|
|
2019-10-25 07:30:58 -07:00
|
|
|
if (Array.isArray(responseData)) {
|
|
|
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
|
|
|
} else {
|
|
|
|
returnData.push(responseData as IDataObject);
|
|
|
|
}
|
2019-10-25 05:24:24 -07:00
|
|
|
}
|
2019-10-25 07:30:58 -07:00
|
|
|
|
|
|
|
return [this.helpers.returnJsonArray(returnData)];
|
2019-08-20 23:45:03 -07:00
|
|
|
}
|
2019-10-25 07:30:58 -07:00
|
|
|
}
|