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,243 @@
|
||||
import type {
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialTestFunctions,
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
IHttpRequestMethods,
|
||||
ILoadOptionsFunctions,
|
||||
IPollFunctions,
|
||||
IRequestOptions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
// Interfaces and Types -------------------------------------------------------------
|
||||
interface IHaloPSATokens {
|
||||
scope: string;
|
||||
token_type: string;
|
||||
access_token: string;
|
||||
expires_in: number;
|
||||
refresh_token: string;
|
||||
id_token: string;
|
||||
}
|
||||
|
||||
function getAuthUrl(credentials: IDataObject) {
|
||||
return credentials.hostingType === 'on-premise'
|
||||
? `${credentials.appUrl}/auth/token`
|
||||
: `${credentials.authUrl}/token?tenant=${credentials.tenant}`;
|
||||
}
|
||||
|
||||
// API Requests ---------------------------------------------------------------------
|
||||
|
||||
export async function getAccessTokens(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
): Promise<IHaloPSATokens> {
|
||||
const credentials = await this.getCredentials('haloPSAApi');
|
||||
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
method: 'POST',
|
||||
form: {
|
||||
client_id: credentials.client_id,
|
||||
client_secret: credentials.client_secret,
|
||||
grant_type: 'client_credentials',
|
||||
scope: credentials.scope,
|
||||
},
|
||||
uri: getAuthUrl(credentials),
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
const tokens = await this.helpers.request(options);
|
||||
return tokens;
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
export async function haloPSAApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
accessToken: string,
|
||||
body: IDataObject | IDataObject[] = {},
|
||||
qs: IDataObject = {},
|
||||
option: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const resourceApiUrl = (await this.getCredentials('haloPSAApi')).resourceApiUrl as string;
|
||||
|
||||
try {
|
||||
let options: IRequestOptions = {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
'User-Agent': 'https://n8n.io',
|
||||
Connection: 'keep-alive',
|
||||
Accept: '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: `${resourceApiUrl}${resource}`,
|
||||
json: true,
|
||||
};
|
||||
options = Object.assign({}, options, option);
|
||||
if (Object.keys(body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
const result = await this.helpers.request(options);
|
||||
if (method === 'DELETE' && result.id) {
|
||||
return { success: true };
|
||||
}
|
||||
return result;
|
||||
} catch (error) {
|
||||
const message = (error as JsonObject).message as string;
|
||||
if (method === 'DELETE' || method === 'GET' || (method === 'POST' && message)) {
|
||||
let newErrorMessage;
|
||||
if (message.includes('400')) {
|
||||
this.logger.debug(message);
|
||||
newErrorMessage = JSON.parse(message.split(' - ')[1]);
|
||||
(error as JsonObject).message = `For field ID, ${
|
||||
newErrorMessage.id || newErrorMessage['[0].id']
|
||||
}`;
|
||||
}
|
||||
if (message.includes('403')) {
|
||||
(error as JsonObject).message =
|
||||
`You don\'t have permissions to ${method.toLowerCase()} ${resource
|
||||
.split('/')[1]
|
||||
.toLowerCase()}.`;
|
||||
}
|
||||
}
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
// export async function reasignTickets(
|
||||
// this:
|
||||
// | IHookFunctions
|
||||
// | IExecuteFunctions
|
||||
// | ILoadOptionsFunctions
|
||||
// | IPollFunctions,
|
||||
// clientId: string,
|
||||
// reasigmentCliendId: string,
|
||||
// accessToken: string,
|
||||
// ): Promise<any> {
|
||||
// const response = (await haloPSAApiRequest.call(
|
||||
// this,
|
||||
// 'GET',
|
||||
// `/tickets`,
|
||||
// accessToken,
|
||||
// {},
|
||||
// { client_id: reasigmentCliendId },
|
||||
// )) as IDataObject;
|
||||
|
||||
// const { tickets } = response;
|
||||
// this.logger.debug((tickets as IDataObject[]).map(t => t.id));
|
||||
// const body: IDataObject = {
|
||||
// id: clientId,
|
||||
// client_id: reasigmentCliendId,
|
||||
// };
|
||||
|
||||
// for (const ticket of (tickets as IDataObject[])) {
|
||||
// this.logger.debug(ticket.id);
|
||||
// await haloPSAApiRequest.call(this, 'DELETE', `/tickets/${ticket.id}`, accessToken);
|
||||
// }
|
||||
// }
|
||||
|
||||
export async function haloPSAApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||
propertyName: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
accessToken: string,
|
||||
body = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData: IDataObject;
|
||||
query.page_size = 100;
|
||||
query.page_no = 1;
|
||||
query.pageinate = true;
|
||||
|
||||
do {
|
||||
responseData = (await haloPSAApiRequest.call(
|
||||
this,
|
||||
method,
|
||||
endpoint,
|
||||
accessToken,
|
||||
body,
|
||||
query,
|
||||
)) as IDataObject;
|
||||
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
|
||||
query.page_no++;
|
||||
//@ts-ignore
|
||||
} while (returnData.length < responseData.record_count);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
// Utilities ------------------------------------------------------------------------
|
||||
|
||||
export function simplifyHaloPSAGetOutput(
|
||||
response: IDataObject[],
|
||||
fieldsList: string[],
|
||||
): IDataObject[] {
|
||||
const output = [];
|
||||
for (const item of response) {
|
||||
const simplifiedItem: IDataObject = {};
|
||||
Object.keys(item).forEach((key: string) => {
|
||||
if (fieldsList.includes(key)) {
|
||||
simplifiedItem[key] = item[key];
|
||||
}
|
||||
});
|
||||
output.push(simplifiedItem);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
export function qsSetStatus(status: string) {
|
||||
if (!status) return {};
|
||||
const qs: IDataObject = {};
|
||||
if (status === 'all') {
|
||||
qs.includeinactive = true;
|
||||
qs.includeactive = true;
|
||||
} else if (status === 'active') {
|
||||
qs.includeinactive = false;
|
||||
qs.includeactive = true;
|
||||
} else {
|
||||
qs.includeinactive = true;
|
||||
qs.includeactive = false;
|
||||
}
|
||||
return qs;
|
||||
}
|
||||
|
||||
// Validation -----------------------------------------------------------------------
|
||||
|
||||
export async function validateCredentials(
|
||||
this: ICredentialTestFunctions,
|
||||
decryptedCredentials: ICredentialDataDecryptedObject,
|
||||
): Promise<IHaloPSATokens> {
|
||||
const credentials = decryptedCredentials;
|
||||
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
method: 'POST',
|
||||
form: {
|
||||
client_id: credentials.client_id,
|
||||
client_secret: credentials.client_secret,
|
||||
grant_type: 'client_credentials',
|
||||
scope: credentials.scope,
|
||||
},
|
||||
uri: getAuthUrl(credentials),
|
||||
json: true,
|
||||
};
|
||||
|
||||
return (await this.helpers.request(options)) as IHaloPSATokens;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.haloPSA",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Communication"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/halopsa/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.halopsa/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,684 @@
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type ICredentialDataDecryptedObject,
|
||||
type ICredentialsDecrypted,
|
||||
type ICredentialTestFunctions,
|
||||
type IDataObject,
|
||||
type ILoadOptionsFunctions,
|
||||
type INodeCredentialTestResult,
|
||||
type INodeExecutionData,
|
||||
type INodePropertyOptions,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type JsonObject,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
clientFields,
|
||||
clientOperations,
|
||||
siteFields,
|
||||
siteOperations,
|
||||
ticketFields,
|
||||
ticketOperations,
|
||||
userFields,
|
||||
userOperations,
|
||||
} from './descriptions';
|
||||
import {
|
||||
getAccessTokens,
|
||||
haloPSAApiRequest,
|
||||
haloPSAApiRequestAllItems,
|
||||
qsSetStatus,
|
||||
simplifyHaloPSAGetOutput,
|
||||
validateCredentials,
|
||||
} from './GenericFunctions';
|
||||
|
||||
export class HaloPSA implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'HaloPSA',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-name-miscased
|
||||
name: 'haloPSA',
|
||||
icon: 'file:halopsa.svg',
|
||||
group: ['input'],
|
||||
version: 1,
|
||||
description: 'Consume HaloPSA API',
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
defaults: {
|
||||
name: 'HaloPSA',
|
||||
},
|
||||
usableAsTool: true,
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'haloPSAApi',
|
||||
required: true,
|
||||
testedBy: 'haloPSAApiCredentialTest',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Client',
|
||||
value: 'client',
|
||||
},
|
||||
{
|
||||
name: 'Site',
|
||||
value: 'site',
|
||||
},
|
||||
{
|
||||
name: 'Ticket',
|
||||
value: 'ticket',
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
value: 'user',
|
||||
},
|
||||
],
|
||||
default: 'client',
|
||||
required: true,
|
||||
},
|
||||
...clientOperations,
|
||||
...clientFields,
|
||||
...ticketOperations,
|
||||
...ticketFields,
|
||||
...siteOperations,
|
||||
...siteFields,
|
||||
...userOperations,
|
||||
...userFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
async getHaloPSASites(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const tokens = await getAccessTokens.call(this);
|
||||
|
||||
const response = (await haloPSAApiRequestAllItems.call(
|
||||
this,
|
||||
'sites',
|
||||
'GET',
|
||||
'/site',
|
||||
tokens.access_token,
|
||||
)) as IDataObject[];
|
||||
|
||||
const options = response.map((site) => {
|
||||
return {
|
||||
name: site.clientsite_name as string,
|
||||
value: site.id as number,
|
||||
};
|
||||
});
|
||||
|
||||
return options.sort((a, b) => a.name.localeCompare(b.name));
|
||||
},
|
||||
|
||||
async getHaloPSAClients(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const tokens = await getAccessTokens.call(this);
|
||||
|
||||
const response = (await haloPSAApiRequestAllItems.call(
|
||||
this,
|
||||
'clients',
|
||||
'GET',
|
||||
'/Client',
|
||||
tokens.access_token,
|
||||
)) as IDataObject[];
|
||||
|
||||
const options = response.map((client) => {
|
||||
return {
|
||||
name: client.name as string,
|
||||
value: client.id as number,
|
||||
};
|
||||
});
|
||||
|
||||
return options.sort((a, b) => a.name.localeCompare(b.name));
|
||||
},
|
||||
|
||||
async getHaloPSATicketsTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const tokens = await getAccessTokens.call(this);
|
||||
|
||||
const response = (await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/TicketType',
|
||||
tokens.access_token,
|
||||
{},
|
||||
)) as IDataObject[];
|
||||
|
||||
const options = response.map((ticket) => {
|
||||
return {
|
||||
name: ticket.name as string,
|
||||
value: ticket.id as number,
|
||||
};
|
||||
});
|
||||
|
||||
return options
|
||||
.filter((ticket) => {
|
||||
if (
|
||||
// folowing types throws error 400 - "CODE:APP03/2 Please select the CAB members to approve"
|
||||
ticket.name.includes('Request') ||
|
||||
ticket.name.includes('Offboarding') ||
|
||||
ticket.name.includes('Onboarding') ||
|
||||
ticket.name.includes('Other Hardware') ||
|
||||
ticket.name.includes('Software Change')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
},
|
||||
|
||||
async getHaloPSAAgents(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const tokens = await getAccessTokens.call(this);
|
||||
|
||||
const response = (await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/agent',
|
||||
tokens.access_token,
|
||||
{},
|
||||
)) as IDataObject[];
|
||||
|
||||
const options = response.map((agent) => {
|
||||
return {
|
||||
name: agent.name as string,
|
||||
value: agent.id as number,
|
||||
};
|
||||
});
|
||||
|
||||
return options.sort((a, b) => a.name.localeCompare(b.name));
|
||||
},
|
||||
},
|
||||
|
||||
credentialTest: {
|
||||
async haloPSAApiCredentialTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
try {
|
||||
await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: (error as JsonObject).message as string,
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: 'OK',
|
||||
message: 'Connection successful!',
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
let responseData;
|
||||
|
||||
const tokens = await getAccessTokens.call(this);
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
|
||||
//====================================================================
|
||||
// Main Loop
|
||||
//====================================================================
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
if (resource === 'client') {
|
||||
const simplifiedOutput = ['id', 'name', 'notes', 'is_vip', 'website'];
|
||||
|
||||
if (operation === 'create') {
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const name = this.getNodeParameter('clientName', i) as string;
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
...additionalFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/client',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const clientId = this.getNodeParameter('clientId', i) as string;
|
||||
// const reasign = this.getNodeParameter('reasign', i) as boolean;
|
||||
// if (reasign) {
|
||||
// const reasigmentCliendId = this.getNodeParameter('reasigmentCliendId', i) as string;
|
||||
// await reasignTickets.call(this, clientId, reasigmentCliendId, tokens.access_token);
|
||||
// }
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/client/${clientId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const clientId = this.getNodeParameter('clientId', i) as string;
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const response = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/client/${clientId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const filters = this.getNodeParameter('filters', i);
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const qs: IDataObject = {};
|
||||
let response;
|
||||
|
||||
Object.assign(qs, filters, qsSetStatus(filters.activeStatus as string));
|
||||
if (returnAll) {
|
||||
response = await haloPSAApiRequestAllItems.call(
|
||||
this,
|
||||
'clients',
|
||||
'GET',
|
||||
'/client',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.count = limit;
|
||||
const { clients } = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/client',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
response = clients;
|
||||
}
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'update') {
|
||||
const clientId = this.getNodeParameter('clientId', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDataObject = {
|
||||
id: clientId,
|
||||
...updateFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/client',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'site') {
|
||||
const simplifiedOutput = [
|
||||
'id',
|
||||
'name',
|
||||
'client_id',
|
||||
'maincontact_name',
|
||||
'notes',
|
||||
'phonenumber',
|
||||
];
|
||||
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('siteName', i) as string;
|
||||
const clientId = this.getNodeParameter('clientId', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
client_id: clientId,
|
||||
...additionalFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/site',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const siteId = this.getNodeParameter('siteId', i) as string;
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/site/${siteId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const siteId = this.getNodeParameter('siteId', i) as string;
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const response = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/site/${siteId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const filters = this.getNodeParameter('filters', i);
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const qs: IDataObject = {};
|
||||
let response;
|
||||
|
||||
Object.assign(qs, filters, qsSetStatus(filters.activeStatus as string));
|
||||
if (returnAll) {
|
||||
response = await haloPSAApiRequestAllItems.call(
|
||||
this,
|
||||
'sites',
|
||||
'GET',
|
||||
'/site',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.count = limit;
|
||||
const { sites } = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/site',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
response = sites;
|
||||
}
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'update') {
|
||||
const siteId = this.getNodeParameter('siteId', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDataObject = {
|
||||
id: siteId,
|
||||
...updateFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/site',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'ticket') {
|
||||
const simplifiedOutput = [
|
||||
'id',
|
||||
'summary',
|
||||
'details',
|
||||
'agent_id',
|
||||
'startdate',
|
||||
'targetdate',
|
||||
];
|
||||
|
||||
if (operation === 'create') {
|
||||
const summary = this.getNodeParameter('summary', i) as string;
|
||||
const details = this.getNodeParameter('details', i) as string;
|
||||
const ticketType = this.getNodeParameter('ticketType', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IDataObject = {
|
||||
tickettype_id: ticketType,
|
||||
summary,
|
||||
details,
|
||||
...additionalFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/tickets',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const ticketId = this.getNodeParameter('ticketId', i) as string;
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/tickets/${ticketId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const ticketId = this.getNodeParameter('ticketId', i) as string;
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const response = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/tickets/${ticketId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const filters = this.getNodeParameter('filters', i);
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const qs: IDataObject = {};
|
||||
let response;
|
||||
|
||||
Object.assign(qs, filters, qsSetStatus(filters.activeStatus as string));
|
||||
if (returnAll) {
|
||||
response = await haloPSAApiRequestAllItems.call(
|
||||
this,
|
||||
'tickets',
|
||||
'GET',
|
||||
'/tickets',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.count = limit;
|
||||
const { tickets } = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/tickets',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
response = tickets;
|
||||
}
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'update') {
|
||||
const ticketId = this.getNodeParameter('ticketId', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDataObject = {
|
||||
id: ticketId,
|
||||
...updateFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/tickets',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'user') {
|
||||
const simplifiedOutput = [
|
||||
'id',
|
||||
'name',
|
||||
'site_id',
|
||||
'emailaddress',
|
||||
'notes',
|
||||
'surname',
|
||||
'inactive',
|
||||
];
|
||||
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('userName', i) as string;
|
||||
const siteId = this.getNodeParameter('siteId', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
site_id: siteId,
|
||||
...additionalFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/users',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const userId = this.getNodeParameter('userId', i) as string;
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/users/${userId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const userId = this.getNodeParameter('userId', i) as string;
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const response = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/users/${userId}`,
|
||||
tokens.access_token,
|
||||
);
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const filters = this.getNodeParameter('filters', i);
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const simplify = this.getNodeParameter('simplify', i) as boolean;
|
||||
const qs: IDataObject = {};
|
||||
let response;
|
||||
|
||||
Object.assign(qs, filters, qsSetStatus(filters.activeStatus as string));
|
||||
if (returnAll) {
|
||||
response = await haloPSAApiRequestAllItems.call(
|
||||
this,
|
||||
'users',
|
||||
'GET',
|
||||
'/users',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.count = limit;
|
||||
const { users } = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/users',
|
||||
tokens.access_token,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
response = users;
|
||||
}
|
||||
responseData = simplify
|
||||
? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput)
|
||||
: response;
|
||||
}
|
||||
|
||||
if (operation === 'update') {
|
||||
const userId = this.getNodeParameter('userId', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDataObject = {
|
||||
id: userId,
|
||||
...updateFields,
|
||||
};
|
||||
|
||||
responseData = await haloPSAApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/users',
|
||||
tokens.access_token,
|
||||
[body],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
const executionErrorData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ error: error.message }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionErrorData);
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accountmanagertech": {
|
||||
"type": "integer"
|
||||
},
|
||||
"actionemail": {
|
||||
"type": "integer"
|
||||
},
|
||||
"clearemail": {
|
||||
"type": "integer"
|
||||
},
|
||||
"client_to_invoice": {
|
||||
"type": "integer"
|
||||
},
|
||||
"client_to_invoice_recurring": {
|
||||
"type": "integer"
|
||||
},
|
||||
"colour": {
|
||||
"type": "string"
|
||||
},
|
||||
"confirmemail": {
|
||||
"type": "integer"
|
||||
},
|
||||
"contract_tax_code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"customer_relationship": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"customer_relationship_list": {
|
||||
"type": "string"
|
||||
},
|
||||
"customertype": {
|
||||
"type": "integer"
|
||||
},
|
||||
"default_currency_code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"default_mailbox_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"excludefrominvoicesync": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"inactive": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_account": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_vip": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"item_tax_code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"jira_validated": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"key": {
|
||||
"type": "integer"
|
||||
},
|
||||
"mailbox_override": {
|
||||
"type": "integer"
|
||||
},
|
||||
"messagegroup_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"overridepdftemplateinvoice": {
|
||||
"type": "integer"
|
||||
},
|
||||
"overridepdftemplatequote": {
|
||||
"type": "integer"
|
||||
},
|
||||
"percentage_to_survey": {
|
||||
"type": "integer"
|
||||
},
|
||||
"prepay_tax_code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pritech": {
|
||||
"type": "integer"
|
||||
},
|
||||
"qbo_company_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"sectech": {
|
||||
"type": "integer"
|
||||
},
|
||||
"service_tax_code": {
|
||||
"type": "integer"
|
||||
},
|
||||
"servicenow_validated": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"stopped": {
|
||||
"type": "integer"
|
||||
},
|
||||
"table": {
|
||||
"type": "integer"
|
||||
},
|
||||
"taxable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ticket_invoices_for_each_site": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"toplevel_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"toplevel_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"use": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 3
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agent_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"details": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string"
|
||||
},
|
||||
"targetdate": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agent_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"details": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string"
|
||||
},
|
||||
"targetdate": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 2
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"emailaddress": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"inactive": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"site_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"surname": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const clientOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a client',
|
||||
action: 'Create a client',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a client',
|
||||
action: 'Delete a client',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a client',
|
||||
action: 'Get a client',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many clients',
|
||||
action: 'Get many clients',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a client',
|
||||
action: 'Update a client',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const clientFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'clientName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['client'],
|
||||
},
|
||||
},
|
||||
description: 'Enter client name',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['client'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Account Status',
|
||||
name: 'inactive',
|
||||
type: 'options',
|
||||
default: false,
|
||||
options: [
|
||||
{
|
||||
name: 'Active',
|
||||
value: false,
|
||||
},
|
||||
{
|
||||
name: 'Inactive',
|
||||
value: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'VIP',
|
||||
name: 'is_vip',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the client is VIP or not',
|
||||
},
|
||||
{
|
||||
displayName: 'Website',
|
||||
name: 'website',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
// {
|
||||
// displayName: 'Reasign tickets before deleting',
|
||||
// name: 'reasign',
|
||||
// type: 'boolean',
|
||||
// default: false,
|
||||
// description: 'Whether tickets assigned to client sould be reasigned',
|
||||
// displayOptions: {
|
||||
// show: {
|
||||
// resource: [
|
||||
// 'client',
|
||||
// ],
|
||||
// operation: [
|
||||
// 'delete',
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
|
||||
// {
|
||||
// displayName: 'Client ID For Reasigment',
|
||||
// name: 'reasigmentCliendId',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// displayOptions: {
|
||||
// show: {
|
||||
// resource: [
|
||||
// 'client',
|
||||
// ],
|
||||
// operation: [
|
||||
// 'delete',
|
||||
// ],
|
||||
// reasign: [
|
||||
// true
|
||||
// ]
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client ID',
|
||||
name: 'clientId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
operation: ['get', 'delete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simplify',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
operation: ['get', 'getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 50,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Active Status',
|
||||
name: 'activeStatus',
|
||||
type: 'options',
|
||||
default: 'active',
|
||||
options: [
|
||||
{
|
||||
name: 'Active Only',
|
||||
value: 'active',
|
||||
description: 'Whether to include active customers in the response',
|
||||
},
|
||||
{
|
||||
name: 'All',
|
||||
value: 'all',
|
||||
description: 'Whether to include active and inactive customers in the response',
|
||||
},
|
||||
{
|
||||
name: 'Inactive Only',
|
||||
value: 'inactive',
|
||||
description: 'Whether to include inactive Customers in the response',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Text To Filter By',
|
||||
name: 'search',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filter clients by your search string',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* client:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Client ID',
|
||||
name: 'clientId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['client'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Account Status',
|
||||
name: 'inactive',
|
||||
type: 'options',
|
||||
default: false,
|
||||
options: [
|
||||
{
|
||||
name: 'Active',
|
||||
value: false,
|
||||
},
|
||||
{
|
||||
name: 'Inactive',
|
||||
value: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'VIP',
|
||||
name: 'is_vip',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the client is VIP or not',
|
||||
},
|
||||
{
|
||||
displayName: 'Website',
|
||||
name: 'website',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,316 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const siteOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a site',
|
||||
action: 'Create a site',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a site',
|
||||
action: 'Delete a site',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a site',
|
||||
action: 'Get a site',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many sites',
|
||||
action: 'Get many sites',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a site',
|
||||
action: 'Update a site',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const siteFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* site:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'siteName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description: 'Enter site name',
|
||||
},
|
||||
{
|
||||
displayName: 'Select Client by ID',
|
||||
name: 'selectOption',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether client can be selected by ID',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Client ID',
|
||||
name: 'clientId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['create'],
|
||||
selectOption: [true],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Client Name or ID',
|
||||
name: 'clientId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getHaloPSAClients',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['create'],
|
||||
selectOption: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Main Contact',
|
||||
name: 'maincontact_name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Phone Number',
|
||||
name: 'phonenumber',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* site:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Site ID',
|
||||
name: 'siteId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['delete', 'get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simplify',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['get', 'getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* site:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 50,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Active Status',
|
||||
name: 'activeStatus',
|
||||
type: 'options',
|
||||
default: 'all',
|
||||
options: [
|
||||
{
|
||||
name: 'Active Only',
|
||||
value: 'active',
|
||||
description: 'Whether to include active sites in the response',
|
||||
},
|
||||
{
|
||||
name: 'All',
|
||||
value: 'all',
|
||||
description: 'Whether to include active and inactive sites in the response',
|
||||
},
|
||||
{
|
||||
name: 'Inactive Only',
|
||||
value: 'inactive',
|
||||
description: 'Whether to include inactive sites in the response',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Text To Filter By',
|
||||
name: 'search',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filter sites by your search string',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* site:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Site ID',
|
||||
name: 'siteId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['site'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Client ID',
|
||||
name: 'client_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Main Contact',
|
||||
name: 'maincontact_name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Enter site name',
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Phone Number',
|
||||
name: 'phonenumber',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,312 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const ticketOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a ticket',
|
||||
action: 'Create a ticket',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a ticket',
|
||||
action: 'Delete a ticket',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a ticket',
|
||||
action: 'Get a ticket',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many tickets',
|
||||
action: 'Get many tickets',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a ticket',
|
||||
action: 'Update a ticket',
|
||||
},
|
||||
],
|
||||
default: 'delete',
|
||||
},
|
||||
];
|
||||
|
||||
export const ticketFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* ticket:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Ticket Type Name or ID',
|
||||
name: 'ticketType',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getHaloPSATicketsTypes',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Summary',
|
||||
name: 'summary',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assigned Agent Name or ID',
|
||||
name: 'agent_id',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getHaloPSAAgents',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Start Date',
|
||||
name: 'startdate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Target Date',
|
||||
name: 'targetdate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* site:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Ticket ID',
|
||||
name: 'ticketId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['delete', 'get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simplify',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['get', 'getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* ticket:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 50,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Active Status',
|
||||
name: 'activeStatus',
|
||||
type: 'options',
|
||||
default: 'all',
|
||||
options: [
|
||||
{
|
||||
name: 'Active Only',
|
||||
value: 'active',
|
||||
description: 'Whether to include active customers in the response',
|
||||
},
|
||||
{
|
||||
name: 'All',
|
||||
value: 'all',
|
||||
description: 'Whether to include active and inactive customers in the response',
|
||||
},
|
||||
{
|
||||
name: 'Inactive Only',
|
||||
value: 'inactive',
|
||||
description: 'Whether to include inactive Customers in the responsee',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Text To Filter By',
|
||||
name: 'search',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filter tickets by your search string',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* ticket:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Ticket ID',
|
||||
name: 'ticketId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['ticket'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assigned Agent Name or ID',
|
||||
name: 'agent_id',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getHaloPSAAgents',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Details',
|
||||
name: 'details',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Start Date',
|
||||
name: 'startdate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Summary',
|
||||
name: 'summary',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Target Date',
|
||||
name: 'targetdate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,325 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const userOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a user',
|
||||
action: 'Create a user',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a user',
|
||||
action: 'Delete a user',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a user',
|
||||
action: 'Get a user',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many users',
|
||||
action: 'Get many users',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a user',
|
||||
action: 'Update a user',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const userFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'userName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Enter user name',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Site Name or ID',
|
||||
name: 'siteId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getHaloPSASites',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'emailaddress',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Password',
|
||||
name: 'password',
|
||||
type: 'string',
|
||||
typeOptions: { password: true },
|
||||
default: '',
|
||||
description:
|
||||
'Your new password must be at least 8 characters long and contain at least one letter, one number or symbol, one upper case character and one lower case character',
|
||||
},
|
||||
{
|
||||
displayName: 'Surname',
|
||||
name: 'surname',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'User Is Inactive',
|
||||
name: 'inactive',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'User ID',
|
||||
name: 'userId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['delete', 'get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simplify',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['get', 'getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 50,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Active Status',
|
||||
name: 'activeStatus',
|
||||
type: 'options',
|
||||
default: 'all',
|
||||
options: [
|
||||
{
|
||||
name: 'Active Only',
|
||||
value: 'active',
|
||||
description: 'Whether to include active customers in the response',
|
||||
},
|
||||
{
|
||||
name: 'All',
|
||||
value: 'all',
|
||||
description: 'Whether to include active and inactive customers in the response',
|
||||
},
|
||||
{
|
||||
name: 'Inactive Only',
|
||||
value: 'inactive',
|
||||
description: 'Whether to include inactive Customers in the response',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Text To Filter By',
|
||||
name: 'search',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filter users by your search string',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'User ID',
|
||||
name: 'userId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'emailaddress',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Enter user name',
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'notes',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Password',
|
||||
name: 'password',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
password: true,
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'Your new password must be at least 8 characters long and contain at least one letter, one number or symbol, one upper case character and one lower case character',
|
||||
},
|
||||
{
|
||||
displayName: 'Site Name or ID',
|
||||
name: 'site_id',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getHaloPSASites',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Surname',
|
||||
name: 'surname',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'User Is Inactive',
|
||||
name: 'inactive',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,15 @@
|
||||
import { clientFields, clientOperations } from './ClientDescription';
|
||||
import { siteFields, siteOperations } from './SiteDescription';
|
||||
import { ticketFields, ticketOperations } from './TicketDescription';
|
||||
import { userFields, userOperations } from './UserDescription';
|
||||
|
||||
export {
|
||||
clientFields,
|
||||
clientOperations,
|
||||
siteFields,
|
||||
siteOperations,
|
||||
ticketFields,
|
||||
ticketOperations,
|
||||
userFields,
|
||||
userOperations,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 142.02 142.02"><path d="M71.01 0C31.79 0 0 31.79 0 71.01s31.79 71.01 71.01 71.01 71.01-31.79 71.01-71.01S110.23 0 71.01 0m0 107.77c-4.72 0-9.22-.89-13.37-2.49l-13.12 6.34.23-14.74c-6.72-6.72-10.87-16-10.87-26.25 0-20.51 16.62-37.13 37.13-37.13s37.13 16.62 37.13 37.13c0 20.52-16.62 37.14-37.13 37.14" style="fill:#f8384b"/></svg>
|
||||
|
After Width: | Height: | Size: 403 B |
Reference in New Issue
Block a user