@trg-admin/n8n-nodes-zoho-desk 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -76,7 +76,7 @@ class ZohoCRMDeskOAuth2Api {
|
|
|
76
76
|
displayName: 'Scope',
|
|
77
77
|
name: 'scope',
|
|
78
78
|
type: 'string',
|
|
79
|
-
default: 'ZohoCRM.modules.ALL Desk.tickets.ALL Desk.contacts.ALL Desk.search.READ',
|
|
79
|
+
default: 'ZohoCRM.modules.ALL Desk.tickets.ALL Desk.contacts.ALL Desk.search.READ Desk.tasks.ALL Desk.basic.READ',
|
|
80
80
|
required: true,
|
|
81
81
|
description: 'Space-separated OAuth scopes. Default includes both CRM and Desk permissions. Add or remove scopes as needed (e.g., Desk.settings.ALL, Desk.tasks.ALL).',
|
|
82
82
|
},
|
|
@@ -3,18 +3,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.zohoDeskApiRequest = zohoDeskApiRequest;
|
|
4
4
|
exports.zohoDeskApiRequestAllItems = zohoDeskApiRequestAllItems;
|
|
5
5
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
function getDeskBaseUrl(tokenUrl = '') {
|
|
7
|
+
if (tokenUrl.includes('zoho.com.au')) {
|
|
8
|
+
return 'https://desk.zoho.com.au';
|
|
9
|
+
}
|
|
10
|
+
if (tokenUrl.includes('zoho.eu')) {
|
|
11
|
+
return 'https://desk.zoho.eu';
|
|
12
|
+
}
|
|
13
|
+
if (tokenUrl.includes('zoho.in')) {
|
|
14
|
+
return 'https://desk.zoho.in';
|
|
15
|
+
}
|
|
16
|
+
if (tokenUrl.includes('zoho.com.cn')) {
|
|
17
|
+
return 'https://desk.zoho.com.cn';
|
|
18
|
+
}
|
|
19
|
+
return 'https://desk.zoho.com';
|
|
20
|
+
}
|
|
6
21
|
async function zohoDeskApiRequest(method, endpoint, body = {}, qs = {}, itemIndex = 0) {
|
|
7
22
|
// Get credentials with OAuth token data containing regional API domain
|
|
8
23
|
const credentials = (await this.getCredentials('zohoCRMDeskOAuth2Api'));
|
|
9
|
-
const { oauthTokenData } = credentials;
|
|
24
|
+
const { oauthTokenData, accessTokenUrl, authUrl } = credentials;
|
|
10
25
|
// Get organization ID from node parameters
|
|
11
26
|
const organizationId = this.getNodeParameter('organizationId', itemIndex);
|
|
12
27
|
// Build request options
|
|
28
|
+
const baseUrl = oauthTokenData?.api_domain || getDeskBaseUrl(accessTokenUrl || authUrl || '');
|
|
13
29
|
const options = {
|
|
14
30
|
method,
|
|
15
31
|
qs,
|
|
16
32
|
body,
|
|
17
|
-
uri: `${
|
|
33
|
+
uri: `${baseUrl}/api/v1${endpoint}`,
|
|
18
34
|
headers: {
|
|
19
35
|
orgId: organizationId,
|
|
20
36
|
'Content-Type': 'application/json',
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, ILoadOptionsFunctions } from 'n8n-workflow';
|
|
2
2
|
export declare class ZohoDesk implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getDepartments(this: ILoadOptionsFunctions): Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[]>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
4
12
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
13
|
}
|
|
@@ -12,7 +12,7 @@ class ZohoDesk {
|
|
|
12
12
|
group: ['transform'],
|
|
13
13
|
version: 1,
|
|
14
14
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
15
|
-
description: 'Zoho Desk
|
|
15
|
+
description: 'Zoho Desk node using a custom Zoho CRM & Desk OAuth2 credential for automatic refresh-token handling',
|
|
16
16
|
defaults: {
|
|
17
17
|
name: 'Zoho Desk',
|
|
18
18
|
},
|
|
@@ -120,11 +120,15 @@ class ZohoDesk {
|
|
|
120
120
|
{
|
|
121
121
|
displayName: 'Department ID',
|
|
122
122
|
name: 'departmentId',
|
|
123
|
-
type: '
|
|
123
|
+
type: 'options',
|
|
124
|
+
typeOptions: {
|
|
125
|
+
loadOptionsMethod: 'getDepartments',
|
|
126
|
+
loadOptionsDependsOn: ['organizationId'],
|
|
127
|
+
},
|
|
124
128
|
default: '',
|
|
125
129
|
required: true,
|
|
126
|
-
displayOptions: { show: { resource: ['ticket'], operation: ['create'] } },
|
|
127
|
-
description: '
|
|
130
|
+
displayOptions: { show: { resource: ['ticket'], operation: ['create', 'getAll'] } },
|
|
131
|
+
description: 'Department to assign or filter tickets by',
|
|
128
132
|
},
|
|
129
133
|
{
|
|
130
134
|
displayName: 'Description',
|
|
@@ -352,6 +356,27 @@ class ZohoDesk {
|
|
|
352
356
|
},
|
|
353
357
|
],
|
|
354
358
|
};
|
|
359
|
+
this.methods = {
|
|
360
|
+
loadOptions: {
|
|
361
|
+
async getDepartments() {
|
|
362
|
+
const organizationId = this.getNodeParameter('organizationId', 0, '');
|
|
363
|
+
if (!organizationId) {
|
|
364
|
+
return [];
|
|
365
|
+
}
|
|
366
|
+
const responseData = await GenericFunctions_1.zohoDeskApiRequestAllItems.call(this, 'GET', '/departments', {}, {}, 0);
|
|
367
|
+
return responseData.map((department) => {
|
|
368
|
+
const name = department.name ||
|
|
369
|
+
department.departmentName ||
|
|
370
|
+
department.displayName ||
|
|
371
|
+
String(department.id);
|
|
372
|
+
return {
|
|
373
|
+
name,
|
|
374
|
+
value: department.id,
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
};
|
|
355
380
|
}
|
|
356
381
|
async execute() {
|
|
357
382
|
const items = this.getInputData();
|
|
@@ -369,15 +394,16 @@ class ZohoDesk {
|
|
|
369
394
|
}
|
|
370
395
|
if (operation === 'getAll') {
|
|
371
396
|
const returnAll = this.getNodeParameter('returnAll', i, false);
|
|
397
|
+
const departmentId = this.getNodeParameter('departmentId', i);
|
|
372
398
|
if (returnAll) {
|
|
373
|
-
const responseData = await GenericFunctions_1.zohoDeskApiRequestAllItems.call(this, 'GET', '/tickets', {}, {}, i);
|
|
399
|
+
const responseData = await GenericFunctions_1.zohoDeskApiRequestAllItems.call(this, 'GET', '/tickets', {}, { departmentId }, i);
|
|
374
400
|
for (const row of responseData) {
|
|
375
401
|
returnData.push({ json: row });
|
|
376
402
|
}
|
|
377
403
|
}
|
|
378
404
|
else {
|
|
379
405
|
const limit = this.getNodeParameter('limit', i);
|
|
380
|
-
const responseData = await GenericFunctions_1.zohoDeskApiRequest.call(this, 'GET', '/tickets', {}, { limit }, i);
|
|
406
|
+
const responseData = await GenericFunctions_1.zohoDeskApiRequest.call(this, 'GET', '/tickets', {}, { limit, departmentId }, i);
|
|
381
407
|
const data = Array.isArray(responseData.data)
|
|
382
408
|
? responseData.data
|
|
383
409
|
: [responseData];
|