n8n-nodes-quepasa-api-yurisilva_pro 2.0.1

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.
Files changed (30) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +599 -0
  3. package/dist/QuePasa/quepasa.svg +4 -0
  4. package/dist/credentials/QuePasaApi.credentials.d.ts +9 -0
  5. package/dist/credentials/QuePasaApi.credentials.js +90 -0
  6. package/dist/nodes/QuePasa/QuePasa.node.d.ts +5 -0
  7. package/dist/nodes/QuePasa/QuePasa.node.js +501 -0
  8. package/dist/nodes/QuePasa/descriptions/ChatDescription.d.ts +3 -0
  9. package/dist/nodes/QuePasa/descriptions/ChatDescription.js +90 -0
  10. package/dist/nodes/QuePasa/descriptions/ContactDescription.d.ts +3 -0
  11. package/dist/nodes/QuePasa/descriptions/ContactDescription.js +103 -0
  12. package/dist/nodes/QuePasa/descriptions/GroupDescription.d.ts +3 -0
  13. package/dist/nodes/QuePasa/descriptions/GroupDescription.js +250 -0
  14. package/dist/nodes/QuePasa/descriptions/MediaDescription.d.ts +3 -0
  15. package/dist/nodes/QuePasa/descriptions/MediaDescription.js +60 -0
  16. package/dist/nodes/QuePasa/descriptions/MessageDescription.d.ts +3 -0
  17. package/dist/nodes/QuePasa/descriptions/MessageDescription.js +286 -0
  18. package/dist/nodes/QuePasa/descriptions/SessionDescription.d.ts +3 -0
  19. package/dist/nodes/QuePasa/descriptions/SessionDescription.js +103 -0
  20. package/dist/nodes/QuePasa/descriptions/StatusDescription.d.ts +3 -0
  21. package/dist/nodes/QuePasa/descriptions/StatusDescription.js +87 -0
  22. package/dist/nodes/QuePasa/descriptions/WebhookDescription.d.ts +3 -0
  23. package/dist/nodes/QuePasa/descriptions/WebhookDescription.js +89 -0
  24. package/dist/tests/GenericFunctions.spec.d.ts +1 -0
  25. package/dist/tests/GenericFunctions.spec.js +38 -0
  26. package/dist/utils/GenericFunctions.d.ts +21 -0
  27. package/dist/utils/GenericFunctions.js +77 -0
  28. package/dist/utils/Validators.d.ts +34 -0
  29. package/dist/utils/Validators.js +75 -0
  30. package/package.json +72 -0
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuePasaApi = void 0;
4
+ class QuePasaApi {
5
+ name = 'quePasaApi';
6
+ displayName = 'QuePasa API';
7
+ documentationUrl = 'https://github.com/nocodeleaks/quepasa';
8
+ properties = [
9
+ {
10
+ displayName: 'Server URL',
11
+ name: 'serverUrl',
12
+ type: 'string',
13
+ default: 'http://localhost:31000',
14
+ placeholder: 'http://localhost:31000',
15
+ description: 'QuePasa server URL',
16
+ required: true,
17
+ },
18
+ {
19
+ displayName: 'Accounts',
20
+ name: 'accounts',
21
+ type: 'fixedCollection',
22
+ typeOptions: {
23
+ multipleValues: true,
24
+ },
25
+ default: {},
26
+ placeholder: 'Add Account',
27
+ options: [
28
+ {
29
+ name: 'account',
30
+ displayName: 'Account',
31
+ values: [
32
+ {
33
+ displayName: 'Account Name',
34
+ name: 'name',
35
+ type: 'string',
36
+ default: '',
37
+ placeholder: 'Main Account',
38
+ description: 'Friendly name to identify this account',
39
+ },
40
+ {
41
+ displayName: 'Token',
42
+ name: 'token',
43
+ type: 'string',
44
+ typeOptions: {
45
+ password: true,
46
+ },
47
+ default: '',
48
+ description: 'API Token for this account',
49
+ required: true,
50
+ },
51
+ {
52
+ displayName: 'User ID',
53
+ name: 'userId',
54
+ type: 'string',
55
+ default: '',
56
+ placeholder: 'admin',
57
+ description: 'User ID for this account',
58
+ },
59
+ {
60
+ displayName: 'Phone Number',
61
+ name: 'phone',
62
+ type: 'string',
63
+ default: '',
64
+ placeholder: '5511999999999',
65
+ description: 'Phone number associated with this account',
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ },
71
+ ];
72
+ authenticate = {
73
+ type: 'generic',
74
+ properties: {
75
+ headers: {
76
+ 'X-QUEPASA-TOKEN': '={{$credentials.token}}',
77
+ },
78
+ },
79
+ };
80
+ test = {
81
+ request: {
82
+ baseURL: '={{$credentials.serverUrl}}',
83
+ url: '/info',
84
+ headers: {
85
+ 'X-QUEPASA-TOKEN': '={{$credentials.accounts?.account?.[0]?.token}}',
86
+ },
87
+ },
88
+ };
89
+ }
90
+ exports.QuePasaApi = QuePasaApi;
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class QuePasa implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,501 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuePasa = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const SessionDescription_1 = require("./descriptions/SessionDescription");
6
+ const MessageDescription_1 = require("./descriptions/MessageDescription");
7
+ const GroupDescription_1 = require("./descriptions/GroupDescription");
8
+ const ContactDescription_1 = require("./descriptions/ContactDescription");
9
+ const MediaDescription_1 = require("./descriptions/MediaDescription");
10
+ const WebhookDescription_1 = require("./descriptions/WebhookDescription");
11
+ const ChatDescription_1 = require("./descriptions/ChatDescription");
12
+ const StatusDescription_1 = require("./descriptions/StatusDescription");
13
+ const GenericFunctions_1 = require("../../utils/GenericFunctions");
14
+ class QuePasa {
15
+ description = {
16
+ displayName: 'QuePasa',
17
+ name: 'quePasa',
18
+ icon: 'file:quepasa.svg',
19
+ group: ['transform'],
20
+ version: 1,
21
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
22
+ description: 'Interact with QuePasa WhatsApp API',
23
+ defaults: {
24
+ name: 'QuePasa',
25
+ },
26
+ inputs: ['main'],
27
+ outputs: ['main'],
28
+ credentials: [
29
+ {
30
+ name: 'quePasaApi',
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: 'Chat',
43
+ value: 'chat',
44
+ },
45
+ {
46
+ name: 'Contact',
47
+ value: 'contact',
48
+ },
49
+ {
50
+ name: 'Group',
51
+ value: 'group',
52
+ },
53
+ {
54
+ name: 'Media',
55
+ value: 'media',
56
+ },
57
+ {
58
+ name: 'Message',
59
+ value: 'message',
60
+ },
61
+ {
62
+ name: 'Session',
63
+ value: 'session',
64
+ },
65
+ {
66
+ name: 'Status',
67
+ value: 'status',
68
+ },
69
+ {
70
+ name: 'Webhook',
71
+ value: 'webhook',
72
+ },
73
+ ],
74
+ default: 'session',
75
+ },
76
+ ...SessionDescription_1.sessionOperations,
77
+ ...SessionDescription_1.sessionFields,
78
+ ...MessageDescription_1.messageOperations,
79
+ ...MessageDescription_1.messageFields,
80
+ ...GroupDescription_1.groupOperations,
81
+ ...GroupDescription_1.groupFields,
82
+ ...ContactDescription_1.contactOperations,
83
+ ...ContactDescription_1.contactFields,
84
+ ...MediaDescription_1.mediaOperations,
85
+ ...MediaDescription_1.mediaFields,
86
+ ...WebhookDescription_1.webhookOperations,
87
+ ...WebhookDescription_1.webhookFields,
88
+ ...ChatDescription_1.chatOperations,
89
+ ...ChatDescription_1.chatFields,
90
+ ...StatusDescription_1.statusOperations,
91
+ ...StatusDescription_1.statusFields,
92
+ ],
93
+ };
94
+ async execute() {
95
+ const items = this.getInputData();
96
+ const returnData = [];
97
+ const resource = this.getNodeParameter('resource', 0);
98
+ const operation = this.getNodeParameter('operation', 0);
99
+ for (let i = 0; i < items.length; i++) {
100
+ try {
101
+ let responseData = {};
102
+ // ============================================
103
+ // SESSION
104
+ // ============================================
105
+ if (resource === 'session') {
106
+ if (operation === 'getQrCode') {
107
+ const userId = this.getNodeParameter('userId', i);
108
+ const token = this.getNodeParameter('token', i, '');
109
+ const returnAsImage = this.getNodeParameter('returnAsImage', i, true);
110
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/scan', {}, {}, {
111
+ headers: {
112
+ 'X-QUEPASA-USER': userId,
113
+ 'X-QUEPASA-TOKEN': token,
114
+ },
115
+ });
116
+ const executionData = {
117
+ json: responseData,
118
+ };
119
+ if (returnAsImage && responseData.qrcode) {
120
+ const base64Data = responseData.qrcode.replace(/^data:image\/png;base64,/, '');
121
+ executionData.binary = {
122
+ qrcode: await this.helpers.prepareBinaryData(Buffer.from(base64Data, 'base64'), 'qrcode.png', 'image/png'),
123
+ };
124
+ }
125
+ returnData.push(executionData);
126
+ continue;
127
+ }
128
+ else if (operation === 'checkStatus') {
129
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', '/info');
130
+ }
131
+ else if (operation === 'getInfo') {
132
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', '/info');
133
+ }
134
+ else if (operation === 'disconnect') {
135
+ const confirmation = this.getNodeParameter('confirmation', i);
136
+ if (!confirmation) {
137
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You must confirm disconnection', { itemIndex: i });
138
+ }
139
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/logout');
140
+ }
141
+ }
142
+ // ============================================
143
+ // MESSAGE
144
+ // ============================================
145
+ else if (resource === 'message') {
146
+ if (operation === 'sendText') {
147
+ const chatId = this.getNodeParameter('chatId', i);
148
+ const text = this.getNodeParameter('text', i);
149
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
150
+ const body = {
151
+ chatId: (0, GenericFunctions_1.formatPhoneNumber)(chatId),
152
+ text,
153
+ };
154
+ if (additionalOptions.trackId) {
155
+ body.trackId = additionalOptions.trackId;
156
+ }
157
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/v4/messages/send', body);
158
+ }
159
+ else if (operation === 'sendMedia') {
160
+ const chatId = this.getNodeParameter('chatId', i);
161
+ const mediaType = this.getNodeParameter('mediaType', i);
162
+ const binaryProperty = this.getNodeParameter('binaryProperty', i);
163
+ const caption = this.getNodeParameter('caption', i, '');
164
+ const binaryData = this.helpers.assertBinaryData(i, binaryProperty);
165
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty);
166
+ const base64Data = buffer.toString('base64');
167
+ const body = {
168
+ chatId: (0, GenericFunctions_1.formatPhoneNumber)(chatId),
169
+ [mediaType]: `data:${binaryData.mimeType};base64,${base64Data}`,
170
+ };
171
+ if (caption) {
172
+ body.caption = caption;
173
+ }
174
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/v4/messages/send', body);
175
+ }
176
+ else if (operation === 'sendFromUrl') {
177
+ const chatId = this.getNodeParameter('chatId', i);
178
+ const url = this.getNodeParameter('url', i);
179
+ const caption = this.getNodeParameter('caption', i, '');
180
+ const filename = this.getNodeParameter('filename', i, '');
181
+ const body = {
182
+ chatId: (0, GenericFunctions_1.formatPhoneNumber)(chatId),
183
+ url,
184
+ };
185
+ if (caption) {
186
+ body.caption = caption;
187
+ }
188
+ if (filename) {
189
+ body.filename = filename;
190
+ }
191
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/v4/messages/send', body);
192
+ }
193
+ else if (operation === 'revokeMessage') {
194
+ const messageId = this.getNodeParameter('messageId', i);
195
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'DELETE', `/v4/messages/${messageId}`);
196
+ }
197
+ else if (operation === 'reactToMessage') {
198
+ const messageId = this.getNodeParameter('messageId', i);
199
+ const emoji = this.getNodeParameter('emoji', i);
200
+ const body = {
201
+ emoji,
202
+ };
203
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/messages/${messageId}/react`, body);
204
+ }
205
+ else if (operation === 'forwardMessage') {
206
+ const messageId = this.getNodeParameter('messageId', i);
207
+ const toChatId = this.getNodeParameter('toChatId', i);
208
+ const body = {
209
+ to: (0, GenericFunctions_1.formatPhoneNumber)(toChatId),
210
+ };
211
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/messages/${messageId}/forward`, body);
212
+ }
213
+ else if (operation === 'getHistory') {
214
+ const chatId = this.getNodeParameter('chatId', i);
215
+ const limit = this.getNodeParameter('limit', i, 50);
216
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/v4/chats/${(0, GenericFunctions_1.formatPhoneNumber)(chatId)}/messages`, {}, { limit: Math.min(limit, 100) });
217
+ }
218
+ }
219
+ // ============================================
220
+ // GROUP
221
+ // ============================================
222
+ else if (resource === 'group') {
223
+ if (operation === 'listGroups') {
224
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', '/groups');
225
+ }
226
+ else if (operation === 'getGroupInfo') {
227
+ const groupId = this.getNodeParameter('groupId', i);
228
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/groups/${groupId}`);
229
+ }
230
+ else if (operation === 'createGroup') {
231
+ const name = this.getNodeParameter('name', i);
232
+ const participantsStr = this.getNodeParameter('participants', i);
233
+ const topic = this.getNodeParameter('topic', i, '');
234
+ const participants = participantsStr
235
+ .split(',')
236
+ .map(p => (0, GenericFunctions_1.formatPhoneNumber)(p.trim()))
237
+ .filter(p => p);
238
+ const body = {
239
+ title: name,
240
+ participants,
241
+ };
242
+ if (topic) {
243
+ body.topic = topic;
244
+ }
245
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/groups', body);
246
+ }
247
+ else if (operation === 'updateName') {
248
+ const groupId = this.getNodeParameter('groupId', i);
249
+ const name = this.getNodeParameter('name', i);
250
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'PUT', `/groups/${groupId}/name`, { name });
251
+ }
252
+ else if (operation === 'addParticipants') {
253
+ const groupId = this.getNodeParameter('groupId', i);
254
+ const participantsStr = this.getNodeParameter('participants', i);
255
+ const participants = participantsStr
256
+ .split(',')
257
+ .map(p => (0, GenericFunctions_1.formatPhoneNumber)(p.trim()))
258
+ .filter(p => p);
259
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/groups/${groupId}/participants`, { participants });
260
+ }
261
+ else if (operation === 'removeParticipant') {
262
+ const groupId = this.getNodeParameter('groupId', i);
263
+ const participantId = this.getNodeParameter('participantId', i);
264
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'DELETE', `/groups/${groupId}/participants/${participantId}`);
265
+ }
266
+ else if (operation === 'leaveGroup') {
267
+ const groupId = this.getNodeParameter('groupId', i);
268
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/groups/${groupId}/leave`);
269
+ }
270
+ else if (operation === 'updateDescription') {
271
+ const groupId = this.getNodeParameter('groupId', i);
272
+ const description = this.getNodeParameter('description', i);
273
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'PUT', `/groups/${groupId}/description`, { description });
274
+ }
275
+ else if (operation === 'updatePicture') {
276
+ const groupId = this.getNodeParameter('groupId', i);
277
+ const binaryProperty = this.getNodeParameter('binaryProperty', i);
278
+ const binaryData = this.helpers.assertBinaryData(i, binaryProperty);
279
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty);
280
+ const base64Data = buffer.toString('base64');
281
+ const body = {
282
+ picture: `data:${binaryData.mimeType};base64,${base64Data}`,
283
+ };
284
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'PUT', `/groups/${groupId}/picture`, body);
285
+ }
286
+ else if (operation === 'removePicture') {
287
+ const groupId = this.getNodeParameter('groupId', i);
288
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'DELETE', `/groups/${groupId}/picture`);
289
+ }
290
+ else if (operation === 'promoteToAdmin') {
291
+ const groupId = this.getNodeParameter('groupId', i);
292
+ const participantId = this.getNodeParameter('participantId', i);
293
+ const body = {
294
+ participants: [(0, GenericFunctions_1.formatPhoneNumber)(participantId)],
295
+ };
296
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/groups/${groupId}/admins`, body);
297
+ }
298
+ else if (operation === 'demoteFromAdmin') {
299
+ const groupId = this.getNodeParameter('groupId', i);
300
+ const participantId = this.getNodeParameter('participantId', i);
301
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'DELETE', `/groups/${groupId}/admins/${participantId}`);
302
+ }
303
+ else if (operation === 'getInviteLink') {
304
+ const groupId = this.getNodeParameter('groupId', i);
305
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/groups/${groupId}/invite`);
306
+ }
307
+ else if (operation === 'revokeInviteLink') {
308
+ const groupId = this.getNodeParameter('groupId', i);
309
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/groups/${groupId}/invite/revoke`);
310
+ }
311
+ else if (operation === 'joinViaInvite') {
312
+ const inviteCode = this.getNodeParameter('inviteCode', i);
313
+ const body = {
314
+ code: inviteCode,
315
+ };
316
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/groups/join', body);
317
+ }
318
+ }
319
+ // ============================================
320
+ // CONTACT
321
+ // ============================================
322
+ else if (resource === 'contact') {
323
+ if (operation === 'listContacts') {
324
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', '/contacts');
325
+ }
326
+ else if (operation === 'getContactInfo') {
327
+ const contactId = this.getNodeParameter('contactId', i);
328
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/contacts/${contactId}`);
329
+ }
330
+ else if (operation === 'checkWhatsApp') {
331
+ const phonesStr = this.getNodeParameter('phones', i);
332
+ const phones = phonesStr
333
+ .split(',')
334
+ .map(p => p.trim().replace(/\D/g, ''))
335
+ .filter(p => p);
336
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/v4/contacts/check', { phones });
337
+ }
338
+ else if (operation === 'getPicture') {
339
+ const contactId = this.getNodeParameter('contactId', i);
340
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i, 'data');
341
+ const response = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/v4/contacts/${contactId}/picture`, {}, {}, { returnFullResponse: true, encoding: null });
342
+ const executionData = {
343
+ json: { contactId, success: true },
344
+ binary: {
345
+ [binaryPropertyName]: await this.helpers.prepareBinaryData(response.body, `profile_${contactId}.jpg`, response.headers['content-type']),
346
+ },
347
+ };
348
+ returnData.push(executionData);
349
+ continue;
350
+ }
351
+ else if (operation === 'blockContact') {
352
+ const contactId = this.getNodeParameter('contactId', i);
353
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/contacts/${contactId}/block`);
354
+ }
355
+ else if (operation === 'unblockContact') {
356
+ const contactId = this.getNodeParameter('contactId', i);
357
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/contacts/${contactId}/unblock`);
358
+ }
359
+ }
360
+ // ============================================
361
+ // MEDIA
362
+ // ============================================
363
+ else if (resource === 'media') {
364
+ if (operation === 'downloadMedia') {
365
+ const messageId = this.getNodeParameter('messageId', i);
366
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i, 'data');
367
+ const response = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/v4/messages/${messageId}/download`, {}, {}, { returnFullResponse: true, encoding: null });
368
+ const executionData = {
369
+ json: { messageId, success: true },
370
+ binary: {
371
+ [binaryPropertyName]: await this.helpers.prepareBinaryData(response.body, `media_${messageId}`, response.headers['content-type']),
372
+ },
373
+ };
374
+ returnData.push(executionData);
375
+ continue;
376
+ }
377
+ else if (operation === 'downloadAsBase64') {
378
+ const messageId = this.getNodeParameter('messageId', i);
379
+ const response = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/v4/messages/${messageId}/download`, {}, {}, { returnFullResponse: true, encoding: null });
380
+ const base64Data = response.body.toString('base64');
381
+ const mimeType = response.headers['content-type'];
382
+ responseData = {
383
+ messageId,
384
+ base64: `data:${mimeType};base64,${base64Data}`,
385
+ mimeType,
386
+ };
387
+ }
388
+ }
389
+ // ============================================
390
+ // WEBHOOK
391
+ // ============================================
392
+ else if (resource === 'webhook') {
393
+ if (operation === 'setWebhook') {
394
+ const url = this.getNodeParameter('url', i);
395
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
396
+ const body = { url };
397
+ if (additionalOptions.forwardinternal !== undefined) {
398
+ body.forwardinternal = additionalOptions.forwardinternal;
399
+ }
400
+ if (additionalOptions.trackid) {
401
+ body.trackid = additionalOptions.trackid;
402
+ }
403
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/webhook', body);
404
+ }
405
+ else if (operation === 'getWebhook') {
406
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', '/webhook');
407
+ }
408
+ else if (operation === 'deleteWebhook') {
409
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'DELETE', '/webhook');
410
+ }
411
+ else if (operation === 'updateWebhook') {
412
+ const url = this.getNodeParameter('url', i);
413
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
414
+ const body = { url };
415
+ if (additionalOptions.forwardinternal !== undefined) {
416
+ body.forwardinternal = additionalOptions.forwardinternal;
417
+ }
418
+ if (additionalOptions.trackid) {
419
+ body.trackid = additionalOptions.trackid;
420
+ }
421
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'PUT', '/webhook', body);
422
+ }
423
+ }
424
+ // ============================================
425
+ // CHAT
426
+ // ============================================
427
+ else if (resource === 'chat') {
428
+ if (operation === 'markAsRead') {
429
+ const chatId = this.getNodeParameter('chatId', i);
430
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/chats/${chatId}/markasread`);
431
+ }
432
+ else if (operation === 'archiveChat') {
433
+ const chatId = this.getNodeParameter('chatId', i);
434
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/chats/${chatId}/archive`);
435
+ }
436
+ else if (operation === 'unarchiveChat') {
437
+ const chatId = this.getNodeParameter('chatId', i);
438
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/chats/${chatId}/unarchive`);
439
+ }
440
+ else if (operation === 'pinChat') {
441
+ const chatId = this.getNodeParameter('chatId', i);
442
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/chats/${chatId}/pin`);
443
+ }
444
+ else if (operation === 'unpinChat') {
445
+ const chatId = this.getNodeParameter('chatId', i);
446
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/chats/${chatId}/unpin`);
447
+ }
448
+ else if (operation === 'muteChat') {
449
+ const chatId = this.getNodeParameter('chatId', i);
450
+ const duration = this.getNodeParameter('duration', i, 28800);
451
+ const body = {
452
+ duration,
453
+ };
454
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/chats/${chatId}/mute`, body);
455
+ }
456
+ else if (operation === 'unmuteChat') {
457
+ const chatId = this.getNodeParameter('chatId', i);
458
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', `/v4/chats/${chatId}/unmute`);
459
+ }
460
+ }
461
+ // ============================================
462
+ // STATUS
463
+ // ============================================
464
+ else if (resource === 'status') {
465
+ if (operation === 'updatePresence') {
466
+ const presence = this.getNodeParameter('presence', i);
467
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/v4/presence', { presence });
468
+ }
469
+ else if (operation === 'updateStatus') {
470
+ const statusText = this.getNodeParameter('statusText', i);
471
+ const body = {
472
+ status: statusText,
473
+ };
474
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'POST', '/v4/status', body);
475
+ }
476
+ else if (operation === 'getContactStatus') {
477
+ const contactId = this.getNodeParameter('contactId', i);
478
+ responseData = await GenericFunctions_1.quePasaApiRequest.call(this, 'GET', `/v4/contacts/${contactId}/status`);
479
+ }
480
+ }
481
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
482
+ returnData.push(...executionData);
483
+ }
484
+ catch (error) {
485
+ if (this.continueOnFail()) {
486
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
487
+ returnData.push({
488
+ json: {
489
+ error: errorMessage,
490
+ },
491
+ pairedItem: { item: i },
492
+ });
493
+ continue;
494
+ }
495
+ throw error;
496
+ }
497
+ }
498
+ return [returnData];
499
+ }
500
+ }
501
+ exports.QuePasa = QuePasa;
@@ -0,0 +1,3 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const chatOperations: INodeProperties[];
3
+ export declare const chatFields: INodeProperties[];