add connection description

This commit is contained in:
quansenB 2019-11-03 22:17:43 +01:00
parent 7da53ad943
commit e029468171
5 changed files with 434 additions and 11 deletions

View file

@ -34,7 +34,16 @@ import {
ecomCustomerOperations, ecomCustomerOperations,
ecomCustomerFields ecomCustomerFields
} from './EcomCustomerDescription'; } from './EcomCustomerDescription';
import { ecomOrderProductsOperations, ecomOrderProductsFields } from './EcomOrderProductsDescription';
import {
ecomOrderProductsOperations,
ecomOrderProductsFields
} from './EcomOrderProductsDescription';
import {
connectionOperations,
connectionFields
} from './ConnectionDescription';
interface CustomProperty { interface CustomProperty {
name: string; name: string;
@ -98,6 +107,10 @@ export class ActiveCampaign implements INodeType {
name: 'Deal', name: 'Deal',
value: 'deal', value: 'deal',
}, },
{
name: 'Connection',
value: 'connection'
}
{ {
name: 'E-commerce Order', name: 'E-commerce Order',
value: 'ecommerceOrder', value: 'ecommerceOrder',
@ -120,10 +133,14 @@ export class ActiveCampaign implements INodeType {
// ---------------------------------- // ----------------------------------
...contactOperations, ...contactOperations,
...dealOperations, ...dealOperations,
...connectionOperations,
...ecomOrderOperations, ...ecomOrderOperations,
...ecomCustomerOperations, ...ecomCustomerOperations,
...ecomOrderProductsOperations, ...ecomOrderProductsOperations,
// ----------------------------------
// fields
// ----------------------------------
// ---------------------------------- // ----------------------------------
// contact // contact
// ---------------------------------- // ----------------------------------
@ -134,6 +151,11 @@ export class ActiveCampaign implements INodeType {
// ---------------------------------- // ----------------------------------
...dealFields, ...dealFields,
// ----------------------------------
// connection
// ----------------------------------
...connectionFields,
// ---------------------------------- // ----------------------------------
// ecommerceOrder // ecommerceOrder
// ---------------------------------- // ----------------------------------
@ -368,6 +390,83 @@ export class ActiveCampaign implements INodeType {
const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; const dealNoteId = this.getNodeParameter('dealNoteId', i) as number;
endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`; endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`;
} else {
throw new Error(`The operation "${operation}" is not known`);
}
} else if (resource === 'connection') {
if (operation === 'create') {
// ----------------------------------
// connection:create
// ----------------------------------
requestMethod = 'POST';
const updateIfExists = this.getNodeParameter('updateIfExists', i) as boolean;
if (updateIfExists === true) {
endpoint = '/api/3/connection/sync';
} else {
endpoint = '/api/3/connections';
}
dataKey = 'connection';
body.connection = {
email: this.getNodeParameter('email', i) as string,
} as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
addAdditionalFields(body.connection as IDataObject, additionalFields);
} else if (operation === 'delete') {
// ----------------------------------
// connection:delete
// ----------------------------------
requestMethod = 'DELETE';
const connectionId = this.getNodeParameter('connectionId', i) as number;
endpoint = `/api/3/connections/${connectionId}`;
} else if (operation === 'get') {
// ----------------------------------
// connection:get
// ----------------------------------
requestMethod = 'GET';
const connectionId = this.getNodeParameter('connectionId', i) as number;
endpoint = `/api/3/connections/${connectionId}`;
} else if (operation === 'getAll') {
// ----------------------------------
// connections:getAll
// ----------------------------------
requestMethod = 'GET';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
dataKey = 'connections';
endpoint = `/api/3/connections`;
} else if (operation === 'update') {
// ----------------------------------
// connection:update
// ----------------------------------
requestMethod = 'PUT';
const connectionId = this.getNodeParameter('connectionId', i) as number;
endpoint = `/api/3/connections/${connectionId}`;
dataKey = 'connection';
body.connection = {} as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
addAdditionalFields(body.connection as IDataObject, updateFields);
} else { } else {
throw new Error(`The operation "${operation}" is not known`); throw new Error(`The operation "${operation}" is not known`);
} }

View file

@ -0,0 +1,324 @@
import { INodeProperties } from "n8n-workflow";
import { allCurrencies } from './currencies';
export const connectionOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'connection',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a connection',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a connection',
},
{
name: 'Get',
value: 'get',
description: 'Get data of a connection',
},
{
name: 'Get All',
value: 'getAll',
description: 'Get data of all connections',
},
{
name: 'Update',
value: 'update',
description: 'Update a connection',
},
],
default: 'create',
description: 'The operation to perform.',
},
] as INodeProperties[];
export const connectionFields = [
// ----------------------------------
// connection:create
// ----------------------------------
{
displayName: 'Service',
name: 'service',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'connection',
],
},
},
description: 'The name of the service.',
},
{
displayName: 'External accout ID',
name: 'externalid',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'connection',
],
},
},
description: 'The id of the account in the external service.',
},
{
displayName: 'Account Name',
name: 'name',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'connection',
],
},
},
description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").',
},
{
displayName: 'Logo URL',
name: 'logoUrl',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'connection',
],
},
},
description: 'The URL to a logo image for the external service.',
},
{
displayName: 'Link URL',
name: 'linkUrl',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'connection',
],
},
},
description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.',
},
// ----------------------------------
// connection:update
// ----------------------------------
{
displayName: 'Connection ID',
name: 'connectionId',
type: 'number',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'connection',
],
},
},
default: 0,
required: true,
description: 'ID of the connection to update.',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
description: 'The fields to update.',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'connection',
],
},
},
default: {},
options: [
{
displayName: 'Service',
name: 'service',
type: 'string',
default: '',
description: 'The name of the service.',
},
{
displayName: 'External accout ID',
name: 'externalid',
type: 'string',
default: '',
description: 'The id of the account in the external service.',
},
{
displayName: 'Account Name',
name: 'name',
type: 'string',
default: '',
description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").',
},
{
displayName: 'Logo URL',
name: 'logoUrl',
type: 'string',
default: '',
description: 'The URL to a logo image for the external service.',
},
{
displayName: 'Link URL',
name: 'linkUrl',
type: 'string',
default: '',
description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website.',
},
{
displayName: 'Status',
name: 'status',
type: 'number',
default: 1,
description: 'The status of the connection (0 = error; 1 = connected)',
},
{
displayName: 'Syncronisation Status',
name: 'syncStatus',
type: 'number',
default: 1,
description: 'The status of a sync triggered on the connection (0 = sync stopped; 1 = sync running).',
},
]
},
// ----------------------------------
// connection:delete
// ----------------------------------
{
displayName: 'Connection ID',
name: 'connectionId',
type: 'number',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'connection',
],
},
},
default: 0,
required: true,
description: 'ID of the connection to delete.',
},
// ----------------------------------
// connection:get
// ----------------------------------
{
displayName: 'Connection ID',
name: 'connectionId',
type: 'number',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'connection',
],
},
},
default: 0,
required: true,
description: 'ID of the connection to get.',
},
// ----------------------------------
// connection:getAll
// ----------------------------------
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'connection',
],
},
},
default: false,
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'connection',
],
returnAll: [
false,
],
},
},
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 100,
description: 'How many results to return.',
},
] as INodeProperties[];

View file

@ -64,7 +64,7 @@ export const contactFields = [
], ],
}, },
}, },
description: 'The email of the contact to create', description: 'The email of the contact to create.',
}, },
{ {
displayName: 'Update if exists', displayName: 'Update if exists',
@ -105,14 +105,14 @@ export const contactFields = [
name: 'firstName', name: 'firstName',
type: 'string', type: 'string',
default: '', default: '',
description: 'The first name of the contact to create', description: 'The first name of the contact to create.',
}, },
{ {
displayName: 'Last Name', displayName: 'Last Name',
name: 'lastName', name: 'lastName',
type: 'string', type: 'string',
default: '', default: '',
description: 'The last name of the contact to create', description: 'The last name of the contact to create.',
}, },
{ {
displayName: 'Phone', displayName: 'Phone',
@ -208,14 +208,14 @@ export const contactFields = [
name: 'firstName', name: 'firstName',
type: 'string', type: 'string',
default: '', default: '',
description: 'First name of the contact', description: 'First name of the contact.',
}, },
{ {
displayName: 'Last Name', displayName: 'Last Name',
name: 'lastName', name: 'lastName',
type: 'string', type: 'string',
default: '', default: '',
description: 'Last name of the contact', description: 'Last name of the contact.',
}, },
{ {
displayName: 'Phone', displayName: 'Phone',

View file

@ -359,7 +359,7 @@ export const dealFields = [
], ],
}, },
}, },
description: 'The ID of the deal', description: 'The ID of the deal to delete.',
}, },
// ---------------------------------- // ----------------------------------
@ -381,7 +381,7 @@ export const dealFields = [
], ],
}, },
}, },
description: 'The ID of the deal', description: 'The ID of the deal to get.',
}, },
// ---------------------------------- // ----------------------------------

View file

@ -148,7 +148,7 @@ export const ecomCustomerFields = [
}, },
default: 0, default: 0,
required: true, required: true,
description: 'ID of the ecommerceCustomer to update.', description: 'ID of the E-commerce customer to update.',
}, },
{ {
displayName: 'Update Fields', displayName: 'Update Fields',
@ -218,7 +218,7 @@ export const ecomCustomerFields = [
}, },
default: 0, default: 0,
required: true, required: true,
description: 'ID of the ecommerceCustomer to update.', description: 'ID of the E-commerce customer to delete.',
}, },
// ---------------------------------- // ----------------------------------
@ -240,7 +240,7 @@ export const ecomCustomerFields = [
}, },
default: 0, default: 0,
required: true, required: true,
description: 'ID of the ecommerceCustomer to update.', description: 'ID of the E-commerce customer to get.',
}, },
// ---------------------------------- // ----------------------------------