first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.syncroMsp",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Productivity"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/syncromsp/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.syncromsp/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { INodeTypeBaseDescription, IVersionedNodeType } from 'n8n-workflow';
|
||||
import { VersionedNodeType } from 'n8n-workflow';
|
||||
|
||||
import { SyncroMspV1 } from './v1/SyncroMspV1.node';
|
||||
|
||||
export class SyncroMsp extends VersionedNodeType {
|
||||
constructor() {
|
||||
const baseDescription: INodeTypeBaseDescription = {
|
||||
displayName: 'SyncroMSP',
|
||||
name: 'syncroMsp',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
|
||||
icon: 'file:syncromsp.png',
|
||||
group: ['output'],
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Manage contacts, tickets and more from Syncro MSP',
|
||||
defaultVersion: 1,
|
||||
};
|
||||
|
||||
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||
1: new SyncroMspV1(baseDescription),
|
||||
};
|
||||
|
||||
super(nodeVersions, baseDescription);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,57 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
INodeCredentialTestResult,
|
||||
INodeType,
|
||||
INodeTypeBaseDescription,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { router } from './actions/router';
|
||||
import { versionDescription } from './actions/versionDescription';
|
||||
import { loadOptions } from './methods';
|
||||
import { validateCredentials } from './transport';
|
||||
|
||||
export class SyncroMspV1 implements INodeType {
|
||||
description: INodeTypeDescription;
|
||||
|
||||
constructor(baseDescription: INodeTypeBaseDescription) {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
...versionDescription,
|
||||
usableAsTool: true,
|
||||
};
|
||||
}
|
||||
|
||||
methods = {
|
||||
loadOptions,
|
||||
credentialTest: {
|
||||
async syncroMspApiCredentialTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
try {
|
||||
await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: 'The API Key included in the request is invalid',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: 'OK',
|
||||
message: 'Connection successful!',
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions) {
|
||||
return await router.call(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { AllEntities, Entity, PropertiesOf } from 'n8n-workflow';
|
||||
|
||||
type SyncroMspMap = {
|
||||
contact: 'create' | 'delete' | 'get' | 'getAll' | 'update';
|
||||
customer: 'create' | 'delete' | 'get' | 'getAll' | 'update';
|
||||
rmm: 'create' | 'delete' | 'get' | 'getAll' | 'mute';
|
||||
ticket: 'create' | 'delete' | 'get' | 'getAll' | 'update';
|
||||
};
|
||||
|
||||
export type SyncroMsp = AllEntities<SyncroMspMap>;
|
||||
|
||||
export type SyncroMspMapContact = Entity<SyncroMspMap, 'contact'>;
|
||||
export type SyncroMspMapCustomer = Entity<SyncroMspMap, 'customer'>;
|
||||
export type SyncroMspMapRmm = Entity<SyncroMspMap, 'rmm'>;
|
||||
export type SyncroMspMapTicket = Entity<SyncroMspMap, 'ticket'>;
|
||||
|
||||
export type ContactProperties = PropertiesOf<SyncroMspMapContact>;
|
||||
export type CustomerProperties = PropertiesOf<SyncroMspMapCustomer>;
|
||||
export type RmmProperties = PropertiesOf<SyncroMspMapRmm>;
|
||||
export type TicketProperties = PropertiesOf<SyncroMspMapTicket>;
|
||||
|
||||
export interface IAttachment {
|
||||
fields: {
|
||||
item?: object[];
|
||||
};
|
||||
actions: {
|
||||
item?: object[];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { addressFixedCollection } from '../../../methods/sharedFields';
|
||||
import type { ContactProperties } from '../../Interfaces';
|
||||
|
||||
export const contactCreateDescription: ContactProperties = [
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function createContact(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('customerId', index) as IDataObject;
|
||||
const email = this.getNodeParameter('email', index) as IDataObject;
|
||||
const { address, notes, phone, name } = this.getNodeParameter('additionalFields', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = 'contacts';
|
||||
let body = {} as IDataObject;
|
||||
let addressData = address as IDataObject;
|
||||
|
||||
if (addressData) {
|
||||
addressData = addressData.addressFields as IDataObject;
|
||||
addressData.address1 = addressData.address;
|
||||
}
|
||||
|
||||
body = {
|
||||
...addressData,
|
||||
customer_id: id,
|
||||
email,
|
||||
name,
|
||||
notes,
|
||||
phone,
|
||||
};
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { contactCreateDescription as description } from './description';
|
||||
import { createContact as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { ContactProperties } from '../../Interfaces';
|
||||
|
||||
export const contactDeleteDescription: ContactProperties = [
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Delete a specific contact by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function deleteContact(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('contactId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'DELETE';
|
||||
const endpoint = `contacts/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { contactDeleteDescription as description } from './description';
|
||||
import { deleteContact as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { ContactProperties } from '../../Interfaces';
|
||||
|
||||
export const contactGetDescription: ContactProperties = [
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Get specific contact by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function getContact(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('contactId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = `contacts/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { contactGetDescription as description } from './description';
|
||||
import { getContact as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { ContactProperties } from '../../Interfaces';
|
||||
|
||||
export const contactGetAllDescription: ContactProperties = [
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
noDataExpression: true,
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
description: 'Max number of results to return',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
default: 25,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest, apiRequestAllItems } from '../../../transport';
|
||||
|
||||
export async function getAll(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const returnAll = this.getNodeParameter('returnAll', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = 'contacts';
|
||||
const body = {} as IDataObject;
|
||||
|
||||
let responseData;
|
||||
if (returnAll) {
|
||||
responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', index);
|
||||
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData.contacts.splice(0, limit) as IDataObject[]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { contactGetAllDescription as description } from './description';
|
||||
import { getAll as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create';
|
||||
import * as del from './del';
|
||||
import * as get from './get';
|
||||
import * as getAll from './getAll';
|
||||
import * as update from './update';
|
||||
|
||||
export { getAll, create, del as delete, update, get };
|
||||
|
||||
export const descriptions = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create new contact',
|
||||
action: 'Create a contact',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete contact',
|
||||
action: 'Delete a contact',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Retrieve contact',
|
||||
action: 'Get a contact',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Retrieve many contacts',
|
||||
action: 'Get many contacts',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update contact',
|
||||
action: 'Update a contact',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
},
|
||||
...getAll.description,
|
||||
...create.description,
|
||||
...get.description,
|
||||
...update.description,
|
||||
...del.description,
|
||||
] as INodeProperties[];
|
||||
@@ -0,0 +1,64 @@
|
||||
import { addressFixedCollection } from '../../../methods/sharedFields';
|
||||
import type { ContactProperties } from '../../Interfaces';
|
||||
|
||||
export const contactUpdateDescription: ContactProperties = [
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function updateContact(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('contactId', index) as IDataObject;
|
||||
const { address, customerId, email, name, notes, phone } = this.getNodeParameter(
|
||||
'updateFields',
|
||||
index,
|
||||
);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'PUT';
|
||||
const endpoint = `contacts/${id}`;
|
||||
let body = {} as IDataObject;
|
||||
let addressData = address as IDataObject;
|
||||
|
||||
if (addressData) {
|
||||
addressData = addressData.addressFields as IDataObject;
|
||||
addressData.address1 = addressData.address;
|
||||
}
|
||||
|
||||
body = {
|
||||
...addressData,
|
||||
contact_id: id,
|
||||
customer_id: customerId,
|
||||
email,
|
||||
name,
|
||||
notes,
|
||||
phone,
|
||||
};
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { contactUpdateDescription as description } from './description';
|
||||
import { updateContact as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,105 @@
|
||||
import { addressFixedCollection } from '../../../methods/sharedFields';
|
||||
import type { CustomerProperties } from '../../Interfaces';
|
||||
|
||||
export const customerCreateDescription: CustomerProperties = [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Business Name',
|
||||
name: 'businessName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Get SMS',
|
||||
name: 'getSms',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Invoice Emails',
|
||||
name: 'invoiceCcEmails',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
multipleValueButtonText: 'Add Email',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastname',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'No Email',
|
||||
name: 'noEmail',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notification Email',
|
||||
name: 'notificationEmail',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
noEmail: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Referred By',
|
||||
name: 'referredBy',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description:
|
||||
'Source from which customer is referred to the platform like Linkedin, Google, Customer name etc',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,53 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function addCustomer(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const email = this.getNodeParameter('email', index) as IDataObject;
|
||||
const {
|
||||
address,
|
||||
getSms,
|
||||
businessName,
|
||||
lastname,
|
||||
firstName,
|
||||
invoiceCcEmails,
|
||||
noEmail,
|
||||
notes,
|
||||
notificationEmail,
|
||||
phone,
|
||||
referredBy,
|
||||
} = this.getNodeParameter('additionalFields', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = 'customers';
|
||||
let body = {} as IDataObject;
|
||||
let addressData = address as IDataObject;
|
||||
|
||||
if (addressData) {
|
||||
addressData = addressData.addressFields as IDataObject;
|
||||
addressData.address_2 = addressData.address2;
|
||||
}
|
||||
|
||||
body = {
|
||||
...addressData,
|
||||
business_name: businessName,
|
||||
email,
|
||||
firstname: firstName,
|
||||
get_sms: getSms,
|
||||
invoice_cc_emails: ((invoiceCcEmails as string[]) || []).join(','),
|
||||
lastname,
|
||||
no_email: noEmail,
|
||||
notes,
|
||||
notification_email: notificationEmail,
|
||||
phone,
|
||||
referred_by: referredBy,
|
||||
};
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData.customer as IDataObject);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { customerCreateDescription as description } from './description';
|
||||
import { addCustomer as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { CustomerProperties } from '../../Interfaces';
|
||||
|
||||
export const customerDeleteDescription: CustomerProperties = [
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Delete a specific customer by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function deleteCustomer(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('customerId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'DELETE';
|
||||
const endpoint = `customers/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { customerDeleteDescription as description } from './description';
|
||||
import { deleteCustomer as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { CustomerProperties } from '../../Interfaces';
|
||||
|
||||
export const customerGetDescription: CustomerProperties = [
|
||||
{
|
||||
displayName: 'Cutomer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Get specific customer by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function getCustomer(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('customerId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = `customers/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData.customer as IDataObject);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { customerGetDescription as description } from './description';
|
||||
import { getCustomer as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,97 @@
|
||||
import type { CustomerProperties } from '../../Interfaces';
|
||||
|
||||
export const customerGetAllDescription: CustomerProperties = [
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
noDataExpression: true,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
default: 25,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Business Name',
|
||||
name: 'businessName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Include Disabled',
|
||||
name: 'includeDisabled',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastname',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Search Query',
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'John Doe',
|
||||
description: 'Search query, it can be anything related to customer data like name etc',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort',
|
||||
name: 'sort',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'firstname ASC',
|
||||
description: 'Customer field to order by, eg: "firstname ASC", "city DESC" etc',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest, apiRequestAllItems } from '../../../transport';
|
||||
|
||||
export async function getAll(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const returnAll = this.getNodeParameter('returnAll', index);
|
||||
const filters = this.getNodeParameter('filters', index);
|
||||
|
||||
let qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = 'customers';
|
||||
const body = {} as IDataObject;
|
||||
|
||||
if (filters) {
|
||||
qs = filters;
|
||||
if (qs.businessName) {
|
||||
qs.business_name = qs.businessName;
|
||||
}
|
||||
if (qs.includeDisabled) {
|
||||
qs.include_disabled = qs.includeDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
if (!returnAll) {
|
||||
qs.per_page = this.getNodeParameter('limit', index);
|
||||
}
|
||||
|
||||
let responseData;
|
||||
if (returnAll) {
|
||||
responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData);
|
||||
} else {
|
||||
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData.customers as IDataObject[]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { customerGetAllDescription as description } from './description';
|
||||
import { getAll as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create';
|
||||
import * as del from './del';
|
||||
import * as get from './get';
|
||||
import * as getAll from './getAll';
|
||||
import * as update from './update';
|
||||
|
||||
export { getAll, create, del as delete, update, get };
|
||||
|
||||
export const descriptions = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create new customer',
|
||||
action: 'Create a customer',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete customer',
|
||||
action: 'Delete a customer',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Retrieve customer',
|
||||
action: 'Get a customer',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Retrieve many customers',
|
||||
action: 'Get many customers',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update customer',
|
||||
action: 'Update a customer',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
},
|
||||
...getAll.description,
|
||||
...get.description,
|
||||
...create.description,
|
||||
...del.description,
|
||||
...update.description,
|
||||
] as INodeProperties[];
|
||||
@@ -0,0 +1,111 @@
|
||||
import { addressFixedCollection } from '../../../methods/sharedFields';
|
||||
import type { CustomerProperties } from '../../Interfaces';
|
||||
|
||||
export const customerUpdateDescription: CustomerProperties = [
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['customer'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
addressFixedCollection,
|
||||
{
|
||||
displayName: 'Business Name',
|
||||
name: 'businessName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Get SMS',
|
||||
name: 'getSms',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Invoice Emails',
|
||||
name: 'invoiceCcEmails',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
multipleValueButtonText: 'Add Email',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'No Email',
|
||||
name: 'noEmail',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notification Email',
|
||||
name: 'notificationEmail',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
noEmail: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'phone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Referred By',
|
||||
name: 'referredBy',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description:
|
||||
'Source from which customer is referred to the platform like Linkedin, Google, Customer name etc',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { IDataObject, IExecuteFunctions, INodeExecutionData, JsonObject } from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function updateCustomer(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('customerId', index) as IDataObject;
|
||||
const {
|
||||
address,
|
||||
businessName,
|
||||
email,
|
||||
firstName,
|
||||
getSms,
|
||||
invoiceCcEmails,
|
||||
lastName,
|
||||
noEmail,
|
||||
notes,
|
||||
notificationEmail,
|
||||
phone,
|
||||
referredBy,
|
||||
} = this.getNodeParameter('updateFields', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'PUT';
|
||||
const endpoint = `customers/${id}`;
|
||||
let body = {} as IDataObject;
|
||||
let addressData = address as IDataObject;
|
||||
|
||||
if (addressData) {
|
||||
addressData = addressData.addressFields as IDataObject;
|
||||
addressData.address_2 = addressData.address2;
|
||||
}
|
||||
|
||||
body = {
|
||||
...addressData,
|
||||
business_name: businessName,
|
||||
email,
|
||||
firstname: firstName,
|
||||
get_sms: getSms,
|
||||
invoice_cc_emails: ((invoiceCcEmails as string[]) || []).join(','),
|
||||
lastname: lastName,
|
||||
no_email: noEmail,
|
||||
notes,
|
||||
notification_email: notificationEmail,
|
||||
phone,
|
||||
referred_by: referredBy,
|
||||
};
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
if (!responseData.customer) {
|
||||
throw new NodeApiError(this.getNode(), responseData as JsonObject, {
|
||||
httpCode: '404',
|
||||
message: 'Customer ID not found',
|
||||
});
|
||||
}
|
||||
return this.helpers.returnJsonArray(responseData.customer as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { customerUpdateDescription as description } from './description';
|
||||
import { updateCustomer as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { RmmProperties } from '../../Interfaces';
|
||||
|
||||
export const rmmCreateDescription: RmmProperties = [
|
||||
{
|
||||
displayName: 'Asset ID',
|
||||
name: 'assetId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Resolved',
|
||||
name: 'resolved',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function addAlert(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const customerId = this.getNodeParameter('customerId', index) as IDataObject;
|
||||
const assetId = this.getNodeParameter('assetId', index) as IDataObject;
|
||||
const description = this.getNodeParameter('description', index) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = 'rmm_alerts';
|
||||
let body = {} as IDataObject;
|
||||
|
||||
if (additionalFields) {
|
||||
body = additionalFields;
|
||||
}
|
||||
|
||||
body.customer_id = customerId;
|
||||
body.asset_id = assetId;
|
||||
body.description = description;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData.alert as IDataObject);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { rmmCreateDescription as description } from './description';
|
||||
import { addAlert as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { RmmProperties } from '../../Interfaces';
|
||||
|
||||
export const rmmDeleteDescription: RmmProperties = [
|
||||
{
|
||||
displayName: 'RMM Alert ID',
|
||||
name: 'alertId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Delete the RMM alert by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function deleteAlert(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('alertId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'DELETE';
|
||||
const endpoint = `rmm_alerts/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { rmmDeleteDescription as description } from './description';
|
||||
import { deleteAlert as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { RmmProperties } from '../../Interfaces';
|
||||
|
||||
export const rmmGetDescription: RmmProperties = [
|
||||
{
|
||||
displayName: 'RMM Alert ID',
|
||||
name: 'alertId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Get specific RMM alert by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function getAlert(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('alertId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = `rmm_alerts/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData.rmm_alert as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { rmmGetDescription as description } from './description';
|
||||
import { getAlert as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,70 @@
|
||||
import type { RmmProperties } from '../../Interfaces';
|
||||
|
||||
export const rmmGetAllDescription: RmmProperties = [
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
noDataExpression: true,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
default: 25,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Active',
|
||||
value: 'active',
|
||||
},
|
||||
{
|
||||
name: 'All',
|
||||
value: 'all',
|
||||
},
|
||||
{
|
||||
name: 'Resolved',
|
||||
value: 'resolved',
|
||||
},
|
||||
],
|
||||
default: 'all',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest, apiRequestAllItems } from '../../../transport';
|
||||
|
||||
export async function getAll(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const returnAll = this.getNodeParameter('returnAll', index);
|
||||
const filters = this.getNodeParameter('filters', index);
|
||||
|
||||
let qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = 'rmm_alerts';
|
||||
const body = {} as IDataObject;
|
||||
|
||||
if (filters) {
|
||||
qs = filters;
|
||||
}
|
||||
|
||||
if (qs.status === undefined) {
|
||||
qs.status = 'all';
|
||||
}
|
||||
|
||||
if (!returnAll) {
|
||||
qs.per_page = this.getNodeParameter('limit', index);
|
||||
}
|
||||
|
||||
let responseData;
|
||||
if (returnAll) {
|
||||
responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData);
|
||||
} else {
|
||||
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData.rmm_alerts as IDataObject[]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { rmmGetAllDescription as description } from './description';
|
||||
import { getAll as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create';
|
||||
import * as del from './del';
|
||||
import * as get from './get';
|
||||
import * as getAll from './getAll';
|
||||
import * as mute from './mute';
|
||||
|
||||
export { getAll, get, mute, del as delete, create };
|
||||
|
||||
export const descriptions = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create new RMM Alert',
|
||||
action: 'Create an RMM alert',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete RMM Alert',
|
||||
action: 'Delete an RMM alert',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Retrieve RMM Alert',
|
||||
action: 'Get an RMM alert',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Retrieve many RMM Alerts',
|
||||
action: 'Get many RMM alerts',
|
||||
},
|
||||
{
|
||||
name: 'Mute',
|
||||
value: 'mute',
|
||||
description: 'Mute RMM Alert',
|
||||
action: 'Mute an RMM alert',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
},
|
||||
...getAll.description,
|
||||
...get.description,
|
||||
...create.description,
|
||||
...del.description,
|
||||
...mute.description,
|
||||
] as INodeProperties[];
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { RmmProperties } from '../../Interfaces';
|
||||
|
||||
export const rmmMuteDescription: RmmProperties = [
|
||||
{
|
||||
displayName: 'RMM Alert ID',
|
||||
name: 'alertId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['mute'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Mute the RMM alert by ID',
|
||||
},
|
||||
{
|
||||
displayName: 'Mute Period',
|
||||
name: 'muteFor',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['rmm'],
|
||||
operation: ['mute'],
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: '1 Hour',
|
||||
value: '1-hour',
|
||||
},
|
||||
{
|
||||
name: '1 Day',
|
||||
value: '1-day',
|
||||
},
|
||||
{
|
||||
name: '2 Days',
|
||||
value: '2-days',
|
||||
},
|
||||
{
|
||||
name: '1 Week',
|
||||
value: '1-week',
|
||||
},
|
||||
{
|
||||
name: '2 Weeks',
|
||||
value: '2-weeks',
|
||||
},
|
||||
{
|
||||
name: '1 Month',
|
||||
value: '1-month',
|
||||
},
|
||||
{
|
||||
name: 'Forever',
|
||||
value: 'forever',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Length of time to mute alert for',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function muteAlert(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('alertId', index) as string;
|
||||
const mute = this.getNodeParameter('muteFor', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = `rmm_alerts/${id}/mute`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
body.id = id;
|
||||
body.mute_for = mute;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { rmmMuteDescription as description } from './description';
|
||||
import { muteAlert as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData, JsonObject } from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import * as contact from './contact';
|
||||
import * as customer from './customer';
|
||||
import type { SyncroMsp } from './Interfaces';
|
||||
import * as rmm from './rmm';
|
||||
import * as ticket from './ticket';
|
||||
|
||||
export async function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const operationResult: INodeExecutionData[] = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const resource = this.getNodeParameter<SyncroMsp>('resource', i);
|
||||
let operation = this.getNodeParameter('operation', i);
|
||||
let responseData: INodeExecutionData[] = [];
|
||||
if (operation === 'del') {
|
||||
operation = 'delete';
|
||||
}
|
||||
|
||||
const syncroMsp = {
|
||||
resource,
|
||||
operation,
|
||||
} as SyncroMsp;
|
||||
|
||||
try {
|
||||
if (syncroMsp.resource === 'customer') {
|
||||
responseData = await customer[syncroMsp.operation].execute.call(this, i);
|
||||
} else if (syncroMsp.resource === 'ticket') {
|
||||
responseData = await ticket[syncroMsp.operation].execute.call(this, i);
|
||||
} else if (syncroMsp.resource === 'contact') {
|
||||
responseData = await contact[syncroMsp.operation].execute.call(this, i);
|
||||
} else if (syncroMsp.resource === 'rmm') {
|
||||
responseData = await rmm[syncroMsp.operation].execute.call(this, i);
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(responseData, {
|
||||
itemData: { item: i },
|
||||
});
|
||||
|
||||
operationResult.push(...executionData);
|
||||
} catch (err) {
|
||||
if (this.continueOnFail()) {
|
||||
const executionErrorData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ error: err.message }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
operationResult.push(...executionErrorData);
|
||||
} else {
|
||||
throw new NodeApiError(this.getNode(), err as JsonObject, { itemIndex: i });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [operationResult];
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,129 @@
|
||||
import type { TicketProperties } from '../../Interfaces';
|
||||
|
||||
export const ticketCreateDescription: TicketProperties = [
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Subject',
|
||||
name: 'subject',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Asset ID',
|
||||
name: 'assetId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Assign to Contact',
|
||||
name: 'contactId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the contact you want to assign the ticket to',
|
||||
},
|
||||
// {
|
||||
// displayName: 'Due Date',
|
||||
// name: 'dueDate',
|
||||
// type: 'dateTime',
|
||||
// default: '',
|
||||
// },
|
||||
{
|
||||
displayName: 'Issue Type',
|
||||
name: 'issueType',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Contract Work',
|
||||
value: 'Contract Work',
|
||||
},
|
||||
{
|
||||
name: 'Network Project',
|
||||
value: 'Network Project',
|
||||
},
|
||||
{
|
||||
name: 'Other',
|
||||
value: 'Other',
|
||||
},
|
||||
{
|
||||
name: 'Regular Maintenance',
|
||||
value: 'Regular Maintenance',
|
||||
},
|
||||
{
|
||||
name: 'Remote Support',
|
||||
value: 'Remote Support',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Customer Reply',
|
||||
value: 'Customer Reply',
|
||||
},
|
||||
{
|
||||
name: 'In Progress',
|
||||
value: 'In Progress',
|
||||
},
|
||||
{
|
||||
name: 'New',
|
||||
value: 'New',
|
||||
},
|
||||
{
|
||||
name: 'Resolved',
|
||||
value: 'Resolved',
|
||||
},
|
||||
{
|
||||
name: 'Scheduled',
|
||||
value: 'Scheduled',
|
||||
},
|
||||
{
|
||||
name: 'Waiting for Parts',
|
||||
value: 'Waiting for Parts',
|
||||
},
|
||||
{
|
||||
name: 'Waiting on Customer',
|
||||
value: 'Waiting on Customer',
|
||||
},
|
||||
],
|
||||
default: 'New',
|
||||
description: 'If used along the parameter Search Query, only Search Query will be applied',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function createTicket(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('customerId', index) as IDataObject;
|
||||
const subject = this.getNodeParameter('subject', index) as IDataObject;
|
||||
const { assetId, issueType, status, contactId } = this.getNodeParameter(
|
||||
'additionalFields',
|
||||
index,
|
||||
);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = 'tickets';
|
||||
let body = {} as IDataObject;
|
||||
|
||||
body = {
|
||||
asset_id: assetId,
|
||||
//due_date: dueDate,
|
||||
problem_type: issueType,
|
||||
status,
|
||||
contact_id: contactId,
|
||||
};
|
||||
|
||||
body.customer_id = id;
|
||||
body.subject = subject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData.ticket as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { ticketCreateDescription as description } from './description';
|
||||
import { createTicket as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { TicketProperties } from '../../Interfaces';
|
||||
|
||||
export const ticketDeleteDescription: TicketProperties = [
|
||||
{
|
||||
displayName: 'Ticket ID',
|
||||
name: 'ticketId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Delete a specific customer by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function deleteTicket(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('ticketId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'DELETE';
|
||||
const endpoint = `tickets/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { ticketDeleteDescription as description } from './description';
|
||||
import { deleteTicket as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { TicketProperties } from '../../Interfaces';
|
||||
|
||||
export const ticketGetDescription: TicketProperties = [
|
||||
{
|
||||
displayName: 'Ticket ID',
|
||||
name: 'ticketId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Get specific customer by ID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function getTicket(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('ticketId', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = `tickets/${id}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData.ticket as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { ticketGetDescription as description } from './description';
|
||||
import { getTicket as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,94 @@
|
||||
import type { TicketProperties } from '../../Interfaces';
|
||||
|
||||
export const ticketGetAllDescription: TicketProperties = [
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
noDataExpression: true,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
default: 25,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Search Query',
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'John Doe',
|
||||
description: 'Search query, it can be anything related to ticket data like user etc',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Customer Reply',
|
||||
value: 'Customer Reply',
|
||||
},
|
||||
{
|
||||
name: 'In Progress',
|
||||
value: 'In Progress',
|
||||
},
|
||||
{
|
||||
name: 'New',
|
||||
value: 'New',
|
||||
},
|
||||
{
|
||||
name: 'Resolved',
|
||||
value: 'Resolved',
|
||||
},
|
||||
{
|
||||
name: 'Scheduled',
|
||||
value: 'Scheduled',
|
||||
},
|
||||
{
|
||||
name: 'Waiting for Parts',
|
||||
value: 'Waiting for Parts',
|
||||
},
|
||||
{
|
||||
name: 'Waiting on Customer',
|
||||
value: 'Waiting on Customer',
|
||||
},
|
||||
],
|
||||
default: 'New',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest, apiRequestAllItems } from '../../../transport';
|
||||
|
||||
export async function getAll(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const returnAll = this.getNodeParameter('returnAll', index);
|
||||
const filters = this.getNodeParameter('filters', index);
|
||||
|
||||
let qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = 'tickets';
|
||||
const body = {} as IDataObject;
|
||||
|
||||
if (filters) {
|
||||
qs = filters;
|
||||
}
|
||||
|
||||
if (!returnAll) {
|
||||
qs.per_page = this.getNodeParameter('limit', index);
|
||||
}
|
||||
|
||||
let responseData;
|
||||
if (returnAll) {
|
||||
responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData);
|
||||
} else {
|
||||
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
return this.helpers.returnJsonArray(responseData.tickets as IDataObject[]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { ticketGetAllDescription as description } from './description';
|
||||
import { getAll as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create';
|
||||
import * as del from './del';
|
||||
import * as get from './get';
|
||||
import * as getAll from './getAll';
|
||||
import * as update from './update';
|
||||
|
||||
export { getAll, create, get, del as delete, update };
|
||||
|
||||
export const descriptions = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create new ticket',
|
||||
action: 'Create a ticket',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete ticket',
|
||||
action: 'Delete a ticket',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Retrieve ticket',
|
||||
action: 'Get a ticket',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Retrieve many tickets',
|
||||
action: 'Get many tickets',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update ticket',
|
||||
action: 'Update a ticket',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
},
|
||||
...getAll.description,
|
||||
...create.description,
|
||||
...get.description,
|
||||
...del.description,
|
||||
...update.description,
|
||||
] as INodeProperties[];
|
||||
@@ -0,0 +1,127 @@
|
||||
import type { TicketProperties } from '../../Interfaces';
|
||||
|
||||
export const ticketUpdateDescription: TicketProperties = [
|
||||
{
|
||||
displayName: 'Ticket ID',
|
||||
name: 'ticketId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Asset ID',
|
||||
name: 'assetId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Assign to Contact',
|
||||
name: 'contactId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the contact you want to assign the ticket to',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
name: 'dueDate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Issue Type',
|
||||
name: 'issueType',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Contract Work',
|
||||
value: 'Contract Work',
|
||||
},
|
||||
{
|
||||
name: 'Network Project',
|
||||
value: 'Network Project',
|
||||
},
|
||||
{
|
||||
name: 'Other',
|
||||
value: 'Other',
|
||||
},
|
||||
{
|
||||
name: 'Regular Maintenance',
|
||||
value: 'Regular Maintenance',
|
||||
},
|
||||
{
|
||||
name: 'Remote Support',
|
||||
value: 'Remote Support',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Customer Reply',
|
||||
value: 'Customer Reply',
|
||||
},
|
||||
{
|
||||
name: 'In Progress',
|
||||
value: 'In Progress',
|
||||
},
|
||||
{
|
||||
name: 'New',
|
||||
value: 'New',
|
||||
},
|
||||
{
|
||||
name: 'Resolved',
|
||||
value: 'Resolved',
|
||||
},
|
||||
{
|
||||
name: 'Scheduled',
|
||||
value: 'Scheduled',
|
||||
},
|
||||
{
|
||||
name: 'Waiting for Parts',
|
||||
value: 'Waiting for Parts',
|
||||
},
|
||||
{
|
||||
name: 'Waiting on Customer',
|
||||
value: 'Waiting on Customer',
|
||||
},
|
||||
],
|
||||
default: 'New',
|
||||
},
|
||||
{
|
||||
displayName: 'Subject',
|
||||
name: 'subject',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function updateTicket(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const id = this.getNodeParameter('ticketId', index) as IDataObject;
|
||||
const { assetId, customerId, dueDate, issueType, status, subject, ticketType, contactId } =
|
||||
this.getNodeParameter('updateFields', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'PUT';
|
||||
const endpoint = `tickets/${id}`;
|
||||
let body = {} as IDataObject;
|
||||
|
||||
body = {
|
||||
...(assetId && { asset_id: assetId }),
|
||||
...(customerId && { customer_id: customerId }),
|
||||
...(dueDate && { due_date: dueDate }),
|
||||
...(issueType && { problem_type: issueType }),
|
||||
...(status && { status }),
|
||||
...(subject && { subject }),
|
||||
...(ticketType && { ticket_type: ticketType }),
|
||||
...(contactId && { contact_id: contactId }),
|
||||
};
|
||||
|
||||
if (!Object.keys(body).length) {
|
||||
throw new NodeOperationError(this.getNode(), 'At least one update fields has to be defined', {
|
||||
itemIndex: index,
|
||||
});
|
||||
}
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData.ticket as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { ticketUpdateDescription as description } from './description';
|
||||
import { updateTicket as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,61 @@
|
||||
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
|
||||
import { NodeConnectionTypes, type INodeTypeDescription } from 'n8n-workflow';
|
||||
|
||||
import * as contact from './contact';
|
||||
import * as customer from './customer';
|
||||
import * as rmm from './rmm';
|
||||
import * as ticket from './ticket';
|
||||
|
||||
export const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'SyncroMSP',
|
||||
name: 'syncroMsp',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
|
||||
icon: 'file:syncromsp.png',
|
||||
group: ['output'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Gets data from SyncroMSP',
|
||||
defaults: {
|
||||
name: 'SyncroMSP',
|
||||
},
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'syncroMspApi',
|
||||
required: true,
|
||||
testedBy: 'syncroMspApiCredentialTest',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Contact',
|
||||
value: 'contact',
|
||||
},
|
||||
{
|
||||
name: 'Customer',
|
||||
value: 'customer',
|
||||
},
|
||||
{
|
||||
name: 'RMM',
|
||||
value: 'rmm',
|
||||
},
|
||||
{
|
||||
name: 'Ticket',
|
||||
value: 'ticket',
|
||||
},
|
||||
],
|
||||
default: 'contact',
|
||||
},
|
||||
...customer.descriptions,
|
||||
...ticket.descriptions,
|
||||
...contact.descriptions,
|
||||
...rmm.descriptions,
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * as loadOptions from './loadOptions';
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { apiRequestAllItems } from '../transport';
|
||||
|
||||
// Get all the available channels
|
||||
|
||||
export async function getCustomers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const endpoint = 'customers';
|
||||
const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {});
|
||||
|
||||
if (responseData === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No data got returned');
|
||||
}
|
||||
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
for (const data of responseData) {
|
||||
returnData.push({
|
||||
name: data.fullname as string,
|
||||
value: data.id as number,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return returnData;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const addressFixedCollection: INodeProperties = {
|
||||
displayName: 'Address',
|
||||
name: 'address',
|
||||
placeholder: 'Add Address Fields',
|
||||
type: 'fixedCollection',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Address Fields',
|
||||
name: 'addressFields',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Line 1',
|
||||
name: 'address',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Line 2',
|
||||
name: 'address2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'City',
|
||||
name: 'city',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'State',
|
||||
name: 'state',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'ZIP',
|
||||
name: 'zip',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,83 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
GenericValue,
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialTestFunctions,
|
||||
IDataObject,
|
||||
IHttpRequestOptions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
/**
|
||||
* Make an API request to Mattermost
|
||||
*/
|
||||
export async function apiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD',
|
||||
endpoint: string,
|
||||
body: IDataObject | GenericValue | GenericValue[] = {},
|
||||
query: IDataObject = {},
|
||||
) {
|
||||
const credentials = await this.getCredentials('syncroMspApi');
|
||||
|
||||
query.api_key = credentials.apiKey;
|
||||
|
||||
const options: IHttpRequestOptions = {
|
||||
method,
|
||||
body,
|
||||
qs: query,
|
||||
url: `https://${credentials.subdomain}.syncromsp.com/api/v1/${endpoint}`,
|
||||
headers: {},
|
||||
};
|
||||
|
||||
try {
|
||||
return await this.helpers.httpRequest(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
export async function apiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD',
|
||||
endpoint: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
) {
|
||||
let returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
query.page = 1;
|
||||
|
||||
do {
|
||||
responseData = await apiRequest.call(this, method, endpoint, body, query);
|
||||
query.page++;
|
||||
returnData = returnData.concat(responseData[endpoint] as IDataObject[]);
|
||||
} while (responseData[endpoint].length !== 0);
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function validateCredentials(
|
||||
this: ICredentialTestFunctions,
|
||||
decryptedCredentials: ICredentialDataDecryptedObject,
|
||||
): Promise<any> {
|
||||
const credentials = decryptedCredentials;
|
||||
|
||||
const { subdomain, apiKey } = credentials as {
|
||||
subdomain: string;
|
||||
apiKey: string;
|
||||
};
|
||||
|
||||
const options: IHttpRequestOptions = {
|
||||
method: 'GET',
|
||||
qs: {
|
||||
api_key: apiKey,
|
||||
},
|
||||
url: `https://${subdomain}.syncromsp.com/api/v1//me`,
|
||||
};
|
||||
|
||||
return await this.helpers.request(options);
|
||||
}
|
||||
Reference in New Issue
Block a user