Add Syncromsp node (#2477)

* Init Node

* Added get customer details api for syncomsp-node

* Fixed formatting bug 🐛

* Updated description for query params, and removed redundant condition in router

* Changed default value for page parameter

* 🚢 Added tickets API

* 🚢 Added contacts API

* 🚢 Added RMM Alerts API

* Add customer API

* Updates post code review

* Rename SyncroMspAPI.credentials.ts to SyncroMspApi.credentials.ts

* added create and delete method to customers module

* fix liniting issue

* Added Update method to customer module

* Code Review Changes

* 🚢 Added CRUD for contacts endpoint

* 🚢 Added CRUD for RMM Alert endpoint

* Added options for status field

* 🐛 fix linting issues

* Init Node

* Added get customer details api for syncomsp-node

* Fixed formatting bug 🐛

* Updated description for query params, and removed redundant condition in router

* Changed default value for page parameter

* 🚢 Added tickets API

* 🚢 Added contacts API

* 🚢 Added RMM Alerts API

* Updates post code review

* Add customer API

* added create and delete method to customers module

* fix liniting issue

* Added Update method to customer module

* Rename SyncroMspAPI.credentials.ts to SyncroMspApi.credentials.ts

* Code Review Changes

* 🚢 Added CRUD for contacts endpoint

* 🚢 Added CRUD for RMM Alert endpoint

* Added options for status field

* 🐛 fix linting issues

* 🚢 Added CRUD for ticket endpoint

* :tag: update get customer module

* :tag: update get customer module

* Minor bug fixes

* Changed response for ticket update

* 👕 Fix lint issue

* Alphabetically ordered all options

* 🐛 Fixed build issue

* 🐛 Fixed Server.ts build issue, rebased from master

*  Fix node issues

*  Fix more issues

*  Fixed all operations with the standard convention

* 👕 Fix lint

* Fix reviewed changes

* update border color

*  minor fixes

* minor fixes

* Added fallback when port in use

*  Minor Fixes

*  Hide addtional paramerts when return all is active

*  Fix issues with Tickets

*  Fix issues with Rmm

*  Fix issues with Customer

* 👕 Fix lint

*  Fix issues with Contact

* 👕 Fixed formatting issue

*  Return 404 in ID not found

* 👕 Fixed formatting issue

*  Improvements

*  Improvements

*  Improvements

*  Add credentials verification

*  Improvements

*  Improvements

*  Additional improvements

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
Anuj Kapoor
2022-01-07 22:49:24 +05:30
committed by GitHub
parent 57016624b8
commit 214dd5061e
78 changed files with 2915 additions and 0 deletions

View File

@@ -0,0 +1,124 @@
import {
CustomerProperties,
} from '../../Interfaces';
import {
addressFixedCollection
} from '../../../methods/sharedFields';
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',
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.',
},
],
},
];

View File

@@ -0,0 +1,53 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import {
IDataObject,
INodeExecutionData,
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) as IDataObject;
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,
};
let responseData;
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
if (!responseData.customer) {
throw new NodeApiError(this.getNode(), responseData, { httpCode: '404', message: 'Customer ID not found' });
}
return this.helpers.returnJsonArray(responseData.customer);
}

View File

@@ -0,0 +1,7 @@
import { updateCustomer as execute } from './execute';
import { customerUpdateDescription as description } from './description';
export {
description,
execute,
};