Initial refactor of Zoho node

This commit is contained in:
Iván Ovejero 2021-04-29 11:56:19 +02:00
parent 7f0f8deb6d
commit 878e2093db
15 changed files with 4708 additions and 398 deletions

View file

@ -59,6 +59,22 @@ export class ZohoOAuth2Api implements ICredentialType {
default: 'https://accounts.zoho.com/oauth/v2/token',
required: true,
},
{
displayName: 'Region',
name: 'region',
type: 'options' as NodePropertyTypes,
default: 'europe',
options: [
{
name: 'Europe',
value: 'europe',
},
{
name: 'United States',
value: 'unitedStates',
},
],
},
{
displayName: 'Scope',
name: 'scope',

View file

@ -1,50 +1,86 @@
import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
IExecuteSingleFunctions,
ILoadOptionsFunctions,
IHookFunctions,
} from 'n8n-core';
import {
IDataObject, NodeApiError
IDataObject,
NodeApiError,
NodeOperationError,
} from 'n8n-workflow';
export async function zohoApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
import {
OptionsWithUri,
} from 'request';
import {
flow,
} from 'lodash';
export async function zohoApiRequest(
this: IExecuteFunctions | IHookFunctions,
method: string,
endpoint: string,
body: IDataObject = {},
qs: IDataObject = {},
uri?: string,
) {
const operation = this.getNodeParameter('operation', 0) as string;
const { region } = this.getCredentials('zohoOAuth2Api') as { region: 'europe' | 'unitedStates' };
const tld = getTld(region);
const options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',
},
method,
body: {
data: [
body,
],
},
method,
qs,
uri: uri || `https://www.zohoapis.com/crm/v2${resource}`,
uri: uri ?? `https://www.zohoapis.${tld}/crm/v2${endpoint}`,
json: true,
};
if (!Object.keys(body).length) {
delete options.body;
}
if (!Object.keys(qs).length) {
delete options.qs;
}
try {
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'zohoOAuth2Api', options);
console.log(JSON.stringify(options.body.data, null, 2));
const responseData = await this.helpers.requestOAuth2.call(this, 'zohoOAuth2Api', options);
return operation === 'getAll' ? responseData : responseData.data;
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
export async function zohoApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
/**
* Make an authenticated API request to Zoho CRM API and return all items.
*/
export async function zohoApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions,
method: string,
endpoint: string,
body: IDataObject,
qs: IDataObject,
) {
const returnData: IDataObject[] = [];
let responseData;
let uri: string | undefined;
query.per_page = 200;
query.page = 0;
qs.per_page = 200;
qs.page = 0;
do {
responseData = await zohoApiRequest.call(this, method, endpoint, body, query, uri);
responseData = await zohoApiRequest.call(this, method, endpoint, body, qs, uri);
uri = responseData.info.more_records;
returnData.push.apply(returnData, responseData[propertyName]);
query.page++;
returnData.push.apply(returnData, responseData['data']);
qs.page++;
} while (
responseData.info.more_records !== undefined &&
responseData.info.more_records === true
@ -52,3 +88,78 @@ export async function zohoApiRequestAllItems(this: IExecuteFunctions | ILoadOpti
return returnData;
}
/**
* Handle a Zoho CRM API listing by returning all items or up to a limit.
*/
export async function handleListing(
this: IExecuteFunctions,
method: string,
endpoint: string,
body: IDataObject = {},
qs: IDataObject = {},
) {
let responseData;
const returnAll = this.getNodeParameter('returnAll', 0);
if (returnAll) {
return await zohoApiRequestAllItems.call(this, method, endpoint, body, qs);
}
const limit = this.getNodeParameter('limit', 0) as number;
responseData = await zohoApiRequestAllItems.call(this, method, endpoint, body, qs);
return responseData.slice(0, limit);
}
// ----------------------------------------
// field adjusters
// ----------------------------------------
/**
* Place a location field's contents at the top level of the payload.
*/
const adjustLocationFields = (locationType: LocationType) => (allFields: IDataObject) => {
const locationField = allFields[locationType];
if (!locationField || !hasAddressFields(locationField)) return allFields;
return { ...omit(locationType, allFields), ...locationField.address_fields };
};
const adjustAddressFields = adjustLocationFields('Address');
const adjustBillingAddressFields = adjustLocationFields('Billing_Address');
const adjustMailingAddressFields = adjustLocationFields('Mailing_Address');
const adjustShippingAddressFields = adjustLocationFields('Shipping_Address');
const adjustOtherAddressFields = adjustLocationFields('Other_Address');
export const adjustAccountFields = flow(adjustBillingAddressFields, adjustShippingAddressFields);
export const adjustContactFields = flow(adjustMailingAddressFields, adjustOtherAddressFields);
export const adjustInvoiceFields = flow(adjustBillingAddressFields, adjustShippingAddressFields); // TODO: product details
export const adjustLeadFields = adjustAddressFields;
export const adjustPurchaseOrderFields = adjustInvoiceFields;
export const adjustQuoteFields = adjustInvoiceFields;
export const adjustSalesOrderFields = adjustInvoiceFields;
// ----------------------------------------
// helpers
// ----------------------------------------
export const omit = (keyToOmit: string, { [keyToOmit]: _, ...omittedPropObj }) => omittedPropObj;
function hasAddressFields(locationField: unknown): locationField is LocationField {
if (typeof locationField !== 'object' || locationField === null) return false;
return locationField.hasOwnProperty('address_fields');
}
const getTld = (region: 'europe' | 'unitedStates') =>
({ europe: 'eu', unitedStates: 'com' }[region]);
// ----------------------------------------
// types
// ----------------------------------------
type LocationType = 'Address' | 'Billing_Address' | 'Mailing_Address' | 'Shipping_Address' | 'Other_Address';
type LocationField = {
address_fields: { [key in LocationType]: string };
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,366 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
billingAddress,
makeGetAllFields,
shippingAddress,
} from './SharedFields';
export const accountOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'account',
],
},
},
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 accountFields = [
// ----------------------------------------
// account: create
// ----------------------------------------
{
displayName: 'Account Name',
name: 'accountName',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'account',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'account',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Account Number',
name: 'Account_Number',
type: 'string',
default: '',
},
{
displayName: 'Account Site',
name: 'Account_Site',
type: 'string',
default: '',
description: 'Name of the accounts location, e.g. Headquarters or London.',
},
{
displayName: 'Account Type',
name: 'Account_Type',
type: 'string',
default: '',
},
{
displayName: 'Annual Revenue',
name: 'Annual_Revenue',
type: 'string',
default: '',
},
billingAddress,
{
displayName: 'Contact Details',
name: 'Contact_Details',
type: 'string',
default: '',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Employees',
name: 'Employees',
type: 'number',
default: '',
description: 'Number of employees in the accounts company.',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Fax',
name: 'Fax',
type: 'string',
default: '',
},
{
displayName: 'Industry',
name: 'Industry',
type: 'string',
default: '',
},
{
displayName: 'Phone',
name: 'Phone',
type: 'string',
default: '',
},
shippingAddress,
{
displayName: 'Ticker Symbol',
name: 'Ticker_Symbol',
type: 'string',
default: '',
},
{
displayName: 'Website',
name: 'Website',
type: 'string',
default: '',
},
],
},
// ----------------------------------------
// account: delete
// ----------------------------------------
{
displayName: 'Account ID',
name: 'accountId',
description: 'ID of the account to delete.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'account',
],
operation: [
'delete',
],
},
},
},
// ----------------------------------------
// account: get
// ----------------------------------------
{
displayName: 'Account ID',
name: 'accountId',
description: 'ID of the account to retrieve.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'account',
],
operation: [
'get',
],
},
},
},
// ----------------------------------------
// account: getAll
// ----------------------------------------
...makeGetAllFields('account'),
// ----------------------------------------
// account: update
// ----------------------------------------
{
displayName: 'Account ID',
name: 'accountId',
description: 'ID of the account to update.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'account',
],
operation: [
'update',
],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'account',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Account Name',
name: 'Account_Name',
type: 'string',
default: '',
},
{
displayName: 'Account Number',
name: 'Account_Number',
type: 'string',
default: '',
},
{
displayName: 'Account Site',
name: 'Account_Site',
type: 'string',
default: '',
description: 'Name of the accounts location, e.g. Headquarters or London.',
},
{
displayName: 'Account Type',
name: 'Account_Type',
type: 'string',
default: '',
},
{
displayName: 'Annual Revenue',
name: 'Annual_Revenue',
type: 'string',
default: '',
},
billingAddress,
{
displayName: 'Contact Details',
name: 'Contact_Details',
type: 'string',
default: '',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Employees',
name: 'Employees',
type: 'number',
default: '',
description: 'Number of employees in the accounts company.',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Fax',
name: 'Fax',
type: 'string',
default: '',
},
{
displayName: 'Industry',
name: 'Industry',
type: 'string',
default: '',
},
{
displayName: 'Phone',
name: 'Phone',
type: 'string',
default: '',
},
shippingAddress,
{
displayName: 'Ticker Symbol',
name: 'Ticker_Symbol',
type: 'string',
default: '',
},
{
displayName: 'Website',
name: 'Website',
type: 'string',
default: '',
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,426 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
mailingAddress,
makeGetAllFields,
otherAddress,
} from './SharedFields';
export const contactOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'contact',
],
},
},
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 contactFields = [
// ----------------------------------------
// contact: create
// ----------------------------------------
{
displayName: 'Last Name',
name: 'lastName',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Assistant',
name: 'Assistant',
type: 'string',
default: '',
description: 'Name of the contacts assistant.',
},
{
displayName: 'Assistants Phone',
name: 'Asst_Phone',
type: 'string',
default: '',
description: 'Phone number of the contacts assistant.',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Date of Birth',
name: 'Date_of_Birth',
type: 'string',
default: '',
},
{
displayName: 'Department',
name: 'Department',
type: 'string',
default: '',
description: 'Company department to which the contact belongs.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Email',
name: 'Email',
type: 'string',
default: '',
},
{
displayName: 'Fax',
name: 'Fax',
type: 'string',
default: '',
},
{
displayName: 'First Name',
name: 'First_Name',
type: 'string',
default: '',
},
{
displayName: 'Full Name',
name: 'Full_Name',
type: 'string',
default: '',
},
{
displayName: 'Home Phone',
name: 'Home_Phone',
type: 'string',
default: '',
},
mailingAddress,
{
displayName: 'Mobile',
name: 'Mobile',
type: 'string',
default: '',
},
otherAddress,
{
displayName: 'Other Phone',
name: 'Other_Phone',
type: 'string',
default: '',
},
{
displayName: 'Phone',
name: 'Phone',
type: 'string',
default: '',
},
{
displayName: 'Salutation',
name: 'Salutation',
type: 'string',
default: '',
},
{
displayName: 'Secondary Email',
name: 'Secondary_Email',
type: 'string',
default: '',
},
{
displayName: 'Skype ID',
name: 'Skype_ID',
type: 'string',
default: '',
},
{
displayName: 'Title',
name: 'Title',
type: 'string',
default: '',
description: 'Position of the contact at their company.',
},
{
displayName: 'Twitter',
name: 'Twitter',
type: 'string',
default: '',
},
],
},
// ----------------------------------------
// contact: delete
// ----------------------------------------
{
displayName: 'Contact ID',
name: 'contactId',
description: 'ID of the contact to delete.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'delete',
],
},
},
},
// ----------------------------------------
// contact: get
// ----------------------------------------
{
displayName: 'Contact ID',
name: 'contactId',
description: 'ID of the contact to retrieve.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'get',
],
},
},
},
// ----------------------------------------
// contact: getAll
// ----------------------------------------
...makeGetAllFields('contact'),
// ----------------------------------------
// contact: update
// ----------------------------------------
{
displayName: 'Contact ID',
name: 'contactId',
description: 'ID of the contact to update.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'update',
],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Assistant',
name: 'Assistant',
type: 'string',
default: '',
},
{
displayName: 'Assistants Phone',
name: 'Asst_Phone',
type: 'string',
default: '',
description: 'Phone number of the contacts assistant.',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Date of Birth',
name: 'Date_of_Birth',
type: 'string',
default: '',
},
{
displayName: 'Department',
name: 'Department',
type: 'string',
default: '',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Email',
name: 'Email',
type: 'string',
default: '',
},
{
displayName: 'Fax',
name: 'Fax',
type: 'string',
default: '',
},
{
displayName: 'First Name',
name: 'First_Name',
type: 'string',
default: '',
},
{
displayName: 'Full Name',
name: 'Full_Name',
type: 'string',
default: '',
},
{
displayName: 'Home Phone',
name: 'Home_Phone',
type: 'string',
default: '',
},
{
displayName: 'Last Name',
name: 'Last_Name',
type: 'string',
default: '',
},
mailingAddress,
{
displayName: 'Mobile',
name: 'Mobile',
type: 'string',
default: '',
},
otherAddress,
{
displayName: 'Other Phone',
name: 'Other_Phone',
type: 'string',
default: '',
},
{
displayName: 'Phone',
name: 'Phone',
type: 'string',
default: '',
},
{
displayName: 'Salutation',
name: 'Salutation',
type: 'string',
default: '',
},
{
displayName: 'Secondary Email',
name: 'Secondary_Email',
type: 'string',
default: '',
},
{
displayName: 'Skype ID',
name: 'Skype_ID',
type: 'string',
default: '',
},
{
displayName: 'Title',
name: 'Title',
type: 'string',
default: '',
description: 'Position of the contact at their company.',
},
{
displayName: 'Twitter',
name: 'Twitter',
type: 'string',
default: '',
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,329 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
makeGetAllFields,
} from './SharedFields';
export const dealOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'deal',
],
},
},
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 dealFields = [
// ----------------------------------------
// deal: create
// ----------------------------------------
{
displayName: 'Deal Name',
name: 'dealName',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'deal',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Stage',
name: 'stage',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'deal',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'deal',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Amount',
name: 'Amount',
type: 'number',
default: '',
description: 'Monetary amount of the deal.',
},
{
displayName: 'Closing Date',
name: 'Closing_Date',
type: 'string',
default: '',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Lead Conversion Time',
name: 'Lead_Conversion_Time',
type: 'number',
default: '',
description: 'Averge number of days to convert the lead into a deal.',
},
{
displayName: 'Next Step',
name: 'Next_Step',
type: 'string',
default: '',
description: 'Description of the next step in the sales process.',
},
{
displayName: 'Overall Sales Duration',
name: 'Overall_Sales_Duration',
type: 'number',
default: '',
description: 'Averge number of days to convert the lead into a deal and to win the deal.',
},
{
displayName: 'Probability',
name: 'Probability',
type: 'string',
default: '',
description: 'Probability of deal closure.',
},
{
displayName: 'Sales Cycle Duration',
name: 'Sales_Cycle_Duration',
type: 'string',
default: '',
description: 'Averge number of days for the deal to be won.',
},
],
},
// ----------------------------------------
// deal: delete
// ----------------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
description: 'ID of the deal to delete.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'deal',
],
operation: [
'delete',
],
},
},
},
// ----------------------------------------
// deal: get
// ----------------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
description: 'ID of the deal to retrieve.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'deal',
],
operation: [
'get',
],
},
},
},
// ----------------------------------------
// deal: getAll
// ----------------------------------------
...makeGetAllFields('deal'),
// ----------------------------------------
// deal: update
// ----------------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
description: 'ID of the deal to update.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'deal',
],
operation: [
'update',
],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'deal',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Amount',
name: 'Amount',
type: 'number',
default: '',
description: 'Monetary amount of the deal.',
},
{
displayName: 'Closing Date',
name: 'Closing_Date',
type: 'string',
default: '',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Deal Name',
name: 'Deal_Name',
type: 'string',
default: '',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Lead Conversion Time',
name: 'Lead_Conversion_Time',
type: 'number',
default: '',
description: 'Averge number of days to convert the lead into a deal.',
},
{
displayName: 'Next Step',
name: 'Next_Step',
type: 'string',
default: '',
description: 'Description of the next step in the sales process.',
},
{
displayName: 'Overall Sales Duration',
name: 'Overall_Sales_Duration',
type: 'number',
default: '',
description: 'Averge number of days to convert the lead into a deal and to win the deal.',
},
{
displayName: 'Probability',
name: 'Probability',
type: 'string',
default: '',
description: 'Probability of deal closure.',
},
{
displayName: 'Sales Cycle Duration',
name: 'Sales_Cycle_Duration',
type: 'string',
default: '',
description: 'Averge number of days to win the deal.',
},
{
displayName: 'Stage',
name: 'Stage',
type: 'string',
default: '',
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,425 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
billingAddress,
makeGetAllFields,
productDetails,
shippingAddress,
} from './SharedFields';
export const invoiceOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'invoice',
],
},
},
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 invoiceFields = [
// ----------------------------------------
// invoice: create
// ----------------------------------------
{
displayName: 'Product Details',
name: 'productDetails',
type: '',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Subject',
name: 'subject',
description: 'Subject or title of the invoice.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Account Name',
name: 'Account_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Account Name Field',
options: [
{
displayName: 'Account Name Fields',
name: 'account_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
billingAddress,
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Due Date',
name: 'Due_Date',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
{
displayName: 'Invoice Date',
name: 'Invoice_Date',
type: 'string',
default: '',
},
{
displayName: 'Invoice Number',
name: 'Invoice_Number',
type: 'string',
default: '',
},
{
displayName: 'Sales Commission',
name: 'Sales_Commission',
type: 'string',
default: '',
description: 'Commission of sales person on deal closure.',
},
shippingAddress,
{
displayName: 'Status',
name: 'Status',
type: 'string',
default: '',
},
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Tax amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the invoice.',
},
],
},
// ----------------------------------------
// invoice: delete
// ----------------------------------------
{
displayName: 'Invoice ID',
name: 'invoiceId',
description: 'ID of the invoice to delete.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'delete',
],
},
},
},
// ----------------------------------------
// invoice: get
// ----------------------------------------
{
displayName: 'Invoice ID',
name: 'invoiceId',
description: 'ID of the invoice to retrieve.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'get',
],
},
},
},
// ----------------------------------------
// invoice: getAll
// ----------------------------------------
...makeGetAllFields('invoice'),
// ----------------------------------------
// invoice: update
// ----------------------------------------
{
displayName: 'Invoice ID',
name: 'invoiceId',
description: 'ID of the invoice to update.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'update',
],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'invoice',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Account Name',
name: 'Account_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Account Name Field',
options: [
{
displayName: 'Account Name Fields',
name: 'account_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
billingAddress,
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Due Date',
name: 'Due_Date',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
{
displayName: 'Invoice Date',
name: 'Invoice_Date',
type: 'string',
default: '',
},
{
displayName: 'Invoice Number',
name: 'Invoice_Number',
type: 'string',
default: '',
},
productDetails,
{
displayName: 'Sales Commission',
name: 'Sales_Commission',
type: 'string',
default: '',
description: 'Commission of sales person on deal closure.',
},
shippingAddress,
{
displayName: 'Status',
name: 'Status',
type: 'string',
default: '',
},
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Subject',
name: 'Subject',
type: 'string',
default: '',
description: 'Subject or title of the invoice.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Tax amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the invoice.',
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,466 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
address,
makeGetAllFields,
} from './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: 'Company',
name: 'Company',
description: 'Company at which the lead works.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'lead',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Last Name',
name: 'Last_Name',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'lead',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'lead',
],
operation: [
'create',
],
},
},
options: [
address,
{
displayName: 'Annual Revenue',
name: 'Annual_Revenue',
type: 'number',
default: '',
description: 'Annual revenue of the leads company.',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Designation',
name: 'Designation',
type: 'string',
default: '',
description: 'Position of the lead at their company.',
},
{
displayName: 'Email',
name: 'Email',
type: 'string',
default: '',
},
{
displayName: 'Fax',
name: 'Fax',
type: 'string',
default: '',
},
{
displayName: 'First Name',
name: 'First_Name',
type: 'string',
default: '',
},
{
displayName: 'Full Name',
name: 'Full_Name',
type: 'string',
default: '',
},
{
displayName: 'Industry',
name: 'Industry',
type: 'string',
default: '',
description: 'Industry to which the lead belongs.',
},
{
displayName: 'Industry Type',
name: 'Industry_Type',
type: 'string',
default: '',
description: 'Type of industry to which the lead belongs.',
},
{
displayName: 'Lead Source',
name: 'Lead_Source',
type: 'string',
default: '',
description: 'Source from which the lead was created.',
},
{
displayName: 'Lead Status',
name: 'Lead_Status',
type: 'string',
default: '',
},
{
displayName: 'Mobile',
name: 'Mobile',
type: 'string',
default: '',
},
{
displayName: 'Number of Employees',
name: 'No_of_Employees',
type: 'number',
default: '',
description: 'Number of employees in the leads company.',
},
{
displayName: 'Phone',
name: 'Phone',
type: 'string',
default: '',
},
{
displayName: 'Salutation',
name: 'Salutation',
type: 'string',
default: '',
},
{
displayName: 'Secondary Email',
name: 'Secondary_Email',
type: 'string',
default: '',
},
{
displayName: 'Skype ID',
name: 'Skype_ID',
type: 'string',
default: '',
},
{
displayName: 'Twitter',
name: 'Twitter',
type: 'string',
default: '',
},
{
displayName: 'Website',
name: 'Website',
type: 'string',
default: '',
},
],
},
// ----------------------------------------
// 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
// ----------------------------------------
...makeGetAllFields('lead'),
// ----------------------------------------
// 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: [
address,
{
displayName: 'Annual Revenue',
name: 'Annual_Revenue',
type: 'number',
default: '',
description: 'Annual revenue of the leads company.',
},
{
displayName: 'Company',
name: 'Company',
type: 'string',
default: '',
description: 'Company at which the lead works.',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Designation',
name: 'Designation',
type: 'string',
default: '',
description: 'Position of the lead at their company.',
},
{
displayName: 'Email',
name: 'Email',
type: 'string',
default: '',
},
{
displayName: 'Fax',
name: 'Fax',
type: 'string',
default: '',
},
{
displayName: 'First Name',
name: 'First_Name',
type: 'string',
default: '',
},
{
displayName: 'Full Name',
name: 'Full_Name',
type: 'string',
default: '',
},
{
displayName: 'Industry',
name: 'Industry',
type: 'string',
default: '',
description: 'Industry to which the lead belongs.',
},
{
displayName: 'Industry Type',
name: 'Industry_Type',
type: 'string',
default: '',
description: 'Type of industry to which the lead belongs.',
},
{
displayName: 'Last Name',
name: 'Last_Name',
type: 'string',
default: '',
},
{
displayName: 'Lead Source',
name: 'Lead_Source',
type: 'string',
default: '',
description: 'Source from which the lead was created.',
},
{
displayName: 'Lead Status',
name: 'Lead_Status',
type: 'string',
default: '',
},
{
displayName: 'Mobile',
name: 'Mobile',
type: 'string',
default: '',
},
{
displayName: 'Number of Employees',
name: 'No_of_Employees',
type: 'number',
default: '',
description: 'Number of employees in the leads company.',
},
{
displayName: 'Phone',
name: 'Phone',
type: 'string',
default: '',
},
{
displayName: 'Salutation',
name: 'Salutation',
type: 'string',
default: '',
},
{
displayName: 'Secondary Email',
name: 'Secondary_Email',
type: 'string',
default: '',
},
{
displayName: 'Skype ID',
name: 'Skype_ID',
type: 'string',
default: '',
},
{
displayName: 'Twitter',
name: 'Twitter',
type: 'string',
default: '',
},
{
displayName: 'Website',
name: 'Website',
type: 'string',
default: '',
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,499 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
billingAddress,
makeGetAllFields,
productDetails,
shippingAddress,
} from './SharedFields';
export const purchaseOrderOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
},
},
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 purchaseOrderFields = [
// ----------------------------------------
// purchaseOrder: create
// ----------------------------------------
{
displayName: 'Subject',
name: 'subject',
description: 'Subject or title of the purchase order.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Vendor Name',
name: 'vendorName',
type: '',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
{
displayName: 'Billing Address',
name: 'Billing_Address',
type: 'fixedCollection',
default: {},
placeholder: 'Add Billing Address Field',
options: [
{
displayName: 'Billing Address Fields',
name: 'billing_address_fields',
values: [
{
displayName: 'Billing City',
name: 'Billing_City',
type: 'string',
default: '',
},
{
displayName: 'Billing Code',
name: 'Billing_Code',
type: 'string',
default: '',
},
{
displayName: 'Billing Country',
name: 'Billing_Country',
type: 'string',
default: '',
},
{
displayName: 'Billing State',
name: 'Billing_State',
type: 'string',
default: '',
},
{
displayName: 'Billing Street',
name: 'Billing_Street',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Carrier',
name: 'Carrier',
type: 'string',
default: '',
description: 'Name of the carrier.',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Discount',
name: 'Discount',
type: 'number',
default: '',
},
{
displayName: 'Due Date',
name: 'Due_Date',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
{
displayName: 'PO Date',
name: 'PO_Date',
type: 'string',
default: '',
description: 'Date on which the purchase order was issued.',
},
{
displayName: 'PO Number',
name: 'PO_Number',
type: 'string',
default: '',
description: 'ID of the purchase order after creating a case.',
},
productDetails,
{
displayName: 'Sales Commission',
name: 'Sales_Commission',
type: 'string',
default: '',
description: 'Commission of sales person on deal closure.',
},
shippingAddress,
{
displayName: 'Status',
name: 'Status',
type: 'string',
default: '',
description: 'Status of the purchase order.',
},
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Tax amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the purchase order.',
},
{
displayName: 'Tracking Number',
name: 'Tracking_Number',
type: 'string',
default: '',
},
],
},
// ----------------------------------------
// purchaseOrder: delete
// ----------------------------------------
{
displayName: 'Purchase Order ID',
name: 'purchaseOrderId',
description: 'ID of the purchase order to delete.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
operation: [
'delete',
],
},
},
},
// ----------------------------------------
// purchaseOrder: get
// ----------------------------------------
{
displayName: 'Purchase Order ID',
name: 'purchaseOrderId',
description: 'ID of the purchase order to retrieve.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
operation: [
'get',
],
},
},
},
// ----------------------------------------
// purchaseOrder: getAll
// ----------------------------------------
...makeGetAllFields('purchaseOrder'),
// ----------------------------------------
// purchaseOrder: update
// ----------------------------------------
{
displayName: 'Purchase Order ID',
name: 'purchaseOrderId',
description: 'ID of the purchase order to update.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
operation: [
'update',
],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'purchaseOrder',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
billingAddress,
{
displayName: 'Carrier',
name: 'Carrier',
type: 'string',
default: '',
description: 'Name of the carrier.',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Discount',
name: 'Discount',
type: 'number',
default: '',
},
{
displayName: 'Due Date',
name: 'Due_Date',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
{
displayName: 'PO Date',
name: 'PO_Date',
type: 'string',
default: '',
description: 'Date on which the purchase order was issued.',
},
{
displayName: 'PO Number',
name: 'PO_Number',
type: 'string',
default: '',
description: 'ID of the purchase order after creating a case.',
},
productDetails,
{
displayName: 'Sales Commission',
name: 'Sales_Commission',
type: 'string',
default: '',
description: 'Commission of sales person on deal closure.',
},
shippingAddress,
{
displayName: 'Status',
name: 'Status',
type: 'string',
default: '',
description: 'Status of the purchase order.',
},
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Subject',
name: 'Subject',
type: 'string',
default: '',
description: 'Subject or title of the purchase order.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Tax amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the purchase order.',
},
{
displayName: 'Tracking Number',
name: 'Tracking_Number',
type: 'string',
default: '',
},
{
displayName: 'Vendor Name',
name: 'Vendor_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Vendor Name Field',
options: [
{
displayName: 'Vendor Name Fields',
name: 'vendor_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
],
},
],
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,373 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
billingAddress,
makeGetAllFields,
productDetails,
shippingAddress,
} from './SharedFields';
export const quoteOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'quote',
],
},
},
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 quoteFields = [
// ----------------------------------------
// quote: create
// ----------------------------------------
{
displayName: 'Product Details',
name: 'productDetails',
type: '',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'quote',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Subject',
name: 'subject',
description: 'Subject or title of the quote.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'quote',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'quote',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
billingAddress,
{
displayName: 'Carrier',
name: 'Carrier',
type: 'string',
default: '',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
{
displayName: 'Quote Stage',
name: 'Quote_Stage',
type: 'string',
default: '',
},
shippingAddress,
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Total amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Team',
name: 'Team',
type: 'string',
default: '',
description: 'Team for whom the quote is created.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the quote.',
},
{
displayName: 'Valid Till',
name: 'Valid_Till',
type: 'string',
default: '',
description: 'Date until when the quote is valid.',
},
],
},
// ----------------------------------------
// quote: delete
// ----------------------------------------
{
displayName: 'Quote ID',
name: 'quoteId',
description: 'ID of the quote to delete.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'quote',
],
operation: [
'delete',
],
},
},
},
// ----------------------------------------
// quote: get
// ----------------------------------------
{
displayName: 'Quote ID',
name: 'quoteId',
description: 'ID of the quote to retrieve.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'quote',
],
operation: [
'get',
],
},
},
},
// ----------------------------------------
// quote: getAll
// ----------------------------------------
...makeGetAllFields('quote'),
// ----------------------------------------
// quote: update
// ----------------------------------------
{
displayName: 'Quote ID',
name: 'quoteId',
description: 'ID of the quote to update.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'quote',
],
operation: [
'update',
],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'quote',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
billingAddress,
{
displayName: 'Carrier',
name: 'Carrier',
type: 'string',
default: '',
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
productDetails,
{
displayName: 'Quote Stage',
name: 'Quote_Stage',
type: 'string',
default: '',
},
shippingAddress,
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Subject',
name: 'Subject',
type: 'string',
default: '',
description: 'Subject or title of the quote.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Tax amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Team',
name: 'Team',
type: 'string',
default: '',
description: 'Team for whom the quote is created.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the quote.',
},
{
displayName: 'Valid Till',
name: 'Valid_Till',
type: 'string',
default: '',
description: 'Date until when the quote is valid.',
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,549 @@
import {
INodeProperties,
} from 'n8n-workflow';
import {
billingAddress,
makeGetAllFields,
productDetails,
shippingAddress,
} from './SharedFields';
export const salesOrderOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'salesOrder',
],
},
},
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 salesOrderFields = [
// ----------------------------------------
// salesOrder: create
// ----------------------------------------
{
displayName: 'Account Name',
name: 'accountName',
type: '',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'salesOrder',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Subject',
name: 'subject',
description: 'Subject or title of the sales order.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'salesOrder',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'salesOrder',
],
operation: [
'create',
],
},
},
options: [
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
billingAddress,
{
displayName: 'Carrier',
name: 'Carrier',
type: 'string',
default: '',
description: 'Name of the carrier.',
},
{
displayName: 'Contact Name',
name: 'Contact_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Contact Name Field',
options: [
{
displayName: 'Contact Name Fields',
name: 'contact_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Deal Name',
name: 'Deal_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Deal Name Field',
options: [
{
displayName: 'Deal Name Fields',
name: 'deal_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Discount',
name: 'Discount',
type: 'number',
default: '',
},
{
displayName: 'Due Date',
name: 'Due_Date',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
productDetails,
{
displayName: 'Purchase Order',
name: 'Purchase_Order',
type: 'string',
default: '',
},
{
displayName: 'SO Number',
name: 'SO_Number',
type: 'string',
default: '',
description: 'ID of the sales order after creating a case.',
},
{
displayName: 'Sales Commission',
name: 'Sales_Commission',
type: 'string',
default: '',
description: 'Commission of sales person on deal closure.',
},
shippingAddress,
{
displayName: 'Status',
name: 'Status',
type: 'string',
default: '',
description: 'Status of the sales order.',
},
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Tax amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the purchase order.',
},
],
},
// ----------------------------------------
// salesOrder: delete
// ----------------------------------------
{
displayName: 'Sales Order ID',
name: 'salesOrderId',
description: 'ID of the sales order to delete.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'salesOrder',
],
operation: [
'delete',
],
},
},
},
// ----------------------------------------
// salesOrder: get
// ----------------------------------------
{
displayName: 'salesOrder ID',
name: 'salesOrderId',
description: 'ID of the sales order to retrieve.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'salesOrder',
],
operation: [
'get',
],
},
},
},
// ----------------------------------------
// salesOrder: getAll
// ----------------------------------------
...makeGetAllFields('salesOrder'),
// ----------------------------------------
// salesOrder: update
// ----------------------------------------
{
displayName: 'Sales Order ID',
name: 'salesOrderId',
description: 'ID of the sales order to update.',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'salesOrder',
],
operation: [
'update',
],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'salesOrder',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Account Name',
name: 'Account_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Account Name Field',
options: [
{
displayName: 'Account Name Fields',
name: 'account_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Adjustment',
name: 'Adjustment',
type: 'number',
default: '',
description: 'Adjustment in the grand total, if any.',
},
billingAddress,
{
displayName: 'Carrier',
name: 'Carrier',
type: 'string',
default: '',
description: 'Name of the carrier.',
},
{
displayName: 'Contact Name',
name: 'Contact_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Contact Name Field',
options: [
{
displayName: 'Contact Name Fields',
name: 'contact_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Currency',
name: 'Currency',
type: 'string',
default: '',
description: 'Symbol of the currency in which revenue is generated.',
},
{
displayName: 'Deal Name',
name: 'Deal_Name',
type: 'fixedCollection',
default: {},
placeholder: 'Add Deal Name Field',
options: [
{
displayName: 'Deal Name Fields',
name: 'deal_name_fields',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Description',
name: 'Description',
type: 'string',
default: '',
},
{
displayName: 'Discount',
name: 'Discount',
type: 'number',
default: '',
},
{
displayName: 'Due Date',
name: 'Due_Date',
type: 'string',
default: '',
},
{
displayName: 'Exchange Rate',
name: 'Exchange_Rate',
type: 'string',
default: '',
description: 'Exchange rate of the default currency to the home currency.',
},
{
displayName: 'Grand Total',
name: 'Grand_Total',
type: 'number',
default: '',
description: 'Total amount for the product after deducting tax and discounts.',
},
productDetails,
{
displayName: 'Purchase Order',
name: 'Purchase_Order',
type: 'string',
default: '',
},
{
displayName: 'SO Number',
name: 'SO_Number',
type: 'string',
default: '',
description: 'ID of the sales order after creating a case.',
},
{
displayName: 'Sales Commission',
name: 'Sales_Commission',
type: 'string',
default: '',
description: 'Commission of sales person on deal closure.',
},
shippingAddress,
{
displayName: 'Status',
name: 'Status',
type: 'string',
default: '',
description: 'Status of the sales order.',
},
{
displayName: 'Sub Total',
name: 'Sub_Total',
type: 'number',
default: '',
description: 'Total amount for the product excluding tax.',
},
{
displayName: 'Subject',
name: 'Subject',
type: 'string',
default: '',
description: 'Subject or title of the sales order.',
},
{
displayName: 'Tax',
name: 'Tax',
type: 'number',
default: '',
description: 'Tax amount as the sum of sales tax and value-added tax.',
},
{
displayName: 'Terms and Conditions',
name: 'Terms_and_Conditions',
type: 'string',
default: '',
description: 'Terms and conditions associated with the purchase order.',
},
],
},
] as INodeProperties[];

View file

@ -0,0 +1,381 @@
export const billingAddress = {
displayName: 'Billing Address',
name: 'Billing_Address',
type: 'fixedCollection',
default: {},
placeholder: 'Add Billing Address Field',
options: [
{
displayName: 'Billing Address Fields',
name: 'address_fields',
values: [
{
displayName: 'Billing City',
name: 'Billing_City',
type: 'string',
default: '',
},
{
displayName: 'Billing Code',
name: 'Billing_Code',
type: 'string',
default: '',
},
{
displayName: 'Billing Country',
name: 'Billing_Country',
type: 'string',
default: '',
},
{
displayName: 'Billing State',
name: 'Billing_State',
type: 'string',
default: '',
},
{
displayName: 'Billing Street',
name: 'Billing_Street',
type: 'string',
default: '',
},
],
},
],
};
export const shippingAddress = {
displayName: 'Shipping Address',
name: 'Shipping_Address',
type: 'fixedCollection',
default: {},
placeholder: 'Add Shipping Address Field',
options: [
{
displayName: 'Shipping Address Fields',
name: 'address_fields',
values: [
{
displayName: 'Shipping City',
name: 'Shipping_City',
type: 'string',
default: '',
},
{
displayName: 'Shipping Code',
name: 'Shipping_Code',
type: 'string',
default: '',
},
{
displayName: 'Shipping Country',
name: 'Shipping_Country',
type: 'string',
default: '',
},
{
displayName: 'Shipping State',
name: 'Shipping_State',
type: 'string',
default: '',
},
{
displayName: 'Shipping Street',
name: 'Shipping_Street',
type: 'string',
default: '',
},
],
},
],
};
export const mailingAddress = {
displayName: 'Mailing Address',
name: 'Mailing_Address',
type: 'fixedCollection',
default: {},
placeholder: 'Add Mailing Address Field',
options: [
{
displayName: 'Mailing Address Fields',
name: 'address_fields',
values: [
{
displayName: 'Mailing City',
name: 'Mailing_City',
type: 'string',
default: '',
},
{
displayName: 'Mailing Country',
name: 'Mailing_Country',
type: 'string',
default: '',
},
{
displayName: 'Mailing State',
name: 'Mailing_State',
type: 'string',
default: '',
},
{
displayName: 'Mailing Street',
name: 'Mailing_Street',
type: 'string',
default: '',
},
{
displayName: 'Mailing Zip',
name: 'Mailing_Zip',
type: 'string',
default: '',
},
],
},
],
};
export const otherAddress = {
displayName: 'Other Address',
name: 'Other_Address',
type: 'fixedCollection',
default: {},
placeholder: 'Add Other Address Field',
options: [
{
displayName: 'Other Address Fields',
name: 'address_fields',
values: [
{
displayName: 'Other City',
name: 'Other_City',
type: 'string',
default: '',
},
{
displayName: 'Other State',
name: 'Other_State',
type: 'string',
default: '',
},
{
displayName: 'Other Street',
name: 'Other_Street',
type: 'string',
default: '',
},
{
displayName: 'Other Zip',
name: 'Other_Zip',
type: 'string',
default: '',
},
],
},
],
};
export const address = {
displayName: 'Address',
name: 'Address',
type: 'fixedCollection',
default: {},
placeholder: 'Add Address Field',
options: [
{
displayName: 'Address Fields',
name: 'address_fields',
values: [
{
displayName: 'City',
name: 'City',
type: 'string',
default: '',
},
{
displayName: 'Country',
name: 'Country',
type: 'string',
default: '',
},
{
displayName: 'State',
name: 'State',
type: 'string',
default: '',
},
{
displayName: 'Street',
name: 'Street',
type: 'string',
default: '',
},
{
displayName: 'Zip Code',
name: 'Zip_Code',
type: 'string',
default: '',
},
],
},
],
};
export const productDetails = {
displayName: 'Product Details',
name: 'Product_Details',
type: 'fixedCollection',
default: {},
placeholder: 'Add Product Details Field',
options: [
{
displayName: 'Product Details Fields',
name: 'product_details_fields',
values: [
{
displayName: 'Tax',
name: 'Tax',
type: 'string',
default: '',
},
{
displayName: 'Book',
name: 'book',
type: 'string',
default: '',
},
{
displayName: 'List Price',
name: 'list_price',
type: 'string',
default: '',
},
{
displayName: 'Net Total',
name: 'net_total',
type: 'string',
default: '',
},
{
displayName: 'Product',
name: 'product',
type: 'string',
default: '',
},
{
displayName: 'Product Description',
name: 'product_description',
type: 'string',
default: '',
},
{
displayName: 'Quantity',
name: 'quantity',
type: 'string',
default: '',
},
{
displayName: 'Quantity in Stock',
name: 'quantity_in_stock',
type: 'string',
default: '',
},
{
displayName: 'Total',
name: 'total',
type: 'string',
default: '',
},
{
displayName: 'Total After Discount',
name: 'total_after_discount',
type: 'string',
default: '',
},
{
displayName: 'Unit Price',
name: 'unit_price',
type: 'string',
default: '',
},
],
},
],
};
const pluralize = (resource: string) => (isCamelCase(resource) ? splitCamelCased(resource) : resource) + 's';
const isCamelCase = (resource: string) => /([a-z])([A-Z])/.test(resource);
const splitCamelCased = (resource: string) => resource.replace(/([a-z])([A-Z])/, '$1 $2').toLowerCase();
export const makeGetAllFields = (resource: string) => [
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Return all results.',
displayOptions: {
show: {
resource: [
resource,
],
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: [
resource,
],
operation: [
'getAll',
],
returnAll: [
false,
],
},
},
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
default: {},
displayOptions: {
show: {
resource: [
resource,
],
operation: [
'getAll',
],
},
},
options: [
{
displayName: 'IDs',
name: 'id',
type: 'string',
default: '',
description: `Comma-separated list of IDs to filter the ${pluralize(resource)} by.`,
},
],
},
];

View file

@ -0,0 +1,8 @@
export * from './AccountDescription';
export * from './ContactDescription';
export * from './DealDescription';
export * from './InvoiceDescription';
export * from './LeadDescription';
export * from './PurchaseOrderDescription';
export * from './QuoteDescription';
export * from './SalesOrderDescription';

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB