mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
✨ Add Copper node (#1571)
* 🎉 Register regular node * 🎨 Replace PNG with SVG icon * ✨ Add Copper regular node * ⚡ Add user and customer sources * 👕 Appease linter * ⚡ Handle listings in getAll operations * ⚡ Implement continueOnFail * ⚡ Simplify pagination * 🔨 Fix fields adjustments for person * zap: Improvements * ⚡ Minor fixes * ⚡ Fix Lead Email update & Minor improvements Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
45c0d6598f
commit
dd6d523b85
704
packages/nodes-base/nodes/Copper/Copper.node.ts
Normal file
704
packages/nodes-base/nodes/Copper/Copper.node.ts
Normal file
|
@ -0,0 +1,704 @@
|
|||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
adjustCompanyFields,
|
||||
adjustLeadFields,
|
||||
adjustPersonFields,
|
||||
adjustTaskFields,
|
||||
copperApiRequest,
|
||||
handleListing,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
companyFields,
|
||||
companyOperations,
|
||||
customerSourceFields,
|
||||
customerSourceOperations,
|
||||
leadFields,
|
||||
leadOperations,
|
||||
opportunityFields,
|
||||
opportunityOperations,
|
||||
personFields,
|
||||
personOperations,
|
||||
projectFields,
|
||||
projectOperations,
|
||||
taskFields,
|
||||
taskOperations,
|
||||
userFields,
|
||||
userOperations,
|
||||
} from './descriptions';
|
||||
|
||||
export class Copper implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Copper',
|
||||
name: 'copper',
|
||||
icon: 'file:copper.svg',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume the Copper API',
|
||||
defaults: {
|
||||
name: 'Copper',
|
||||
color: '#ff2564',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'copperApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Company',
|
||||
value: 'company',
|
||||
},
|
||||
{
|
||||
name: 'Customer Source',
|
||||
value: 'customerSource',
|
||||
},
|
||||
{
|
||||
name: 'Lead',
|
||||
value: 'lead',
|
||||
},
|
||||
{
|
||||
name: 'Opportunity',
|
||||
value: 'opportunity',
|
||||
},
|
||||
{
|
||||
name: 'Person',
|
||||
value: 'person',
|
||||
},
|
||||
{
|
||||
name: 'Project',
|
||||
value: 'project',
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
value: 'user',
|
||||
},
|
||||
],
|
||||
default: 'company',
|
||||
description: 'Resource to consume',
|
||||
},
|
||||
...companyOperations,
|
||||
...companyFields,
|
||||
...customerSourceOperations,
|
||||
...customerSourceFields,
|
||||
...leadOperations,
|
||||
...leadFields,
|
||||
...opportunityOperations,
|
||||
...opportunityFields,
|
||||
...personOperations,
|
||||
...personFields,
|
||||
...projectOperations,
|
||||
...projectFields,
|
||||
...taskOperations,
|
||||
...taskFields,
|
||||
...userOperations,
|
||||
...userFields,
|
||||
],
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
let responseData;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
||||
try {
|
||||
|
||||
if (resource === 'company') {
|
||||
|
||||
// **********************************************************************
|
||||
// company
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------------
|
||||
// company: create
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/companies/create-a-new-company.html
|
||||
|
||||
const body: IDataObject = {
|
||||
name: this.getNodeParameter('name', i),
|
||||
};
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(additionalFields).length) {
|
||||
Object.assign(body, adjustCompanyFields(additionalFields));
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'POST', '/companies', body);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------------
|
||||
// company: delete
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/companies/delete-a-company.html
|
||||
|
||||
const companyId = this.getNodeParameter('companyId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'DELETE', `/companies/${companyId}`);
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// company: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/companies/fetch-a-company-by-id.html
|
||||
|
||||
const companyId = this.getNodeParameter('companyId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'GET', `/companies/${companyId}`);
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// company: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/companies/list-companies-search.html
|
||||
|
||||
const body: IDataObject = {};
|
||||
const filterFields = this.getNodeParameter('filterFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(filterFields).length) {
|
||||
Object.assign(body, filterFields);
|
||||
}
|
||||
|
||||
responseData = await handleListing.call(this, 'POST', '/companies/search', body);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// company: update
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/companies/update-a-company.html
|
||||
|
||||
const companyId = this.getNodeParameter('companyId', i);
|
||||
|
||||
const body: IDataObject = {};
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(updateFields).length) {
|
||||
Object.assign(body, adjustCompanyFields(updateFields));
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'PUT', `/companies/${companyId}`, body);
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'customerSource') {
|
||||
|
||||
// **********************************************************************
|
||||
// customerSource
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// customerSource: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
responseData = await handleListing.call(this, 'GET', '/customer_sources');
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'lead') {
|
||||
|
||||
// **********************************************************************
|
||||
// lead
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: create
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/leads/create-a-new-lead.html
|
||||
|
||||
const body: IDataObject = {
|
||||
name: this.getNodeParameter('name', i),
|
||||
};
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(additionalFields).length) {
|
||||
Object.assign(body, adjustLeadFields(additionalFields));
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'POST', '/leads', body);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: delete
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/leads/delete-a-lead.html
|
||||
|
||||
const leadId = this.getNodeParameter('leadId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'DELETE', `/leads/${leadId}`);
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/leads/fetch-a-lead-by-id.html
|
||||
|
||||
const leadId = this.getNodeParameter('leadId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'GET', `/leads/${leadId}`);
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
const body: IDataObject = {};
|
||||
const filterFields = this.getNodeParameter('filterFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(filterFields).length) {
|
||||
Object.assign(body, filterFields);
|
||||
}
|
||||
|
||||
responseData = await handleListing.call(this, 'POST', '/leads/search', body);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: update
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/leads/update-a-lead.html
|
||||
|
||||
const leadId = this.getNodeParameter('leadId', i);
|
||||
|
||||
const body: IDataObject = {};
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(updateFields).length) {
|
||||
Object.assign(body, adjustLeadFields(updateFields));
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'PUT', `/leads/${leadId}`, body);
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'opportunity') {
|
||||
|
||||
// **********************************************************************
|
||||
// opportunity
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: create
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/opportunities/create-a-new-opportunity.html
|
||||
|
||||
const body: IDataObject = {
|
||||
name: this.getNodeParameter('name', i),
|
||||
customer_source_id: this.getNodeParameter('customerSourceId', i),
|
||||
primary_contact_id: this.getNodeParameter('primaryContactId', i),
|
||||
};
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'POST', '/opportunities', body);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: delete
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/opportunities/delete-an-opportunity.html
|
||||
|
||||
const opportunityId = this.getNodeParameter('opportunityId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'DELETE', `/opportunities/${opportunityId}`);
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/opportunities/fetch-an-opportunity-by-id.html
|
||||
|
||||
const opportunityId = this.getNodeParameter('opportunityId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'GET', `/opportunities/${opportunityId}`);
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/opportunities/list-opportunities-search.html
|
||||
|
||||
const body: IDataObject = {};
|
||||
const filterFields = this.getNodeParameter('filterFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(filterFields).length) {
|
||||
Object.assign(body, filterFields);
|
||||
}
|
||||
|
||||
responseData = await handleListing.call(this, 'POST', '/opportunities/search', body);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: update
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/opportunities/update-an-opportunity.html
|
||||
|
||||
const opportunityId = this.getNodeParameter('opportunityId', i);
|
||||
|
||||
const body: IDataObject = {};
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(updateFields).length) {
|
||||
Object.assign(body, updateFields);
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'PUT', `/opportunities/${opportunityId}`, body);
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'person') {
|
||||
|
||||
// **********************************************************************
|
||||
// person
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------------
|
||||
// person: create
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/people/create-a-new-person.html
|
||||
|
||||
const body: IDataObject = {
|
||||
name: this.getNodeParameter('name', i),
|
||||
};
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(additionalFields).length) {
|
||||
Object.assign(body, adjustPersonFields(additionalFields));
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'POST', '/people', body);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------------
|
||||
// person: delete
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/people/delete-a-person.html
|
||||
|
||||
const personId = this.getNodeParameter('personId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'DELETE', `/people/${personId}`);
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// person: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/people/fetch-a-person-by-id.html
|
||||
|
||||
const personId = this.getNodeParameter('personId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'GET', `/people/${personId}`);
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// person: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
const body: IDataObject = {};
|
||||
const filterFields = this.getNodeParameter('filterFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(filterFields).length) {
|
||||
Object.assign(body, filterFields);
|
||||
}
|
||||
|
||||
responseData = await handleListing.call(this, 'POST', '/people/search', body);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// person: update
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/people/update-a-person.html
|
||||
|
||||
const personId = this.getNodeParameter('personId', i);
|
||||
|
||||
const body: IDataObject = {};
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(updateFields).length) {
|
||||
Object.assign(body, adjustPersonFields(updateFields));
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'PUT', `/people/${personId}`, body);
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'project') {
|
||||
|
||||
// **********************************************************************
|
||||
// project
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------------
|
||||
// project: create
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/projects/create-a-new-project.html
|
||||
|
||||
const body: IDataObject = {
|
||||
name: this.getNodeParameter('name', i),
|
||||
};
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(additionalFields).length) {
|
||||
Object.assign(body, additionalFields);
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'POST', '/projects', body);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------------
|
||||
// project: delete
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/projects/delete-a-project.html
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'DELETE', `/projects/${projectId}`);
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// project: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/projects/fetch-a-project-by-id.html
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'GET', `/projects/${projectId}`);
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// project: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/projects/list-projects-search.html
|
||||
|
||||
const body: IDataObject = {};
|
||||
const filterFields = this.getNodeParameter('filterFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(filterFields).length) {
|
||||
Object.assign(body, filterFields);
|
||||
}
|
||||
|
||||
responseData = await handleListing.call(this, 'POST', '/projects/search', body);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// project: update
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/projects/update-a-project.html
|
||||
|
||||
const projectId = this.getNodeParameter('projectId', i);
|
||||
|
||||
const body: IDataObject = {};
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(updateFields).length) {
|
||||
Object.assign(body, updateFields);
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'PUT', `/projects/${projectId}`, body);
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'task') {
|
||||
|
||||
// **********************************************************************
|
||||
// task
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------------
|
||||
// task: create
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/tasks/create-a-new-task.html
|
||||
|
||||
const body: IDataObject = {
|
||||
name: this.getNodeParameter('name', i),
|
||||
};
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(additionalFields).length) {
|
||||
Object.assign(body, additionalFields);
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'POST', '/tasks', body);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------------
|
||||
// task: delete
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/tasks/delete-a-task.html
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'DELETE', `/tasks/${taskId}`);
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// task: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/tasks/fetch-a-task-by-id.html
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i);
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'GET', `/tasks/${taskId}`);
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// task: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/tasks/list-tasks-search.html
|
||||
|
||||
const body: IDataObject = {};
|
||||
const filterFields = this.getNodeParameter('filterFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(filterFields).length) {
|
||||
Object.assign(body, adjustTaskFields(filterFields));
|
||||
}
|
||||
|
||||
responseData = await handleListing.call(this, 'POST', '/tasks/search', body);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// task: update
|
||||
// ----------------------------------------
|
||||
|
||||
// https://developer.copper.com/tasks/update-a-task.html
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i);
|
||||
|
||||
const body: IDataObject = {};
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
if (Object.keys(updateFields).length) {
|
||||
Object.assign(body, updateFields);
|
||||
}
|
||||
|
||||
responseData = await copperApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body);
|
||||
}
|
||||
|
||||
} else if (resource === 'user') {
|
||||
|
||||
// **********************************************************************
|
||||
// user
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// user: getAll
|
||||
// ----------------------------------------
|
||||
|
||||
responseData = await handleListing.call(this, 'POST', '/users/search');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.toString() });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
Array.isArray(responseData)
|
||||
? returnData.push(...responseData)
|
||||
: returnData.push(responseData);
|
||||
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ export class CopperTrigger implements INodeType {
|
|||
description: INodeTypeDescription = {
|
||||
displayName: 'Copper Trigger',
|
||||
name: 'copperTrigger',
|
||||
icon: 'file:copper.png',
|
||||
icon: 'file:copper.svg',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
description: 'Handle Copper events via webhooks',
|
||||
|
@ -147,7 +147,7 @@ export class CopperTrigger implements INodeType {
|
|||
const endpoint = `/webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await copperApiRequest.call(this, 'DELETE', endpoint);
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
delete webhookData.webhookId;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
import { createHash } from 'crypto';
|
||||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
createHash,
|
||||
} from 'crypto';
|
||||
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
|
@ -8,16 +13,37 @@ import {
|
|||
ILoadOptionsFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function copperApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('copperApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
import {
|
||||
flow,
|
||||
omit,
|
||||
} from 'lodash';
|
||||
|
||||
import {
|
||||
AddressFixedCollection,
|
||||
EmailFixedCollection,
|
||||
EmailsFixedCollection,
|
||||
PhoneNumbersFixedCollection,
|
||||
} from './utils/types';
|
||||
|
||||
/**
|
||||
* Make an authenticated API request to Copper.
|
||||
*/
|
||||
export async function copperApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
qs: IDataObject = {},
|
||||
uri = '',
|
||||
option: IDataObject = {},
|
||||
) {
|
||||
const credentials = this.getCredentials('copperApi') as { apiKey: string, email: string };
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
|
@ -29,10 +55,16 @@ export async function copperApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: uri ||`https://api.prosperworks.com/developer_api/v1${resource}`,
|
||||
uri: uri || `https://api.prosperworks.com/developer_api/v1${resource}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
options = Object.assign({}, options, option);
|
||||
|
||||
if (!Object.keys(qs).length) {
|
||||
delete options.qs;
|
||||
}
|
||||
|
||||
if (Object.keys(options.body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
|
@ -41,11 +73,11 @@ export async function copperApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
let errorMessage = error.message;
|
||||
if (error.response.body && error.response.body.message) {
|
||||
if (error.response.body?.message) {
|
||||
errorMessage = error.response.body.message;
|
||||
}
|
||||
|
||||
throw new Error('Copper Error: ' + errorMessage);
|
||||
throw new Error(`Copper error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,3 +93,120 @@ export function getAutomaticSecret(credentials: ICredentialDataDecryptedObject)
|
|||
const data = `${credentials.email},${credentials.apiKey}`;
|
||||
return createHash('md5').update(data).digest('hex');
|
||||
}
|
||||
|
||||
export function adjustAddress(fixedCollection: AddressFixedCollection) {
|
||||
if (!fixedCollection.address) return fixedCollection;
|
||||
|
||||
const adjusted: { address?: object } = omit(fixedCollection, ['address']);
|
||||
|
||||
if (fixedCollection.address) {
|
||||
adjusted.address = fixedCollection.address.addressFields;
|
||||
}
|
||||
|
||||
return adjusted;
|
||||
}
|
||||
|
||||
export function adjustPhoneNumbers(fixedCollection: PhoneNumbersFixedCollection) {
|
||||
if (!fixedCollection.phone_numbers) return fixedCollection;
|
||||
|
||||
const adjusted: { phone_numbers?: object } = omit(fixedCollection, ['phone_numbers']);
|
||||
|
||||
if (fixedCollection.phone_numbers) {
|
||||
adjusted.phone_numbers = fixedCollection.phone_numbers.phoneFields;
|
||||
}
|
||||
|
||||
return adjusted;
|
||||
}
|
||||
|
||||
export function adjustEmails(fixedCollection: EmailsFixedCollection) {
|
||||
if (!fixedCollection.emails) return fixedCollection;
|
||||
|
||||
const adjusted: { emails?: object } = omit(fixedCollection, ['emails']);
|
||||
|
||||
if (fixedCollection.emails) {
|
||||
adjusted.emails = fixedCollection.emails.emailFields;
|
||||
}
|
||||
|
||||
return adjusted;
|
||||
}
|
||||
|
||||
export function adjustProjectIds(fields: { project_ids?: string }) {
|
||||
if (!fields.project_ids) return fields;
|
||||
|
||||
const adjusted: { project_ids?: string[] } = omit(fields, ['project_ids']);
|
||||
|
||||
adjusted.project_ids = fields.project_ids.includes(',')
|
||||
? fields.project_ids.split(',')
|
||||
: [fields.project_ids];
|
||||
|
||||
return adjusted;
|
||||
}
|
||||
|
||||
export function adjustEmail(fixedCollection: EmailFixedCollection) {
|
||||
if (!fixedCollection.email) return fixedCollection;
|
||||
|
||||
const adjusted: { email?: object } = omit(fixedCollection, ['email']);
|
||||
|
||||
if (fixedCollection.email) {
|
||||
adjusted.email = fixedCollection.email.emailFields;
|
||||
}
|
||||
|
||||
return adjusted;
|
||||
}
|
||||
|
||||
export const adjustCompanyFields = flow(adjustAddress, adjustPhoneNumbers);
|
||||
export const adjustLeadFields = flow(adjustCompanyFields, adjustEmail);
|
||||
export const adjustPersonFields = flow(adjustCompanyFields, adjustEmails);
|
||||
export const adjustTaskFields = flow(adjustLeadFields, adjustProjectIds);
|
||||
|
||||
/**
|
||||
* Handle a Copper listing by returning all items or up to a limit.
|
||||
*/
|
||||
export async function handleListing(
|
||||
this: IExecuteFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
qs: IDataObject = {},
|
||||
body: IDataObject = {},
|
||||
uri = '',
|
||||
) {
|
||||
let responseData;
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', 0);
|
||||
|
||||
const option = { resolveWithFullResponse: true };
|
||||
|
||||
if (returnAll) {
|
||||
return await copperApiRequestAllItems.call(this, method, endpoint, body, qs, uri, option);
|
||||
}
|
||||
|
||||
const limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await copperApiRequestAllItems.call(this, method, endpoint, body, qs, uri, option);
|
||||
return responseData.slice(0, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an authenticated API request to Copper and return all items.
|
||||
*/
|
||||
export async function copperApiRequestAllItems(
|
||||
this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
qs: IDataObject = {},
|
||||
uri = '',
|
||||
option: IDataObject = {},
|
||||
) {
|
||||
let responseData;
|
||||
qs.page_size = 200;
|
||||
let totalItems = 0;
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
do {
|
||||
responseData = await copperApiRequest.call(this, method, resource, body, qs, uri, option);
|
||||
totalItems = responseData.headers['x-pw-total'];
|
||||
returnData.push(...responseData.body);
|
||||
} while (totalItems > returnData.length);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
25
packages/nodes-base/nodes/Copper/copper.svg
Normal file
25
packages/nodes-base/nodes/Copper/copper.svg
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="364.000000pt" height="364.000000pt" viewBox="0 0 364.000000 364.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
|
||||
<g transform="translate(0.000000,364.000000) scale(0.100000,-0.100000)"
|
||||
fill="#ff2564" stroke="none">
|
||||
<path d="M1620 3625 c-215 -26 -398 -80 -585 -171 -386 -188 -678 -482 -856
|
||||
-859 -133 -284 -197 -628 -170 -912 15 -159 37 -268 90 -444 39 -128 167 -375
|
||||
264 -504 63 -85 246 -271 342 -347 116 -93 277 -184 460 -263 109 -47 348
|
||||
-100 519 -116 104 -10 162 -10 267 0 604 54 1107 362 1422 871 191 310 291
|
||||
723 258 1072 -13 148 -47 314 -91 447 -151 458 -507 859 -940 1058 -52 24
|
||||
-102 48 -110 52 -19 10 -198 65 -260 80 -204 48 -409 61 -610 36z m585 -783
|
||||
c160 -44 330 -143 420 -244 25 -29 66 -93 90 -143 95 -196 77 -380 -49 -506
|
||||
-70 -70 -106 -83 -226 -84 -92 0 -111 3 -153 24 -69 36 -139 114 -166 186 -34
|
||||
89 -31 174 10 316 65 224 39 339 -91 404 -42 22 -149 25 -202 6 -81 -27 -176
|
||||
-132 -234 -256 -66 -143 -101 -343 -91 -529 11 -220 63 -371 172 -507 154
|
||||
-190 412 -266 693 -203 117 26 232 88 345 187 55 48 72 58 92 53 14 -4 25 -12
|
||||
25 -19 0 -19 -85 -180 -137 -262 -117 -180 -302 -347 -468 -420 -167 -74 -397
|
||||
-99 -607 -65 -199 32 -403 136 -548 280 -294 295 -372 774 -191 1174 137 303
|
||||
433 538 776 616 119 27 427 22 540 -8z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,289 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
isoCountryCodes,
|
||||
} from '../utils/isoCountryCodes';
|
||||
|
||||
import {
|
||||
addressFixedCollection,
|
||||
phoneNumbersFixedCollection,
|
||||
} from '../utils/sharedFields';
|
||||
|
||||
export const companyOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const companyFields = [
|
||||
// ----------------------------------------
|
||||
// company: create
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
description: 'Name of the company to create.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description of the company to create.',
|
||||
},
|
||||
{
|
||||
displayName: 'Email Domain',
|
||||
name: 'email_domain',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
phoneNumbersFixedCollection,
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// company: delete
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Company ID',
|
||||
name: 'companyId',
|
||||
description: 'ID of the company to delete.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// company: get
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Company ID',
|
||||
name: 'companyId',
|
||||
description: 'ID of the company to retrieve.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// company: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filterFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Country',
|
||||
name: 'country',
|
||||
type: 'options',
|
||||
options: isoCountryCodes.map(({ name, alpha2 }) => ({ name, value: alpha2 })),
|
||||
default: '',
|
||||
description: 'Country of the company to filter by.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the company to filter by.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// company: update
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Company ID',
|
||||
name: 'companyId',
|
||||
description: 'ID of the company to update.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description to set for the company.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name to set for the company.',
|
||||
},
|
||||
phoneNumbersFixedCollection,
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
|
@ -0,0 +1,73 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const customerSourceOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'customerSource',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const customerSourceFields = [
|
||||
// ----------------------------------------
|
||||
// customerSource: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'customerSource',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'customerSource',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
] as INodeProperties[];
|
274
packages/nodes-base/nodes/Copper/descriptions/LeadDescription.ts
Normal file
274
packages/nodes-base/nodes/Copper/descriptions/LeadDescription.ts
Normal file
|
@ -0,0 +1,274 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
addressFixedCollection,
|
||||
emailFixedCollection,
|
||||
phoneNumbersFixedCollection,
|
||||
} from '../utils/sharedFields';
|
||||
|
||||
export const leadOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const leadFields = [
|
||||
// ----------------------------------------
|
||||
// lead: create
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
description: 'Name of the lead to create.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
emailFixedCollection,
|
||||
phoneNumbersFixedCollection,
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: delete
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Lead ID',
|
||||
name: 'leadId',
|
||||
description: 'ID of the lead to delete.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: get
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Lead ID',
|
||||
name: 'leadId',
|
||||
description: 'ID of the lead to retrieve.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filterFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Country',
|
||||
name: 'country',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the country to filter by.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the lead to filter by.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// lead: update
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Lead ID',
|
||||
name: 'leadId',
|
||||
description: 'ID of the lead to update.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'lead',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description to set for the lead.',
|
||||
},
|
||||
emailFixedCollection,
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name to set for the lead.',
|
||||
},
|
||||
phoneNumbersFixedCollection,
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
|
@ -0,0 +1,284 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const opportunityOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const opportunityFields = [
|
||||
// ----------------------------------------
|
||||
// opportunity: create
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
description: 'Name of the opportunity to create.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Customer Source ID',
|
||||
name: 'customerSourceId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the customer source that generated this opportunity.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Contact ID',
|
||||
name: 'primaryContactId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the primary company associated with this opportunity.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: delete
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Opportunity ID',
|
||||
name: 'opportunityId',
|
||||
description: 'ID of the opportunity to delete.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: get
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Opportunity ID',
|
||||
name: 'opportunityId',
|
||||
description: 'ID of the opportunity to retrieve.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filterFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Company IDs',
|
||||
name: 'company_ids',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated IDs of the primary companies to filter by.',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer Source IDs',
|
||||
name: 'customer_source_ids',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated IDs of the customer sources to filter by.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// opportunity: update
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Opportunity ID',
|
||||
name: 'opportunityId',
|
||||
description: 'ID of the opportunity to update.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'opportunity',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Customer Source ID',
|
||||
name: 'customer_source_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the primary company associated with this opportunity.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name to set for the opportunity.',
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Contact ID',
|
||||
name: 'primary_contact_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the customer source that generated this opportunity.',
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
|
@ -0,0 +1,286 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
addressFixedCollection,
|
||||
emailsFixedCollection,
|
||||
phoneNumbersFixedCollection,
|
||||
} from '../utils/sharedFields';
|
||||
|
||||
export const personOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const personFields = [
|
||||
// ----------------------------------------
|
||||
// person: create
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
description: 'Name of the person to create.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description to set for the person.',
|
||||
},
|
||||
{
|
||||
displayName: 'Email Domain',
|
||||
name: 'email_domain',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
emailsFixedCollection,
|
||||
phoneNumbersFixedCollection,
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// person: delete
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Person ID',
|
||||
name: 'personId',
|
||||
description: 'ID of the person to delete.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// person: get
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Person ID',
|
||||
name: 'personId',
|
||||
description: 'ID of the person to retrieve.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// person: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filterFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the person to filter by.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// person: update
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Person ID',
|
||||
name: 'personId',
|
||||
description: 'ID of the person to update.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'person',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description to set for the person.',
|
||||
},
|
||||
{
|
||||
displayName: 'Email Domain',
|
||||
name: 'email_domain',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
emailsFixedCollection,
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name to set for the person.',
|
||||
},
|
||||
phoneNumbersFixedCollection,
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
|
@ -0,0 +1,308 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const projectOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const projectFields = [
|
||||
// ----------------------------------------
|
||||
// project: create
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
description: 'Name of the project to create.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assignee ID',
|
||||
name: 'assignee_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the user who will own the project to create.',
|
||||
},
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description of the project to create.',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: 'Open',
|
||||
options: [
|
||||
{
|
||||
name: 'Completed',
|
||||
value: 'Completed',
|
||||
},
|
||||
{
|
||||
name: 'Open',
|
||||
value: 'Open',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// project: delete
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Project ID',
|
||||
name: 'projectId',
|
||||
description: 'ID of the project to delete.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// project: get
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Project ID',
|
||||
name: 'projectId',
|
||||
description: 'ID of the project to retrieve.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// project: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filterFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the project to filter by.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// project: update
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Project ID',
|
||||
name: 'projectId',
|
||||
description: 'ID of the project to update.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'project',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assignee ID',
|
||||
name: 'assignee_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the user who will own the project.',
|
||||
},
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description to set for the project.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name to set for the project.',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: 'Open',
|
||||
options: [
|
||||
{
|
||||
name: 'Completed',
|
||||
value: 'Completed',
|
||||
},
|
||||
{
|
||||
name: 'Open',
|
||||
value: 'Open',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
346
packages/nodes-base/nodes/Copper/descriptions/TaskDescription.ts
Normal file
346
packages/nodes-base/nodes/Copper/descriptions/TaskDescription.ts
Normal file
|
@ -0,0 +1,346 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const taskOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const taskFields = [
|
||||
// ----------------------------------------
|
||||
// task: create
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assignee ID',
|
||||
name: 'assignee_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the user who will own the task to create.',
|
||||
},
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description of the task to create.',
|
||||
},
|
||||
{
|
||||
displayName: 'Priority',
|
||||
name: 'priority',
|
||||
type: 'options',
|
||||
default: 'High',
|
||||
options: [
|
||||
{
|
||||
name: 'High',
|
||||
value: 'High',
|
||||
},
|
||||
{
|
||||
name: 'None',
|
||||
value: 'None',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: 'Open',
|
||||
options: [
|
||||
{
|
||||
name: 'Completed',
|
||||
value: 'Completed',
|
||||
},
|
||||
{
|
||||
name: 'Open',
|
||||
value: 'Open',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// task: delete
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
description: 'ID of the task to delete.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// task: get
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
description: 'ID of the task to retrieve.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// task: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filterFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assignee IDs',
|
||||
name: 'assignee_ids',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated IDs of assignee IDs to filter by.',
|
||||
},
|
||||
{
|
||||
displayName: 'Project IDs',
|
||||
name: 'project_ids',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated IDs of project IDs to filter by.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------------
|
||||
// task: update
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
description: 'ID of the task to update.',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assignee ID',
|
||||
name: 'assignee_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the user who will own the task.',
|
||||
},
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description to set for the task.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name to set for the task.',
|
||||
},
|
||||
{
|
||||
displayName: 'Priority',
|
||||
name: 'priority',
|
||||
type: 'options',
|
||||
default: 'High',
|
||||
options: [
|
||||
{
|
||||
name: 'High',
|
||||
value: 'High',
|
||||
},
|
||||
{
|
||||
name: 'None',
|
||||
value: 'None',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: 'Open',
|
||||
options: [
|
||||
{
|
||||
name: 'Completed',
|
||||
value: 'Completed',
|
||||
},
|
||||
{
|
||||
name: 'Open',
|
||||
value: 'Open',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
|
@ -0,0 +1,73 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const userOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
description: 'Operation to perform',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const userFields = [
|
||||
// ----------------------------------------
|
||||
// user: getAll
|
||||
// ----------------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return.',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
] as INodeProperties[];
|
8
packages/nodes-base/nodes/Copper/descriptions/index.ts
Normal file
8
packages/nodes-base/nodes/Copper/descriptions/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export * from './CompanyDescription';
|
||||
export * from './CustomerSourceDescription';
|
||||
export * from './LeadDescription';
|
||||
export * from './OpportunityDescription';
|
||||
export * from './PersonDescription';
|
||||
export * from './ProjectDescription';
|
||||
export * from './TaskDescription';
|
||||
export * from './UserDescription';
|
1000
packages/nodes-base/nodes/Copper/utils/isoCountryCodes.ts
Normal file
1000
packages/nodes-base/nodes/Copper/utils/isoCountryCodes.ts
Normal file
File diff suppressed because it is too large
Load diff
140
packages/nodes-base/nodes/Copper/utils/sharedFields.ts
Normal file
140
packages/nodes-base/nodes/Copper/utils/sharedFields.ts
Normal file
|
@ -0,0 +1,140 @@
|
|||
// for companies, leads, persons
|
||||
export const addressFixedCollection = {
|
||||
displayName: 'Address',
|
||||
name: 'address',
|
||||
placeholder: 'Add Address Fields',
|
||||
type: 'fixedCollection',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Address Fields',
|
||||
name: 'addressFields',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Street',
|
||||
name: 'street',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'City',
|
||||
name: 'city',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'State',
|
||||
name: 'state',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Postal Code',
|
||||
name: 'postal_code',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Country',
|
||||
name: 'country',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ISO 3166 alpha-2 country code.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// for companies, leads, persons
|
||||
export const phoneNumbersFixedCollection = {
|
||||
displayName: 'Phone Numbers',
|
||||
name: 'phone_numbers',
|
||||
placeholder: 'Add Phone Number',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Phone Fields',
|
||||
name: 'phoneFields',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'number',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Category',
|
||||
name: 'category',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// for persons, multiple emails
|
||||
export const emailsFixedCollection = {
|
||||
displayName: 'Emails',
|
||||
name: 'emails',
|
||||
placeholder: 'Add Email',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email Fields',
|
||||
name: 'emailFields',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Category',
|
||||
name: 'category',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// for leads, single email
|
||||
export const emailFixedCollection = {
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
placeholder: 'Add Email',
|
||||
type: 'fixedCollection',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email Fields',
|
||||
name: 'emailFields',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Category',
|
||||
name: 'category',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
23
packages/nodes-base/nodes/Copper/utils/types.d.ts
vendored
Normal file
23
packages/nodes-base/nodes/Copper/utils/types.d.ts
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
export type EmailFixedCollection = {
|
||||
email?: {
|
||||
emailFields: Array<{ email: string, category: string }>
|
||||
}
|
||||
};
|
||||
|
||||
export type EmailsFixedCollection = {
|
||||
emails?: {
|
||||
emailFields: Array<{ email: string, category: string }>
|
||||
}
|
||||
};
|
||||
|
||||
export type PhoneNumbersFixedCollection = {
|
||||
phone_numbers?: {
|
||||
phoneFields: object,
|
||||
}
|
||||
};
|
||||
|
||||
export type AddressFixedCollection = {
|
||||
address?: {
|
||||
addressFields: object
|
||||
}
|
||||
}
|
|
@ -315,6 +315,7 @@
|
|||
"dist/nodes/Contentful/Contentful.node.js",
|
||||
"dist/nodes/ConvertKit/ConvertKit.node.js",
|
||||
"dist/nodes/ConvertKit/ConvertKitTrigger.node.js",
|
||||
"dist/nodes/Copper/Copper.node.js",
|
||||
"dist/nodes/Copper/CopperTrigger.node.js",
|
||||
"dist/nodes/Cortex/Cortex.node.js",
|
||||
"dist/nodes/CrateDb/CrateDb.node.js",
|
||||
|
|
Loading…
Reference in a new issue