n8n-nodes-cention 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/credentials/CentionApi.credentials.d.ts +11 -0
- package/dist/credentials/CentionApi.credentials.d.ts.map +1 -0
- package/dist/credentials/CentionApi.credentials.js +63 -0
- package/dist/credentials/CentionApi.credentials.js.map +1 -0
- package/dist/nodes/Cention/AgentPresenceDescription.d.ts +4 -0
- package/dist/nodes/Cention/AgentPresenceDescription.d.ts.map +1 -0
- package/dist/nodes/Cention/AgentPresenceDescription.js +90 -0
- package/dist/nodes/Cention/AgentPresenceDescription.js.map +1 -0
- package/dist/nodes/Cention/Cention.node.d.ts +7 -0
- package/dist/nodes/Cention/Cention.node.d.ts.map +1 -0
- package/dist/nodes/Cention/Cention.node.js +676 -0
- package/dist/nodes/Cention/Cention.node.js.map +1 -0
- package/dist/nodes/Cention/CentionTrigger.node.d.ts +7 -0
- package/dist/nodes/Cention/CentionTrigger.node.d.ts.map +1 -0
- package/dist/nodes/Cention/CentionTrigger.node.js +165 -0
- package/dist/nodes/Cention/CentionTrigger.node.js.map +1 -0
- package/dist/nodes/Cention/ChannelDescription.d.ts +4 -0
- package/dist/nodes/Cention/ChannelDescription.d.ts.map +1 -0
- package/dist/nodes/Cention/ChannelDescription.js +144 -0
- package/dist/nodes/Cention/ChannelDescription.js.map +1 -0
- package/dist/nodes/Cention/ChatMessageDescription.d.ts +4 -0
- package/dist/nodes/Cention/ChatMessageDescription.d.ts.map +1 -0
- package/dist/nodes/Cention/ChatMessageDescription.js +86 -0
- package/dist/nodes/Cention/ChatMessageDescription.js.map +1 -0
- package/dist/nodes/Cention/ContactCardDescription.d.ts +4 -0
- package/dist/nodes/Cention/ContactCardDescription.d.ts.map +1 -0
- package/dist/nodes/Cention/ContactCardDescription.js +446 -0
- package/dist/nodes/Cention/ContactCardDescription.js.map +1 -0
- package/dist/nodes/Cention/ErrandDescription.d.ts +4 -0
- package/dist/nodes/Cention/ErrandDescription.d.ts.map +1 -0
- package/dist/nodes/Cention/ErrandDescription.js +409 -0
- package/dist/nodes/Cention/ErrandDescription.js.map +1 -0
- package/dist/nodes/Cention/GenericFunctions.d.ts +5 -0
- package/dist/nodes/Cention/GenericFunctions.d.ts.map +1 -0
- package/dist/nodes/Cention/GenericFunctions.js +60 -0
- package/dist/nodes/Cention/GenericFunctions.js.map +1 -0
- package/dist/nodes/Cention/LibraryQuestionDescription.d.ts +4 -0
- package/dist/nodes/Cention/LibraryQuestionDescription.d.ts.map +1 -0
- package/dist/nodes/Cention/LibraryQuestionDescription.js +216 -0
- package/dist/nodes/Cention/LibraryQuestionDescription.js.map +1 -0
- package/dist/nodes/Cention/StatisticsDescription.d.ts +4 -0
- package/dist/nodes/Cention/StatisticsDescription.d.ts.map +1 -0
- package/dist/nodes/Cention/StatisticsDescription.js +169 -0
- package/dist/nodes/Cention/StatisticsDescription.js.map +1 -0
- package/dist/nodes/Cention/cention.svg +7 -0
- package/dist/nodes/Cention/logo.png +0 -0
- package/package.json +60 -0
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cention = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
const ErrandDescription_1 = require("./ErrandDescription");
|
|
7
|
+
const ContactCardDescription_1 = require("./ContactCardDescription");
|
|
8
|
+
const LibraryQuestionDescription_1 = require("./LibraryQuestionDescription");
|
|
9
|
+
const ChatMessageDescription_1 = require("./ChatMessageDescription");
|
|
10
|
+
const AgentPresenceDescription_1 = require("./AgentPresenceDescription");
|
|
11
|
+
const StatisticsDescription_1 = require("./StatisticsDescription");
|
|
12
|
+
const ChannelDescription_1 = require("./ChannelDescription");
|
|
13
|
+
class Cention {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.description = {
|
|
16
|
+
displayName: 'Cention',
|
|
17
|
+
name: 'cention',
|
|
18
|
+
icon: 'file:logo.png',
|
|
19
|
+
group: ['output'],
|
|
20
|
+
version: 1,
|
|
21
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
22
|
+
description: 'Interact with Cention API',
|
|
23
|
+
defaults: {
|
|
24
|
+
name: 'Cention',
|
|
25
|
+
},
|
|
26
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
27
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
28
|
+
credentials: [
|
|
29
|
+
{
|
|
30
|
+
name: 'centionApi',
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
properties: [
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Resource',
|
|
37
|
+
name: 'resource',
|
|
38
|
+
type: 'options',
|
|
39
|
+
noDataExpression: true,
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
name: 'Agent Presence',
|
|
43
|
+
value: 'agentPresence',
|
|
44
|
+
description: 'Manage agent availability status',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Channel',
|
|
48
|
+
value: 'channel',
|
|
49
|
+
description: 'Communication channels (Email, Chat, Social Media)',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Chat Message',
|
|
53
|
+
value: 'chatMessage',
|
|
54
|
+
description: 'Live chat session messages',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Contact Card',
|
|
58
|
+
value: 'contactCard',
|
|
59
|
+
description: 'Customer contact information',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'Errand',
|
|
63
|
+
value: 'errand',
|
|
64
|
+
description: 'Customer support tickets/cases',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Library Question',
|
|
68
|
+
value: 'libraryQuestion',
|
|
69
|
+
description: 'Knowledge base articles and FAQs',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Statistics',
|
|
73
|
+
value: 'statistics',
|
|
74
|
+
description: 'Business intelligence and reporting data',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
default: 'errand',
|
|
78
|
+
},
|
|
79
|
+
...AgentPresenceDescription_1.agentPresenceOperations,
|
|
80
|
+
...AgentPresenceDescription_1.agentPresenceFields,
|
|
81
|
+
...ChannelDescription_1.channelOperations,
|
|
82
|
+
...ChannelDescription_1.channelFields,
|
|
83
|
+
...ChatMessageDescription_1.chatMessageOperations,
|
|
84
|
+
...ChatMessageDescription_1.chatMessageFields,
|
|
85
|
+
...ContactCardDescription_1.contactCardOperations,
|
|
86
|
+
...ContactCardDescription_1.contactCardFields,
|
|
87
|
+
...ErrandDescription_1.errandOperations,
|
|
88
|
+
...ErrandDescription_1.errandFields,
|
|
89
|
+
...LibraryQuestionDescription_1.libraryQuestionOperations,
|
|
90
|
+
...LibraryQuestionDescription_1.libraryQuestionFields,
|
|
91
|
+
...StatisticsDescription_1.statisticsOperations,
|
|
92
|
+
...StatisticsDescription_1.statisticsFields,
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async execute() {
|
|
97
|
+
const items = this.getInputData();
|
|
98
|
+
const returnData = [];
|
|
99
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
100
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
101
|
+
for (let i = 0; i < items.length; i++) {
|
|
102
|
+
try {
|
|
103
|
+
if (resource === 'errand') {
|
|
104
|
+
// =====================================
|
|
105
|
+
// Errand Operations
|
|
106
|
+
// =====================================
|
|
107
|
+
if (operation === 'create') {
|
|
108
|
+
// Create Errand - Channel/Area comes from JWT token
|
|
109
|
+
const subject = this.getNodeParameter('subject', i);
|
|
110
|
+
const message = this.getNodeParameter('message', i);
|
|
111
|
+
const fromEmail = this.getNodeParameter('fromEmail', i);
|
|
112
|
+
const fromName = this.getNodeParameter('fromName', i);
|
|
113
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
114
|
+
// Generate unique message ID if not provided
|
|
115
|
+
const messageId = additionalFields.messageId ||
|
|
116
|
+
`n8n_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
117
|
+
// Build JSON:API format per Cention API spec
|
|
118
|
+
// Note: Channel and Area are determined by the JWT token
|
|
119
|
+
const msgData = {
|
|
120
|
+
message_id: messageId,
|
|
121
|
+
subject,
|
|
122
|
+
body: message,
|
|
123
|
+
from: fromEmail,
|
|
124
|
+
name: fromName,
|
|
125
|
+
};
|
|
126
|
+
// Add optional HTML body
|
|
127
|
+
if (additionalFields.htmlBody) {
|
|
128
|
+
msgData.html_body = additionalFields.htmlBody;
|
|
129
|
+
}
|
|
130
|
+
const attributes = {
|
|
131
|
+
msg: msgData,
|
|
132
|
+
};
|
|
133
|
+
// Add extra data if provided
|
|
134
|
+
if (additionalFields.extraData) {
|
|
135
|
+
attributes.extradata = additionalFields.extraData;
|
|
136
|
+
}
|
|
137
|
+
const body = {
|
|
138
|
+
data: {
|
|
139
|
+
type: 'c3_new_errands',
|
|
140
|
+
attributes,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'POST', '/c3_new_errands', body);
|
|
144
|
+
returnData.push({
|
|
145
|
+
json: responseData,
|
|
146
|
+
pairedItem: { item: i },
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else if (operation === 'get') {
|
|
150
|
+
// Get Errand
|
|
151
|
+
const errandId = this.getNodeParameter('errandId', i);
|
|
152
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', `/c3_errand_reports/${errandId}`);
|
|
153
|
+
returnData.push({
|
|
154
|
+
json: responseData,
|
|
155
|
+
pairedItem: { item: i },
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else if (operation === 'getAll') {
|
|
159
|
+
// Get All Errands
|
|
160
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
161
|
+
const filters = this.getNodeParameter('filters', i);
|
|
162
|
+
const qs = {};
|
|
163
|
+
// Required by Cention API
|
|
164
|
+
qs['filter[changed]'] = 'true';
|
|
165
|
+
if (filters.areaId) {
|
|
166
|
+
qs['filter[area]'] = filters.areaId;
|
|
167
|
+
}
|
|
168
|
+
if (filters.status) {
|
|
169
|
+
qs['filter[status]'] = filters.status;
|
|
170
|
+
}
|
|
171
|
+
if (returnAll) {
|
|
172
|
+
const responseData = await GenericFunctions_1.centionApiRequestAllItems.call(this, 'data', 'GET', '/c3_errand_reports', {}, qs);
|
|
173
|
+
for (const item of responseData) {
|
|
174
|
+
returnData.push({
|
|
175
|
+
json: item,
|
|
176
|
+
pairedItem: { item: i },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const limit = this.getNodeParameter('limit', i);
|
|
182
|
+
qs.limit = limit;
|
|
183
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', '/c3_errand_reports', {}, qs);
|
|
184
|
+
const items = responseData.data || [];
|
|
185
|
+
for (const item of items) {
|
|
186
|
+
returnData.push({
|
|
187
|
+
json: item,
|
|
188
|
+
pairedItem: { item: i },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else if (operation === 'update') {
|
|
194
|
+
// Update Errand
|
|
195
|
+
const errandId = this.getNodeParameter('errandId', i);
|
|
196
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
197
|
+
const body = {
|
|
198
|
+
data: {
|
|
199
|
+
type: 'c3_errand_reports',
|
|
200
|
+
id: errandId.toString(),
|
|
201
|
+
attributes: updateFields,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'PATCH', `/c3_errand_reports/${errandId}`, body);
|
|
205
|
+
returnData.push({
|
|
206
|
+
json: responseData,
|
|
207
|
+
pairedItem: { item: i },
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else if (operation === 'close') {
|
|
211
|
+
// Close Errand - per Cention API spec
|
|
212
|
+
const errandId = this.getNodeParameter('errandId', i);
|
|
213
|
+
const body = {
|
|
214
|
+
data: {
|
|
215
|
+
type: 'c3_end_errands',
|
|
216
|
+
attributes: {
|
|
217
|
+
errand_id: errandId,
|
|
218
|
+
answer: {
|
|
219
|
+
body: 'Closed via API',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'POST', '/c3_end_errands', body);
|
|
225
|
+
returnData.push({
|
|
226
|
+
json: responseData,
|
|
227
|
+
pairedItem: { item: i },
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
else if (operation === 'delete') {
|
|
231
|
+
// Delete Errand
|
|
232
|
+
const errandId = this.getNodeParameter('errandId', i);
|
|
233
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'DELETE', `/c3_errand_reports/${errandId}`);
|
|
234
|
+
returnData.push({
|
|
235
|
+
json: responseData || { success: true },
|
|
236
|
+
pairedItem: { item: i },
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else if (operation === 'sendMessage') {
|
|
240
|
+
// Send Message
|
|
241
|
+
const errandId = this.getNodeParameter('errandId', i);
|
|
242
|
+
const message = this.getNodeParameter('message', i);
|
|
243
|
+
const messageOptions = this.getNodeParameter('messageOptions', i);
|
|
244
|
+
const body = {
|
|
245
|
+
errandId,
|
|
246
|
+
message,
|
|
247
|
+
isInternal: messageOptions.isInternal || false,
|
|
248
|
+
};
|
|
249
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'POST', '/errand/sendErrand', body);
|
|
250
|
+
returnData.push({
|
|
251
|
+
json: responseData,
|
|
252
|
+
pairedItem: { item: i },
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else if (resource === 'contactCard') {
|
|
257
|
+
// =====================================
|
|
258
|
+
// Contact Card Operations
|
|
259
|
+
// =====================================
|
|
260
|
+
if (operation === 'create') {
|
|
261
|
+
// Create Contact Card
|
|
262
|
+
const name = this.getNodeParameter('name', i);
|
|
263
|
+
const email = this.getNodeParameter('email', i);
|
|
264
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
265
|
+
const contacts = {
|
|
266
|
+
name,
|
|
267
|
+
email: [email],
|
|
268
|
+
};
|
|
269
|
+
// Add optional fields
|
|
270
|
+
if (additionalFields.facebook) {
|
|
271
|
+
contacts.facebook = [additionalFields.facebook];
|
|
272
|
+
}
|
|
273
|
+
if (additionalFields.voice) {
|
|
274
|
+
contacts.voice = [additionalFields.voice];
|
|
275
|
+
}
|
|
276
|
+
if (additionalFields.vk) {
|
|
277
|
+
contacts.vk = [additionalFields.vk];
|
|
278
|
+
}
|
|
279
|
+
if (additionalFields.line) {
|
|
280
|
+
contacts.line = [additionalFields.line];
|
|
281
|
+
}
|
|
282
|
+
if (additionalFields.custom) {
|
|
283
|
+
const customData = additionalFields.custom;
|
|
284
|
+
if (customData.field && Array.isArray(customData.field)) {
|
|
285
|
+
contacts.custom = customData.field;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const body = {
|
|
289
|
+
data: {
|
|
290
|
+
type: 'c3_contact_cards',
|
|
291
|
+
attributes: {
|
|
292
|
+
contacts,
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'POST', '/c3_contact_cards', body);
|
|
297
|
+
returnData.push({
|
|
298
|
+
json: responseData,
|
|
299
|
+
pairedItem: { item: i },
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
else if (operation === 'update') {
|
|
303
|
+
// Update Contact Card
|
|
304
|
+
const contactCardId = this.getNodeParameter('contactCardId', i);
|
|
305
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
306
|
+
const contacts = {};
|
|
307
|
+
// Build contacts object with only provided fields
|
|
308
|
+
if (updateFields.name) {
|
|
309
|
+
contacts.name = updateFields.name;
|
|
310
|
+
}
|
|
311
|
+
if (updateFields.email) {
|
|
312
|
+
contacts.email = [updateFields.email];
|
|
313
|
+
}
|
|
314
|
+
if (updateFields.facebook) {
|
|
315
|
+
contacts.facebook = [updateFields.facebook];
|
|
316
|
+
}
|
|
317
|
+
if (updateFields.voice) {
|
|
318
|
+
contacts.voice = [updateFields.voice];
|
|
319
|
+
}
|
|
320
|
+
if (updateFields.vk) {
|
|
321
|
+
contacts.vk = [updateFields.vk];
|
|
322
|
+
}
|
|
323
|
+
if (updateFields.line) {
|
|
324
|
+
contacts.line = [updateFields.line];
|
|
325
|
+
}
|
|
326
|
+
if (updateFields.custom) {
|
|
327
|
+
const customData = updateFields.custom;
|
|
328
|
+
if (customData.field && Array.isArray(customData.field)) {
|
|
329
|
+
contacts.custom = customData.field;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const body = {
|
|
333
|
+
data: {
|
|
334
|
+
type: 'c3_contact_cards',
|
|
335
|
+
id: contactCardId.toString(),
|
|
336
|
+
attributes: {
|
|
337
|
+
contacts,
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'PATCH', `/c3_contact_cards/${contactCardId}`, body);
|
|
342
|
+
returnData.push({
|
|
343
|
+
json: responseData,
|
|
344
|
+
pairedItem: { item: i },
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
else if (operation === 'delete') {
|
|
348
|
+
// Delete Contact Card
|
|
349
|
+
const contactCardId = this.getNodeParameter('contactCardId', i);
|
|
350
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'DELETE', `/c3_contact_cards/${contactCardId}`);
|
|
351
|
+
returnData.push({
|
|
352
|
+
json: responseData || { success: true },
|
|
353
|
+
pairedItem: { item: i },
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
else if (operation === 'get') {
|
|
357
|
+
// Get Contact Card
|
|
358
|
+
const contactCardId = this.getNodeParameter('contactCardId', i);
|
|
359
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', `/c3_contact_cards/${contactCardId}`);
|
|
360
|
+
returnData.push({
|
|
361
|
+
json: responseData,
|
|
362
|
+
pairedItem: { item: i },
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
else if (operation === 'getAll') {
|
|
366
|
+
// Get All Contact Cards
|
|
367
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
368
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
369
|
+
const qs = {};
|
|
370
|
+
if (additionalFields.email) {
|
|
371
|
+
qs['filter[email]'] = additionalFields.email;
|
|
372
|
+
}
|
|
373
|
+
if (additionalFields.name) {
|
|
374
|
+
qs['filter[name]'] = additionalFields.name;
|
|
375
|
+
}
|
|
376
|
+
if (returnAll) {
|
|
377
|
+
const responseData = await GenericFunctions_1.centionApiRequestAllItems.call(this, 'data', 'GET', '/c3_contact_cards', {}, qs);
|
|
378
|
+
for (const item of responseData) {
|
|
379
|
+
returnData.push({
|
|
380
|
+
json: item,
|
|
381
|
+
pairedItem: { item: i },
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
const limit = this.getNodeParameter('limit', i);
|
|
387
|
+
qs['page[limit]'] = limit;
|
|
388
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', '/c3_contact_cards', {}, qs);
|
|
389
|
+
const items = responseData.data || [];
|
|
390
|
+
for (const item of items) {
|
|
391
|
+
returnData.push({
|
|
392
|
+
json: item,
|
|
393
|
+
pairedItem: { item: i },
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else if (operation === 'search') {
|
|
399
|
+
// Search Contact Cards
|
|
400
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
401
|
+
const query = this.getNodeParameter('query', i);
|
|
402
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
403
|
+
const qs = {};
|
|
404
|
+
// Add search query
|
|
405
|
+
if (query) {
|
|
406
|
+
qs['filter[search]'] = query;
|
|
407
|
+
}
|
|
408
|
+
// Add additional filters
|
|
409
|
+
if (additionalFields.email) {
|
|
410
|
+
qs['filter[email]'] = additionalFields.email;
|
|
411
|
+
}
|
|
412
|
+
if (additionalFields.name) {
|
|
413
|
+
qs['filter[name]'] = additionalFields.name;
|
|
414
|
+
}
|
|
415
|
+
if (returnAll) {
|
|
416
|
+
const responseData = await GenericFunctions_1.centionApiRequestAllItems.call(this, 'data', 'GET', '/c3_contact_cards', {}, qs);
|
|
417
|
+
for (const item of responseData) {
|
|
418
|
+
returnData.push({
|
|
419
|
+
json: item,
|
|
420
|
+
pairedItem: { item: i },
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
const limit = this.getNodeParameter('limit', i);
|
|
426
|
+
qs['page[limit]'] = limit;
|
|
427
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', '/c3_contact_cards', {}, qs);
|
|
428
|
+
const items = responseData.data || [];
|
|
429
|
+
for (const item of items) {
|
|
430
|
+
returnData.push({
|
|
431
|
+
json: item,
|
|
432
|
+
pairedItem: { item: i },
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else if (resource === 'libraryQuestion') {
|
|
439
|
+
// =====================================
|
|
440
|
+
// Library Question Operations
|
|
441
|
+
// =====================================
|
|
442
|
+
if (operation === 'get') {
|
|
443
|
+
// Get Library Question
|
|
444
|
+
const questionId = this.getNodeParameter('questionId', i);
|
|
445
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', `/c3_library_questions/${questionId}`);
|
|
446
|
+
returnData.push({
|
|
447
|
+
json: responseData,
|
|
448
|
+
pairedItem: { item: i },
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
else if (operation === 'getAll') {
|
|
452
|
+
// Get All Library Questions
|
|
453
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
454
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
455
|
+
const qs = {};
|
|
456
|
+
if (additionalFields.libraryId) {
|
|
457
|
+
qs['q_filter[library]'] = additionalFields.libraryId;
|
|
458
|
+
}
|
|
459
|
+
if (additionalFields.topList) {
|
|
460
|
+
qs['filter[toplist]'] = 'true';
|
|
461
|
+
}
|
|
462
|
+
if (returnAll) {
|
|
463
|
+
const responseData = await GenericFunctions_1.centionApiRequestAllItems.call(this, 'data', 'GET', '/c3_library_questions', {}, qs);
|
|
464
|
+
for (const item of responseData) {
|
|
465
|
+
returnData.push({
|
|
466
|
+
json: item,
|
|
467
|
+
pairedItem: { item: i },
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
const limit = this.getNodeParameter('limit', i);
|
|
473
|
+
qs['page[limit]'] = limit;
|
|
474
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', '/c3_library_questions', {}, qs);
|
|
475
|
+
const items = responseData.data || [];
|
|
476
|
+
for (const item of items) {
|
|
477
|
+
returnData.push({
|
|
478
|
+
json: item,
|
|
479
|
+
pairedItem: { item: i },
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
else if (operation === 'search') {
|
|
485
|
+
// Search Library Questions
|
|
486
|
+
const searchTerm = this.getNodeParameter('searchTerm', i);
|
|
487
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
488
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
489
|
+
const qs = {};
|
|
490
|
+
qs['q_filter[phrase]'] = searchTerm;
|
|
491
|
+
if (additionalFields.searchOption) {
|
|
492
|
+
qs['q_filter[option]'] = additionalFields.searchOption;
|
|
493
|
+
}
|
|
494
|
+
if (additionalFields.libraryId) {
|
|
495
|
+
qs['q_filter[library]'] = additionalFields.libraryId;
|
|
496
|
+
}
|
|
497
|
+
if (returnAll) {
|
|
498
|
+
const responseData = await GenericFunctions_1.centionApiRequestAllItems.call(this, 'data', 'GET', '/c3_library_questions', {}, qs);
|
|
499
|
+
for (const item of responseData) {
|
|
500
|
+
returnData.push({
|
|
501
|
+
json: item,
|
|
502
|
+
pairedItem: { item: i },
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
const limit = this.getNodeParameter('limit', i);
|
|
508
|
+
qs['page[limit]'] = limit;
|
|
509
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', '/c3_library_questions', {}, qs);
|
|
510
|
+
const items = responseData.data || [];
|
|
511
|
+
for (const item of items) {
|
|
512
|
+
returnData.push({
|
|
513
|
+
json: item,
|
|
514
|
+
pairedItem: { item: i },
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
else if (resource === 'chatMessage') {
|
|
521
|
+
// =====================================
|
|
522
|
+
// Chat Message Operations
|
|
523
|
+
// =====================================
|
|
524
|
+
if (operation === 'getAll') {
|
|
525
|
+
// Get Chat Messages
|
|
526
|
+
const email = this.getNodeParameter('email', i);
|
|
527
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
528
|
+
const params = {
|
|
529
|
+
email,
|
|
530
|
+
limit: additionalFields.limit || 100,
|
|
531
|
+
};
|
|
532
|
+
if (additionalFields.from) {
|
|
533
|
+
params.from = additionalFields.from;
|
|
534
|
+
}
|
|
535
|
+
if (additionalFields.to) {
|
|
536
|
+
params.to = additionalFields.to;
|
|
537
|
+
}
|
|
538
|
+
const body = {
|
|
539
|
+
data: {
|
|
540
|
+
params,
|
|
541
|
+
},
|
|
542
|
+
};
|
|
543
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'POST', '/c3_get_chat_messages', body);
|
|
544
|
+
returnData.push({
|
|
545
|
+
json: responseData,
|
|
546
|
+
pairedItem: { item: i },
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
else if (resource === 'agentPresence') {
|
|
551
|
+
// =====================================
|
|
552
|
+
// Agent Presence Operations
|
|
553
|
+
// =====================================
|
|
554
|
+
if (operation === 'set') {
|
|
555
|
+
// Set Agent Presence
|
|
556
|
+
const status = this.getNodeParameter('status', i);
|
|
557
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
558
|
+
const attributes = {
|
|
559
|
+
status,
|
|
560
|
+
};
|
|
561
|
+
if (additionalFields.message) {
|
|
562
|
+
attributes.message = additionalFields.message;
|
|
563
|
+
}
|
|
564
|
+
const body = {
|
|
565
|
+
data: {
|
|
566
|
+
type: 'c3_agent_presence',
|
|
567
|
+
attributes,
|
|
568
|
+
},
|
|
569
|
+
};
|
|
570
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'POST', '/c3_agent_presence', body);
|
|
571
|
+
returnData.push({
|
|
572
|
+
json: responseData,
|
|
573
|
+
pairedItem: { item: i },
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
else if (resource === 'statistics') {
|
|
578
|
+
// =====================================
|
|
579
|
+
// Statistics Operations
|
|
580
|
+
// =====================================
|
|
581
|
+
if (operation === 'get') {
|
|
582
|
+
// Get Statistics
|
|
583
|
+
const reportType = this.getNodeParameter('reportType', i);
|
|
584
|
+
const fromDate = this.getNodeParameter('fromDate', i);
|
|
585
|
+
const toDate = this.getNodeParameter('toDate', i);
|
|
586
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
587
|
+
const qs = {};
|
|
588
|
+
qs['filter[report_type]'] = reportType;
|
|
589
|
+
qs['filter[from]'] = fromDate;
|
|
590
|
+
qs['filter[to]'] = toDate;
|
|
591
|
+
if (additionalFields.areaId) {
|
|
592
|
+
qs['filter[area]'] = additionalFields.areaId;
|
|
593
|
+
}
|
|
594
|
+
if (additionalFields.organizationId) {
|
|
595
|
+
qs['filter[organization]'] = additionalFields.organizationId;
|
|
596
|
+
}
|
|
597
|
+
if (additionalFields.agentId) {
|
|
598
|
+
qs['filter[agent]'] = additionalFields.agentId;
|
|
599
|
+
}
|
|
600
|
+
if (additionalFields.groupBy) {
|
|
601
|
+
qs['filter[group_by]'] = additionalFields.groupBy;
|
|
602
|
+
}
|
|
603
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', '/c3_statistics', {}, qs);
|
|
604
|
+
returnData.push({
|
|
605
|
+
json: responseData,
|
|
606
|
+
pairedItem: { item: i },
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
else if (resource === 'channel') {
|
|
611
|
+
// =====================================
|
|
612
|
+
// Channel Operations
|
|
613
|
+
// =====================================
|
|
614
|
+
if (operation === 'get') {
|
|
615
|
+
// Get Channel
|
|
616
|
+
const channelId = this.getNodeParameter('channelId', i);
|
|
617
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', `/c3_channels/${channelId}`);
|
|
618
|
+
returnData.push({
|
|
619
|
+
json: responseData,
|
|
620
|
+
pairedItem: { item: i },
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
else if (operation === 'getAll') {
|
|
624
|
+
// Get All Channels
|
|
625
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
626
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
627
|
+
const qs = {};
|
|
628
|
+
if (additionalFields.type) {
|
|
629
|
+
qs['filter[type]'] = additionalFields.type;
|
|
630
|
+
}
|
|
631
|
+
if (additionalFields.activeOnly) {
|
|
632
|
+
qs['filter[active]'] = 'true';
|
|
633
|
+
}
|
|
634
|
+
if (returnAll) {
|
|
635
|
+
const responseData = await GenericFunctions_1.centionApiRequestAllItems.call(this, 'data', 'GET', '/c3_channels', {}, qs);
|
|
636
|
+
for (const item of responseData) {
|
|
637
|
+
returnData.push({
|
|
638
|
+
json: item,
|
|
639
|
+
pairedItem: { item: i },
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
const limit = this.getNodeParameter('limit', i);
|
|
645
|
+
qs['page[limit]'] = limit;
|
|
646
|
+
const responseData = await GenericFunctions_1.centionApiRequest.call(this, 'GET', '/c3_channels', {}, qs);
|
|
647
|
+
const items = responseData.data || [];
|
|
648
|
+
for (const item of items) {
|
|
649
|
+
returnData.push({
|
|
650
|
+
json: item,
|
|
651
|
+
pairedItem: { item: i },
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
catch (error) {
|
|
659
|
+
if (this.continueOnFail()) {
|
|
660
|
+
returnData.push({
|
|
661
|
+
json: {
|
|
662
|
+
error: error.message,
|
|
663
|
+
},
|
|
664
|
+
pairedItem: { item: i },
|
|
665
|
+
});
|
|
666
|
+
continue;
|
|
667
|
+
}
|
|
668
|
+
throw error;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return [returnData];
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
exports.Cention = Cention;
|
|
675
|
+
exports.default = Cention;
|
|
676
|
+
//# sourceMappingURL=Cention.node.js.map
|