first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,549 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const activityOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create an activity',
|
||||
action: 'Create an activity',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete an activity',
|
||||
action: 'Delete an activity',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get an activity',
|
||||
action: 'Get an activity',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many companies',
|
||||
action: 'Get many activities',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update an activity',
|
||||
action: 'Update an activity',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const activityFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* activity:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Owner Name or ID',
|
||||
name: 'owner',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getUsers',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description: 'This field displays activity type such as call, meeting etc',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains details related to the activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains tags associated with an activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
name: 'dueDate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Expiry date of an activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Duration',
|
||||
name: 'duration',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Time duration of an activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Is Calendar Invite',
|
||||
name: 'isCalendarInvite',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to send calendar invite',
|
||||
},
|
||||
{
|
||||
displayName: 'Is Completed',
|
||||
name: 'isCompleted',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the activity is completed or not',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* activity:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Activity ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Owner',
|
||||
name: 'owner',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains details related to the activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains tags associated with an activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
name: 'dueDate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Expiry date of an activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Duration',
|
||||
name: 'duration',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Time duration of an activity',
|
||||
},
|
||||
{
|
||||
displayName: 'Is Calendar Invite',
|
||||
name: 'isCalendarInvite',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to send calendar invite',
|
||||
},
|
||||
{
|
||||
displayName: 'Is Completed',
|
||||
name: 'isCompleted',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the activity is completed or not',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* activity:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Activity ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* activity:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 25,
|
||||
},
|
||||
default: 10,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'JSON Parameters',
|
||||
name: 'jsonParameters',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['activity'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Fields',
|
||||
name: 'fields',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated list of fields to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort By',
|
||||
name: 'sortBy',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The field to sort by',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort Order',
|
||||
name: 'sortOrder',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'ASC',
|
||||
value: 'asc',
|
||||
},
|
||||
{
|
||||
name: 'DESC',
|
||||
value: 'desc',
|
||||
},
|
||||
],
|
||||
default: 'desc',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filtersJson',
|
||||
type: 'json',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['activity'],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
placeholder: 'Add filter',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: false,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['getAll'],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'filtersUi',
|
||||
displayName: 'Filters',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Operator',
|
||||
name: 'operator',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'AND',
|
||||
value: 'AND',
|
||||
},
|
||||
{
|
||||
name: 'OR',
|
||||
value: 'OR',
|
||||
},
|
||||
],
|
||||
default: 'AND',
|
||||
},
|
||||
{
|
||||
displayName: 'Conditions',
|
||||
name: 'conditions',
|
||||
placeholder: 'Add Condition',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'conditionsUi',
|
||||
displayName: 'Conditions',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Field',
|
||||
name: 'field',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Title',
|
||||
value: 'title',
|
||||
},
|
||||
{
|
||||
name: 'Tags',
|
||||
value: 'tags',
|
||||
},
|
||||
],
|
||||
default: 'title',
|
||||
},
|
||||
{
|
||||
displayName: 'Condition',
|
||||
name: 'condition',
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Equals',
|
||||
value: 'EQUALS',
|
||||
},
|
||||
{
|
||||
name: 'Not Equals',
|
||||
value: 'NOT_EQUALS',
|
||||
},
|
||||
{
|
||||
name: 'CONTAINS',
|
||||
value: 'Contains',
|
||||
},
|
||||
{
|
||||
name: 'Does Not Contains',
|
||||
value: 'DOES_NOT_CONTAINS',
|
||||
},
|
||||
{
|
||||
name: 'Empty',
|
||||
value: 'EMPTY',
|
||||
},
|
||||
{
|
||||
name: 'Not Empty',
|
||||
value: 'NOT_EMPTY',
|
||||
},
|
||||
{
|
||||
name: 'Starts With',
|
||||
value: 'STARTS_WITH',
|
||||
},
|
||||
{
|
||||
name: 'Ends With',
|
||||
value: 'ENDS_WITH',
|
||||
},
|
||||
],
|
||||
default: 'EQUALS',
|
||||
description: 'Value of the property to set',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* activity:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Activity ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['activity'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
description: 'If more than one activity add them separated by ,',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface IActivity {
|
||||
title?: string;
|
||||
owner?: number;
|
||||
type?: string;
|
||||
description?: string;
|
||||
tags?: string;
|
||||
dueDate?: number;
|
||||
duration?: number;
|
||||
isCalendarInvite?: boolean;
|
||||
isCompleted?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,658 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const companyOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a company',
|
||||
action: 'Create a company',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a company',
|
||||
action: 'Delete a company',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a company',
|
||||
action: 'Get a company',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many companies',
|
||||
action: 'Get many companies',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a company',
|
||||
action: 'Update a company',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const companyFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Owner Name or ID',
|
||||
name: 'owner',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getUsers',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Website',
|
||||
name: 'website',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Other Phone',
|
||||
name: 'otherPhone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Facebook Handle',
|
||||
name: 'facebookHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Google Plus Handle',
|
||||
name: 'googlePlusHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'LinkedIn Handle',
|
||||
name: 'linkedInHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Skype ID',
|
||||
name: 'skypeId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Twitter Handle',
|
||||
name: 'twitterHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Address Line 1',
|
||||
name: 'billingAddressLine1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Address Line 2',
|
||||
name: 'billingAddressLine2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing City',
|
||||
name: 'billingCity',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Zip Code',
|
||||
name: 'billingZipCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing State',
|
||||
name: 'billingState',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Country',
|
||||
name: 'billingState',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Company ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Owner Name or ID',
|
||||
name: 'owner',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getUsers',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Website',
|
||||
name: 'website',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Other Phone',
|
||||
name: 'otherPhone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Facebook Handle',
|
||||
name: 'facebookHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Google Plus Handle',
|
||||
name: 'googlePlusHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'LinkedIn Handle',
|
||||
name: 'linkedInHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Skype ID',
|
||||
name: 'skypeId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Twitter Handle',
|
||||
name: 'twitterHandle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Address Line 1',
|
||||
name: 'billingAddressLine1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Address Line 2',
|
||||
name: 'billingAddressLine2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing City',
|
||||
name: 'billingCity',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Zip Code',
|
||||
name: 'billingZipCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing State',
|
||||
name: 'billingState',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Billing Country',
|
||||
name: 'billingState',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Company ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 25,
|
||||
},
|
||||
default: 10,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'JSON Parameters',
|
||||
name: 'jsonParameters',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['company'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Fields',
|
||||
name: 'fields',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated list of fields to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort By',
|
||||
name: 'sortBy',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The field to sort by',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort Order',
|
||||
name: 'sortOrder',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'ASC',
|
||||
value: 'asc',
|
||||
},
|
||||
{
|
||||
name: 'DESC',
|
||||
value: 'desc',
|
||||
},
|
||||
],
|
||||
default: 'desc',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filtersJson',
|
||||
type: 'json',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['company'],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
placeholder: 'Add filter',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: false,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['getAll'],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'filtersUi',
|
||||
displayName: 'Filters',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Operator',
|
||||
name: 'operator',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'AND',
|
||||
value: 'AND',
|
||||
},
|
||||
{
|
||||
name: 'OR',
|
||||
value: 'OR',
|
||||
},
|
||||
],
|
||||
default: 'AND',
|
||||
},
|
||||
{
|
||||
displayName: 'Conditions',
|
||||
name: 'conditions',
|
||||
placeholder: 'Add Condition',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'conditionsUi',
|
||||
displayName: 'Conditions',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Field',
|
||||
name: 'field',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Name',
|
||||
value: 'name',
|
||||
},
|
||||
{
|
||||
name: 'Email',
|
||||
value: 'email',
|
||||
},
|
||||
{
|
||||
name: 'Phone',
|
||||
value: 'phone',
|
||||
},
|
||||
],
|
||||
default: 'name',
|
||||
},
|
||||
{
|
||||
displayName: 'Condition',
|
||||
name: 'condition',
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Equals',
|
||||
value: 'EQUALS',
|
||||
},
|
||||
{
|
||||
name: 'Not Equals',
|
||||
value: 'NOT_EQUALS',
|
||||
},
|
||||
{
|
||||
name: 'CONTAINS',
|
||||
value: 'Contains',
|
||||
},
|
||||
{
|
||||
name: 'Does Not Contains',
|
||||
value: 'DOES_NOT_CONTAINS',
|
||||
},
|
||||
{
|
||||
name: 'Empty',
|
||||
value: 'EMPTY',
|
||||
},
|
||||
{
|
||||
name: 'Not Empty',
|
||||
value: 'NOT_EMPTY',
|
||||
},
|
||||
{
|
||||
name: 'Starts With',
|
||||
value: 'STARTS_WITH',
|
||||
},
|
||||
{
|
||||
name: 'Ends With',
|
||||
value: 'ENDS_WITH',
|
||||
},
|
||||
],
|
||||
default: 'EQUALS',
|
||||
description: 'Value of the property to set',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Company ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['company'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
description: 'If more than one company add them separated by ,',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,22 @@
|
||||
export interface ICompany {
|
||||
name?: string;
|
||||
owner?: number;
|
||||
website?: string;
|
||||
phone?: string;
|
||||
otherPhone?: string;
|
||||
googlePlusHandle?: string;
|
||||
linkedInHandle?: string;
|
||||
facebookHandle?: string;
|
||||
linkedinHandle?: string;
|
||||
skypeId?: string;
|
||||
twitterHandle?: string;
|
||||
currency?: string;
|
||||
billingAddressLine1?: string;
|
||||
billingAddressLine2?: string;
|
||||
billingCity?: string;
|
||||
billingZipCode?: string;
|
||||
billingCountry?: string;
|
||||
billingState?: string;
|
||||
description?: string;
|
||||
tags?: string;
|
||||
}
|
||||
@@ -0,0 +1,812 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const dealOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a deal',
|
||||
action: 'Create a deal',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a deal',
|
||||
action: 'Delete a deal',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a deal',
|
||||
action: 'Get a deal',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many deals',
|
||||
action: 'Get many deals',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a deal',
|
||||
action: 'Update a deal',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const dealFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* deal:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Owner Name or ID',
|
||||
name: 'owner',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getUsers',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Contact Name or ID',
|
||||
name: 'primaryContact',
|
||||
type: 'options',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getContacts',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description:
|
||||
'Primary contact for the deal. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Pipeline',
|
||||
name: 'pipeline',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Sales',
|
||||
value: 'Sales',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: 'Open',
|
||||
options: [
|
||||
{
|
||||
name: 'Open',
|
||||
value: 'Open',
|
||||
},
|
||||
{
|
||||
name: 'Close',
|
||||
value: 'Close',
|
||||
},
|
||||
{
|
||||
name: 'Lost',
|
||||
value: 'Lost',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Stage',
|
||||
name: 'stage',
|
||||
type: 'options',
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'New (Untouched)',
|
||||
value: 'New (Untouched)',
|
||||
},
|
||||
{
|
||||
name: 'Contacted',
|
||||
value: 'Contacted',
|
||||
},
|
||||
{
|
||||
name: 'Qualified',
|
||||
value: 'Qualified',
|
||||
},
|
||||
{
|
||||
name: 'In Negotiation',
|
||||
value: 'In Negotiation',
|
||||
},
|
||||
{
|
||||
name: 'Proposal Presented',
|
||||
value: 'Proposal Presented',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains details related to the deal',
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains tags associated with an deal',
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Company Name or ID',
|
||||
name: 'primaryCompany',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCompanies',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Source',
|
||||
name: 'source',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Ads',
|
||||
value: 'Ads',
|
||||
},
|
||||
{
|
||||
name: 'Referrals',
|
||||
value: 'Referrals',
|
||||
},
|
||||
{
|
||||
name: 'Website',
|
||||
value: 'Website',
|
||||
},
|
||||
{
|
||||
name: 'Word of Mouth',
|
||||
value: 'Word of mouth',
|
||||
},
|
||||
],
|
||||
default: 'Ads',
|
||||
},
|
||||
{
|
||||
displayName: 'Estimated Close Date',
|
||||
name: 'estimatedCloseDate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Deal Value',
|
||||
name: 'dealValue',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
numberPrecision: 2,
|
||||
},
|
||||
default: 0,
|
||||
},
|
||||
{
|
||||
displayName: 'Priority',
|
||||
name: 'priority',
|
||||
type: 'options',
|
||||
default: 'Medium',
|
||||
options: [
|
||||
{
|
||||
name: 'High',
|
||||
value: 'High',
|
||||
},
|
||||
{
|
||||
name: 'Medium',
|
||||
value: 'Medium',
|
||||
},
|
||||
{
|
||||
name: 'Low',
|
||||
value: 'Low',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* deal:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Deal ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Owner Name or ID',
|
||||
name: 'owner',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getUsers',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Contact Name or ID',
|
||||
name: 'primaryContact',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getContacts',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Pipeline',
|
||||
name: 'pipeline',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Sales',
|
||||
value: 'Sales',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: 'Open',
|
||||
options: [
|
||||
{
|
||||
name: 'Open',
|
||||
value: 'Open',
|
||||
},
|
||||
{
|
||||
name: 'Close',
|
||||
value: 'Close',
|
||||
},
|
||||
{
|
||||
name: 'Lost',
|
||||
value: 'Lost',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Stage',
|
||||
name: 'stage',
|
||||
type: 'options',
|
||||
default: '',
|
||||
options: [
|
||||
{
|
||||
name: 'Contacted',
|
||||
value: 'Contacted',
|
||||
},
|
||||
{
|
||||
name: 'In Negotiation',
|
||||
value: 'In Negotiation',
|
||||
},
|
||||
{
|
||||
name: 'New (Untouched)',
|
||||
value: 'New (Untouched)',
|
||||
},
|
||||
{
|
||||
name: 'Proposal Presented',
|
||||
value: 'Proposal Presented',
|
||||
},
|
||||
{
|
||||
name: 'Qualified',
|
||||
value: 'Qualified',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains details related to the deal',
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'This field contains tags associated with an deal',
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Company Name or ID',
|
||||
name: 'primaryCompany',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCompanies',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Source',
|
||||
name: 'source',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Ads',
|
||||
value: 'Ads',
|
||||
},
|
||||
{
|
||||
name: 'Referrals',
|
||||
value: 'Referrals',
|
||||
},
|
||||
{
|
||||
name: 'Website',
|
||||
value: 'Website',
|
||||
},
|
||||
{
|
||||
name: 'Word of Mouth',
|
||||
value: 'Word of mouth',
|
||||
},
|
||||
],
|
||||
default: 'Ads',
|
||||
},
|
||||
{
|
||||
displayName: 'Estimated Close Date',
|
||||
name: 'estimatedCloseDate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Deal Value',
|
||||
name: 'dealValue',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
numberPrecision: 2,
|
||||
},
|
||||
default: 0,
|
||||
},
|
||||
{
|
||||
displayName: 'Priority',
|
||||
name: 'priority',
|
||||
type: 'options',
|
||||
default: 'Medium',
|
||||
options: [
|
||||
{
|
||||
name: 'High',
|
||||
value: 'High',
|
||||
},
|
||||
{
|
||||
name: 'Medium',
|
||||
value: 'Medium',
|
||||
},
|
||||
{
|
||||
name: 'Low',
|
||||
value: 'Low',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* deal:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Deal ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'RAW Data',
|
||||
name: 'rawData',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether the data should include the fields details',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* deal:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 25,
|
||||
},
|
||||
default: 10,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'JSON Parameters',
|
||||
name: 'jsonParameters',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['deal'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Fields',
|
||||
name: 'fields',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated list of fields to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort By',
|
||||
name: 'sortBy',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The field to sort by',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort Order',
|
||||
name: 'sortOrder',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'ASC',
|
||||
value: 'asc',
|
||||
},
|
||||
{
|
||||
name: 'DESC',
|
||||
value: 'desc',
|
||||
},
|
||||
],
|
||||
default: 'desc',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filtersJson',
|
||||
type: 'json',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['deal'],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
placeholder: 'Add filter',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: false,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['getAll'],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'filtersUi',
|
||||
displayName: 'Filters',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Operator',
|
||||
name: 'operator',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'AND',
|
||||
value: 'AND',
|
||||
},
|
||||
{
|
||||
name: 'OR',
|
||||
value: 'OR',
|
||||
},
|
||||
],
|
||||
default: 'AND',
|
||||
},
|
||||
{
|
||||
displayName: 'Conditions',
|
||||
name: 'conditions',
|
||||
placeholder: 'Add Condition',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'conditionsUi',
|
||||
displayName: 'Conditions',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Field',
|
||||
name: 'field',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Title',
|
||||
value: 'title',
|
||||
},
|
||||
{
|
||||
name: 'Tags',
|
||||
value: 'tags',
|
||||
},
|
||||
{
|
||||
name: 'Last Communication Mode',
|
||||
value: 'lastCommunicationMode',
|
||||
},
|
||||
],
|
||||
default: 'title',
|
||||
},
|
||||
{
|
||||
displayName: 'Condition',
|
||||
name: 'condition',
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Equals',
|
||||
value: 'EQUALS',
|
||||
},
|
||||
{
|
||||
name: 'Not Equals',
|
||||
value: 'NOT_EQUALS',
|
||||
},
|
||||
{
|
||||
name: 'CONTAINS',
|
||||
value: 'Contains',
|
||||
},
|
||||
{
|
||||
name: 'Does Not Contains',
|
||||
value: 'DOES_NOT_CONTAINS',
|
||||
},
|
||||
{
|
||||
name: 'Empty',
|
||||
value: 'EMPTY',
|
||||
},
|
||||
{
|
||||
name: 'Not Empty',
|
||||
value: 'NOT_EMPTY',
|
||||
},
|
||||
{
|
||||
name: 'Starts With',
|
||||
value: 'STARTS_WITH',
|
||||
},
|
||||
{
|
||||
name: 'Ends With',
|
||||
value: 'ENDS_WITH',
|
||||
},
|
||||
],
|
||||
default: 'EQUALS',
|
||||
description: 'Value of the property to set',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* deal:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Deal ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['deal'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
description: 'If more than one deal add them separated by ,',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
export interface IDeal {
|
||||
title?: string;
|
||||
owner?: number;
|
||||
pipeline?: string;
|
||||
primaryContact?: number;
|
||||
primaryCompany?: number;
|
||||
status?: string;
|
||||
stage?: string;
|
||||
source?: string;
|
||||
estimatedCloseDate?: string;
|
||||
dealValue?: number;
|
||||
currency?: string;
|
||||
priority?: string;
|
||||
description?: string;
|
||||
tags?: string;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IWebhookFunctions,
|
||||
JsonObject,
|
||||
IRequestOptions,
|
||||
IHttpRequestMethods,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function salesmateApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
_option: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('salesmateApi');
|
||||
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
sessionToken: credentials.sessionToken,
|
||||
'x-linkname': credentials.url,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: uri || `https://apis.salesmate.io${resource}`,
|
||||
json: true,
|
||||
};
|
||||
if (!Object.keys(body as IDataObject).length) {
|
||||
delete options.body;
|
||||
}
|
||||
try {
|
||||
return await this.helpers.request(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
export async function salesmateApiRequestAllItems(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
query.pageNo = 1;
|
||||
query.rows = 25;
|
||||
do {
|
||||
responseData = await salesmateApiRequest.call(this, method, resource, body, query);
|
||||
returnData.push.apply(returnData, responseData[propertyName].data as IDataObject[]);
|
||||
query.pageNo++;
|
||||
} while (
|
||||
responseData[propertyName].totalPages !== undefined &&
|
||||
query.pageNo <= responseData[propertyName].totalPages
|
||||
);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): any {
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
} catch (exception) {
|
||||
result = undefined;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts data from the Salesmate format into a simple object
|
||||
*
|
||||
*/
|
||||
export function simplifySalesmateData(data: IDataObject[]): IDataObject {
|
||||
const returnData: IDataObject = {};
|
||||
|
||||
for (const item of data) {
|
||||
returnData[item.fieldName as string] = item.value;
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.salesmate",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Sales"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/salesmate/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.salesmate/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,796 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { activityFields, activityOperations } from './ActivityDescription';
|
||||
import type { IActivity } from './ActivityInterface';
|
||||
import { companyFields, companyOperations } from './CompanyDescription';
|
||||
import type { ICompany } from './CompanyInterface';
|
||||
import { dealFields, dealOperations } from './DealDescription';
|
||||
import type { IDeal } from './DealInterface';
|
||||
import {
|
||||
salesmateApiRequest,
|
||||
salesmateApiRequestAllItems,
|
||||
simplifySalesmateData,
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
|
||||
export class Salesmate implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Salesmate',
|
||||
name: 'salesmate',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
|
||||
icon: 'file:salesmate.png',
|
||||
group: ['output'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
|
||||
description: 'Consume Salesmate API',
|
||||
defaults: {
|
||||
name: 'Salesmate',
|
||||
},
|
||||
usableAsTool: true,
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'salesmateApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Activity',
|
||||
value: 'activity',
|
||||
},
|
||||
{
|
||||
name: 'Company',
|
||||
value: 'company',
|
||||
},
|
||||
{
|
||||
name: 'Deal',
|
||||
value: 'deal',
|
||||
},
|
||||
],
|
||||
default: 'activity',
|
||||
},
|
||||
...companyOperations,
|
||||
...activityOperations,
|
||||
...dealOperations,
|
||||
...companyFields,
|
||||
...activityFields,
|
||||
...dealFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the available users to display them to user so that they can
|
||||
// select them easily
|
||||
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const users = await salesmateApiRequest.call(this, 'GET', '/v1/users/active');
|
||||
for (const user of users.Data) {
|
||||
const userName = user.nickname;
|
||||
const userId = user.id;
|
||||
returnData.push({
|
||||
name: userName,
|
||||
value: userId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the available contacs to display them to user so that they can
|
||||
// select them easily
|
||||
async getContacts(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const qs: IDataObject = {
|
||||
fields: ['name', 'id'],
|
||||
query: {},
|
||||
};
|
||||
const contacts = await salesmateApiRequest.call(this, 'POST', '/v2/contacts/search', qs);
|
||||
for (const contact of contacts.Data.data) {
|
||||
const contactName = contact.name;
|
||||
const contactId = contact.id;
|
||||
returnData.push({
|
||||
name: contactName,
|
||||
value: contactId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the available companies to display them to user so that they can
|
||||
// select them easily
|
||||
async getCompanies(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const qs: IDataObject = {
|
||||
fields: ['name', 'id'],
|
||||
query: {},
|
||||
};
|
||||
const companies = await salesmateApiRequest.call(this, 'POST', '/v2/companies/search', qs);
|
||||
for (const company of companies.Data.data) {
|
||||
const companyName = company.name;
|
||||
const companyId = company.id;
|
||||
returnData.push({
|
||||
name: companyName,
|
||||
value: companyId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length;
|
||||
const qs: IDataObject = {};
|
||||
let responseData;
|
||||
const resource = this.getNodeParameter('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (resource === 'company') {
|
||||
if (operation === 'create') {
|
||||
const owner = this.getNodeParameter('owner', i) as number;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: ICompany = {
|
||||
name,
|
||||
owner,
|
||||
};
|
||||
if (additionalFields.website) {
|
||||
body.website = additionalFields.website as string;
|
||||
}
|
||||
if (additionalFields.phone) {
|
||||
body.phone = additionalFields.phone as string;
|
||||
}
|
||||
if (additionalFields.otherPhone) {
|
||||
body.otherPhone = additionalFields.otherPhone as string;
|
||||
}
|
||||
if (additionalFields.facebookHandle) {
|
||||
body.facebookHandle = additionalFields.facebookHandle as string;
|
||||
}
|
||||
if (additionalFields.googlePlusHandle) {
|
||||
body.googlePlusHandle = additionalFields.googlePlusHandle as string;
|
||||
}
|
||||
if (additionalFields.linkedInHandle) {
|
||||
body.linkedInHandle = additionalFields.linkedInHandle as string;
|
||||
}
|
||||
if (additionalFields.skypeId) {
|
||||
body.skypeId = additionalFields.skypeId as string;
|
||||
}
|
||||
if (additionalFields.twitterHandle) {
|
||||
body.twitterHandle = additionalFields.twitterHandle as string;
|
||||
}
|
||||
if (additionalFields.currency) {
|
||||
body.currency = additionalFields.currency as string;
|
||||
}
|
||||
if (additionalFields.billingAddressLine1) {
|
||||
body.billingAddressLine1 = additionalFields.billingAddressLine1 as string;
|
||||
}
|
||||
if (additionalFields.billingAddressLine2) {
|
||||
body.billingAddressLine2 = additionalFields.billingAddressLine2 as string;
|
||||
}
|
||||
if (additionalFields.billingCity) {
|
||||
body.billingCity = additionalFields.billingCity as string;
|
||||
}
|
||||
if (additionalFields.billingZipCode) {
|
||||
body.billingZipCode = additionalFields.billingZipCode as string;
|
||||
}
|
||||
if (additionalFields.billingState) {
|
||||
body.billingState = additionalFields.billingState as string;
|
||||
}
|
||||
if (additionalFields.description) {
|
||||
body.description = additionalFields.description as string;
|
||||
}
|
||||
if (additionalFields.tags) {
|
||||
body.tags = additionalFields.tags as string;
|
||||
}
|
||||
responseData = await salesmateApiRequest.call(this, 'POST', '/v1/companies', body);
|
||||
responseData = responseData.Data;
|
||||
if (!rawData) {
|
||||
delete responseData.detail;
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const companyId = this.getNodeParameter('id', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
const body: ICompany = {};
|
||||
if (updateFields.owner) {
|
||||
body.owner = updateFields.owner as number;
|
||||
}
|
||||
if (updateFields.name) {
|
||||
body.name = updateFields.name as string;
|
||||
}
|
||||
if (updateFields.website) {
|
||||
body.website = updateFields.website as string;
|
||||
}
|
||||
if (updateFields.phone) {
|
||||
body.phone = updateFields.phone as string;
|
||||
}
|
||||
if (updateFields.otherPhone) {
|
||||
body.otherPhone = updateFields.otherPhone as string;
|
||||
}
|
||||
if (updateFields.facebookHandle) {
|
||||
body.facebookHandle = updateFields.facebookHandle as string;
|
||||
}
|
||||
if (updateFields.googlePlusHandle) {
|
||||
body.googlePlusHandle = updateFields.googlePlusHandle as string;
|
||||
}
|
||||
if (updateFields.linkedInHandle) {
|
||||
body.linkedInHandle = updateFields.linkedInHandle as string;
|
||||
}
|
||||
if (updateFields.skypeId) {
|
||||
body.skypeId = updateFields.skypeId as string;
|
||||
}
|
||||
if (updateFields.twitterHandle) {
|
||||
body.twitterHandle = updateFields.twitterHandle as string;
|
||||
}
|
||||
if (updateFields.currency) {
|
||||
body.currency = updateFields.currency as string;
|
||||
}
|
||||
if (updateFields.billingAddressLine1) {
|
||||
body.billingAddressLine1 = updateFields.billingAddressLine1 as string;
|
||||
}
|
||||
if (updateFields.billingAddressLine2) {
|
||||
body.billingAddressLine2 = updateFields.billingAddressLine2 as string;
|
||||
}
|
||||
if (updateFields.billingCity) {
|
||||
body.billingCity = updateFields.billingCity as string;
|
||||
}
|
||||
if (updateFields.billingZipCode) {
|
||||
body.billingZipCode = updateFields.billingZipCode as string;
|
||||
}
|
||||
if (updateFields.billingState) {
|
||||
body.billingState = updateFields.billingState as string;
|
||||
}
|
||||
if (updateFields.description) {
|
||||
body.description = updateFields.description as string;
|
||||
}
|
||||
if (updateFields.tags) {
|
||||
body.tags = updateFields.tags as string;
|
||||
}
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/v1/companies/${companyId}`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.Data;
|
||||
if (!rawData) {
|
||||
delete responseData.detail;
|
||||
}
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const companyId = this.getNodeParameter('id', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
responseData = await salesmateApiRequest.call(this, 'GET', `/v1/companies/${companyId}`);
|
||||
responseData = responseData.Data;
|
||||
|
||||
if (!rawData) {
|
||||
responseData = simplifySalesmateData(responseData as IDataObject[]);
|
||||
}
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const jsonActive = this.getNodeParameter('jsonParameters', i);
|
||||
let body: IDataObject = {
|
||||
query: {
|
||||
group: {},
|
||||
},
|
||||
};
|
||||
if (options.sortBy) {
|
||||
qs.sortBy = options.sortBy as string;
|
||||
}
|
||||
if (options.sortOrder) {
|
||||
qs.sortOrder = options.sortOrder as string;
|
||||
}
|
||||
if (options.fields) {
|
||||
if ((options.fields as string).trim() === '') {
|
||||
throw new NodeOperationError(this.getNode(), 'You have to add at least one field', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
body.fields = (options.fields as string).split(',');
|
||||
} else {
|
||||
body.fields = [
|
||||
'name',
|
||||
'description',
|
||||
'billingAddressLine1',
|
||||
'billingAddressLine2',
|
||||
'billingCity',
|
||||
'billingZipCode',
|
||||
'billingState',
|
||||
'billingCountry',
|
||||
'website',
|
||||
'owner',
|
||||
'tags',
|
||||
'photo',
|
||||
'createdAt',
|
||||
];
|
||||
}
|
||||
if (!jsonActive) {
|
||||
const filters: IDataObject[] = [];
|
||||
const filtersUi = this.getNodeParameter('filters', i).filtersUi as IDataObject;
|
||||
if (filtersUi?.conditions) {
|
||||
const conditions = filtersUi.conditions as IDataObject;
|
||||
if (conditions.conditionsUi) {
|
||||
for (const condition of conditions.conditionsUi as IDataObject[]) {
|
||||
const filter: IDataObject = {};
|
||||
filter.moduleName = 'Company';
|
||||
filter.field = {
|
||||
fieldName: condition.field,
|
||||
};
|
||||
filter.condition = condition.condition;
|
||||
filter.data = condition.value;
|
||||
filters.push(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filtersUi?.operator) {
|
||||
//@ts-ignore
|
||||
body.query.group = {
|
||||
operator: filtersUi.operator,
|
||||
rules: filters,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
const json = validateJSON(this.getNodeParameter('filtersJson', i) as string);
|
||||
body = json;
|
||||
}
|
||||
if (returnAll) {
|
||||
responseData = await salesmateApiRequestAllItems.call(
|
||||
this,
|
||||
'Data',
|
||||
'POST',
|
||||
'/v2/companies/search',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.rows = limit;
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/v2/companies/search',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.Data.data;
|
||||
}
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const companyId = parseInt(this.getNodeParameter('id', i) as string, 10);
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1/companies/${companyId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (resource === 'activity') {
|
||||
if (operation === 'create') {
|
||||
const owner = this.getNodeParameter('owner', i) as number;
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const type = this.getNodeParameter('type', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IActivity = {
|
||||
title,
|
||||
owner,
|
||||
type,
|
||||
};
|
||||
if (additionalFields.dueDate) {
|
||||
body.dueDate = new Date(additionalFields.dueDate as string).getTime();
|
||||
}
|
||||
if (additionalFields.duration) {
|
||||
body.duration = additionalFields.duration as number;
|
||||
}
|
||||
if (additionalFields.isCalendarInvite) {
|
||||
body.isCalendarInvite = additionalFields.isCalendarInvite as boolean;
|
||||
}
|
||||
if (additionalFields.isCompleted) {
|
||||
body.isCompleted = additionalFields.isCompleted as boolean;
|
||||
}
|
||||
if (additionalFields.description) {
|
||||
body.description = additionalFields.description as string;
|
||||
}
|
||||
if (additionalFields.tags) {
|
||||
body.tags = additionalFields.tags as string;
|
||||
}
|
||||
responseData = await salesmateApiRequest.call(this, 'POST', '/v1/activities', body);
|
||||
responseData = responseData.Data;
|
||||
if (!rawData) {
|
||||
delete responseData.detail;
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const activityId = this.getNodeParameter('id', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IActivity = {};
|
||||
if (updateFields.title) {
|
||||
body.title = updateFields.title as string;
|
||||
}
|
||||
if (updateFields.type) {
|
||||
body.type = updateFields.type as string;
|
||||
}
|
||||
if (updateFields.owner) {
|
||||
body.owner = updateFields.owner as number;
|
||||
}
|
||||
if (updateFields.dueDate) {
|
||||
body.dueDate = new Date(updateFields.dueDate as string).getTime();
|
||||
}
|
||||
if (updateFields.duration) {
|
||||
body.duration = updateFields.duration as number;
|
||||
}
|
||||
if (updateFields.isCalendarInvite) {
|
||||
body.isCalendarInvite = updateFields.isCalendarInvite as boolean;
|
||||
}
|
||||
if (updateFields.isCompleted) {
|
||||
body.isCompleted = updateFields.isCompleted as boolean;
|
||||
}
|
||||
if (updateFields.description) {
|
||||
body.description = updateFields.description as string;
|
||||
}
|
||||
if (updateFields.tags) {
|
||||
body.tags = updateFields.tags as string;
|
||||
}
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/v1/activities/${activityId}`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.Data;
|
||||
if (!rawData) {
|
||||
delete responseData.detail;
|
||||
}
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const activityId = this.getNodeParameter('id', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1/activities/${activityId}`,
|
||||
);
|
||||
responseData = responseData.Data;
|
||||
|
||||
if (!rawData) {
|
||||
responseData = simplifySalesmateData(responseData as IDataObject[]);
|
||||
}
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const jsonActive = this.getNodeParameter('jsonParameters', i);
|
||||
let body: IDataObject = {
|
||||
query: {
|
||||
group: {},
|
||||
},
|
||||
};
|
||||
if (options.sortBy) {
|
||||
qs.sortBy = options.sortBy as string;
|
||||
}
|
||||
if (options.sortOrder) {
|
||||
qs.sortOrder = options.sortOrder as string;
|
||||
}
|
||||
if (options.fields) {
|
||||
if ((options.fields as string).trim() === '') {
|
||||
throw new NodeOperationError(this.getNode(), 'You have to add at least one field', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
body.fields = (options.fields as string).split(',');
|
||||
} else {
|
||||
body.fields = [
|
||||
'title',
|
||||
'dueDate',
|
||||
'description',
|
||||
'duration',
|
||||
'owner',
|
||||
'Deal.title',
|
||||
'PrimaryContact.name',
|
||||
'PrimaryContact.email',
|
||||
'PrimaryCompany.name',
|
||||
'PrimaryCompany.email',
|
||||
'tags',
|
||||
'type',
|
||||
'createdAt',
|
||||
'isCompleted',
|
||||
];
|
||||
}
|
||||
if (!jsonActive) {
|
||||
const filters: IDataObject[] = [];
|
||||
const filtersUi = this.getNodeParameter('filters', i).filtersUi as IDataObject;
|
||||
if (filtersUi?.conditions) {
|
||||
const conditions = filtersUi.conditions as IDataObject;
|
||||
if (conditions.conditionsUi) {
|
||||
for (const condition of conditions.conditionsUi as IDataObject[]) {
|
||||
const filter: IDataObject = {};
|
||||
filter.moduleName = 'Task';
|
||||
filter.field = {
|
||||
fieldName: condition.field,
|
||||
};
|
||||
filter.condition = condition.condition;
|
||||
filter.data = condition.value;
|
||||
filters.push(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filtersUi?.operator) {
|
||||
//@ts-ignore
|
||||
body.query.group = {
|
||||
operator: filtersUi.operator,
|
||||
rules: filters,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
const json = validateJSON(this.getNodeParameter('filtersJson', i) as string);
|
||||
body = json;
|
||||
}
|
||||
if (returnAll) {
|
||||
responseData = await salesmateApiRequestAllItems.call(
|
||||
this,
|
||||
'Data',
|
||||
'POST',
|
||||
'/v2/activities/search',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.rows = limit;
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/v2/activities/search',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.Data.data;
|
||||
}
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const activityId = this.getNodeParameter('id', i) as string;
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1/activities/${activityId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (resource === 'deal') {
|
||||
if (operation === 'create') {
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const owner = this.getNodeParameter('owner', i) as number;
|
||||
const primaryContact = this.getNodeParameter('primaryContact', i) as number;
|
||||
const pipeline = this.getNodeParameter('pipeline', i) as string;
|
||||
const status = this.getNodeParameter('status', i) as string;
|
||||
const stage = this.getNodeParameter('stage', i) as string;
|
||||
const currency = this.getNodeParameter('currency', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IDeal = {
|
||||
title,
|
||||
owner,
|
||||
primaryContact,
|
||||
pipeline,
|
||||
status,
|
||||
stage,
|
||||
currency,
|
||||
};
|
||||
if (additionalFields.description) {
|
||||
body.description = additionalFields.description as string;
|
||||
}
|
||||
if (additionalFields.tags) {
|
||||
body.tags = additionalFields.tags as string;
|
||||
}
|
||||
if (additionalFields.primaryCompany) {
|
||||
body.primaryCompany = additionalFields.primaryCompany as number;
|
||||
}
|
||||
if (additionalFields.source) {
|
||||
body.source = additionalFields.source as string;
|
||||
}
|
||||
if (additionalFields.estimatedCloseDate) {
|
||||
body.estimatedCloseDate = additionalFields.estimatedCloseDate as string;
|
||||
}
|
||||
if (additionalFields.dealValue) {
|
||||
body.dealValue = additionalFields.dealValue as number;
|
||||
}
|
||||
if (additionalFields.priority) {
|
||||
body.priority = additionalFields.priority as string;
|
||||
}
|
||||
responseData = await salesmateApiRequest.call(this, 'POST', '/v1/deals', body);
|
||||
responseData = responseData.Data;
|
||||
if (!rawData) {
|
||||
delete responseData.detail;
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const dealId = this.getNodeParameter('id', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDeal = {};
|
||||
if (updateFields.title) {
|
||||
body.title = updateFields.title as string;
|
||||
}
|
||||
if (updateFields.owner) {
|
||||
body.owner = updateFields.owner as number;
|
||||
}
|
||||
if (updateFields.primaryContact) {
|
||||
body.primaryContact = updateFields.primaryContact as number;
|
||||
}
|
||||
if (updateFields.status) {
|
||||
body.status = updateFields.status as string;
|
||||
}
|
||||
if (updateFields.currency) {
|
||||
body.currency = updateFields.currency as string;
|
||||
}
|
||||
if (updateFields.stage) {
|
||||
body.stage = updateFields.stage as string;
|
||||
}
|
||||
if (updateFields.pipeline) {
|
||||
body.pipeline = updateFields.pipeline as string;
|
||||
}
|
||||
if (updateFields.description) {
|
||||
body.description = updateFields.description as string;
|
||||
}
|
||||
if (updateFields.tags) {
|
||||
body.tags = updateFields.tags as string;
|
||||
}
|
||||
if (updateFields.primaryCompany) {
|
||||
body.primaryCompany = updateFields.primaryCompany as number;
|
||||
}
|
||||
if (updateFields.source) {
|
||||
body.source = updateFields.source as string;
|
||||
}
|
||||
if (updateFields.estimatedCloseDate) {
|
||||
body.estimatedCloseDate = updateFields.estimatedCloseDate as string;
|
||||
}
|
||||
if (updateFields.dealValue) {
|
||||
body.dealValue = updateFields.dealValue as number;
|
||||
}
|
||||
if (updateFields.priority) {
|
||||
body.priority = updateFields.priority as string;
|
||||
}
|
||||
responseData = await salesmateApiRequest.call(this, 'PUT', `/v1/deals/${dealId}`, body);
|
||||
responseData = responseData.Data;
|
||||
if (!rawData) {
|
||||
delete responseData.detail;
|
||||
}
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const dealId = this.getNodeParameter('id', i) as string;
|
||||
const rawData = this.getNodeParameter('rawData', i);
|
||||
responseData = await salesmateApiRequest.call(this, 'GET', `/v1/deals/${dealId}`);
|
||||
responseData = responseData.Data;
|
||||
|
||||
if (!rawData) {
|
||||
responseData = simplifySalesmateData(responseData as IDataObject[]);
|
||||
}
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const jsonActive = this.getNodeParameter('jsonParameters', i);
|
||||
let body: IDataObject = {
|
||||
query: {
|
||||
group: {},
|
||||
},
|
||||
};
|
||||
if (options.sortBy) {
|
||||
qs.sortBy = options.sortBy as string;
|
||||
}
|
||||
if (options.sortOrder) {
|
||||
qs.sortOrder = options.sortOrder as string;
|
||||
}
|
||||
if (options.fields !== undefined) {
|
||||
if ((options.fields as string).trim() === '') {
|
||||
throw new NodeOperationError(this.getNode(), 'You have to add at least one field', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
body.fields = (options.fields as string).split(',');
|
||||
} else {
|
||||
body.fields = [
|
||||
'title',
|
||||
'PrimaryContact.name',
|
||||
'PrimaryContact.email',
|
||||
'PrimaryCompany.name',
|
||||
'PrimaryCompany.email',
|
||||
'dealValue',
|
||||
'priority',
|
||||
'stage',
|
||||
'status',
|
||||
'owner',
|
||||
'tags',
|
||||
'createdAt',
|
||||
];
|
||||
}
|
||||
if (!jsonActive) {
|
||||
const filters: IDataObject[] = [];
|
||||
const filtersUi = this.getNodeParameter('filters', i).filtersUi as IDataObject;
|
||||
if (filtersUi?.conditions) {
|
||||
const conditions = filtersUi.conditions as IDataObject;
|
||||
if (conditions.conditionsUi) {
|
||||
for (const condition of conditions.conditionsUi as IDataObject[]) {
|
||||
const filter: IDataObject = {};
|
||||
filter.moduleName = 'Task';
|
||||
filter.field = {
|
||||
fieldName: condition.field,
|
||||
};
|
||||
filter.condition = condition.condition;
|
||||
filter.data = condition.value;
|
||||
filters.push(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filtersUi?.operator) {
|
||||
//@ts-ignore
|
||||
body.query.group = {
|
||||
operator: filtersUi.operator,
|
||||
rules: filters,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
const json = validateJSON(this.getNodeParameter('filtersJson', i) as string);
|
||||
body = json;
|
||||
}
|
||||
if (returnAll) {
|
||||
responseData = await salesmateApiRequestAllItems.call(
|
||||
this,
|
||||
'Data',
|
||||
'POST',
|
||||
'/v2/deals/search',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.rows = limit;
|
||||
responseData = await salesmateApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/v2/deals/search',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.Data.data;
|
||||
}
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const dealId = this.getNodeParameter('id', i) as string;
|
||||
responseData = await salesmateApiRequest.call(this, 'DELETE', `/v1/deals/${dealId}`);
|
||||
}
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 629 B |
Reference in New Issue
Block a user