n8n-nodes-linq 0.1.6 → 0.1.7

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Linq = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
4
5
  class Linq {
5
6
  constructor() {
6
7
  this.description = {
@@ -31,182 +32,182 @@ class Linq {
31
32
  ],
32
33
  default: 'chat',
33
34
  },
34
- // Chat operations
35
35
  {
36
36
  displayName: 'Operation',
37
37
  name: 'operation',
38
38
  type: 'options',
39
39
  noDataExpression: true,
40
- displayOptions: { show: { resource: ['chat'] } },
41
40
  options: [
41
+ // Phone Number Operations (Check iMessage Availability comes first alphabetically)
42
42
  {
43
- name: 'Create',
44
- value: 'create',
45
- action: 'Create a chat'
43
+ name: 'Check iMessage Availability',
44
+ value: 'phoneNumberCheckIMessageAvailability',
45
+ action: 'Check imessage availability',
46
+ displayOptions: { show: { resource: ['phoneNumber'] } },
46
47
  },
48
+ // Chat Operations
47
49
  {
48
- name: 'Find',
49
- value: 'find',
50
- action: 'Find chats'
50
+ name: 'Create Chat',
51
+ value: 'chatCreate',
52
+ action: 'Create a chat',
53
+ displayOptions: { show: { resource: ['chat'] } },
51
54
  },
55
+ // Chat Message Operations
52
56
  {
53
- name: 'Get Many',
54
- value: 'getAll',
55
- action: 'Get many chats'
57
+ name: 'Create Chat Message',
58
+ value: 'chatMessageCreate',
59
+ action: 'Create a chat message',
60
+ displayOptions: { show: { resource: ['chatMessage'] } },
56
61
  },
62
+ // Contact Operations
57
63
  {
58
- name: 'Get One',
59
- value: 'getOne',
60
- action: 'Get one chat'
64
+ name: 'Create Contact',
65
+ value: 'contactCreate',
66
+ action: 'Create a contact',
67
+ displayOptions: { show: { resource: ['contact'] } },
61
68
  },
69
+ // Webhook Subscription Operations
62
70
  {
63
- name: 'Share Contact',
64
- value: 'shareContact',
65
- action: 'Share a contact'
71
+ name: 'Create Webhook Subscription',
72
+ value: 'webhookSubscriptionCreate',
73
+ action: 'Create a webhook subscription',
74
+ displayOptions: { show: { resource: ['webhookSubscription'] } },
66
75
  },
67
- ],
68
- default: 'getAll',
69
- },
70
- // Chat Message operations
71
- {
72
- displayName: 'Operation',
73
- name: 'operation',
74
- type: 'options',
75
- noDataExpression: true,
76
- displayOptions: { show: { resource: ['chatMessage'] } },
77
- options: [
76
+ // Chat Message Operations (Delete)
78
77
  {
79
- name: 'Create',
80
- value: 'create',
81
- action: 'Create a chat message'
78
+ name: 'Delete Chat Message',
79
+ value: 'chatMessageDelete',
80
+ action: 'Delete a chat message',
81
+ displayOptions: { show: { resource: ['chatMessage'] } },
82
82
  },
83
+ // Contact Operations (Delete)
83
84
  {
84
- name: 'Delete',
85
- value: 'delete',
86
- action: 'Delete a chat message'
85
+ name: 'Delete Contact',
86
+ value: 'contactDelete',
87
+ action: 'Delete a contact',
88
+ displayOptions: { show: { resource: ['contact'] } },
87
89
  },
90
+ // Webhook Subscription Operations (Delete)
88
91
  {
89
- name: 'Edit',
90
- value: 'edit',
91
- action: 'Edit a chat message'
92
+ name: 'Delete Webhook Subscription',
93
+ value: 'webhookSubscriptionDelete',
94
+ action: 'Delete a webhook subscription',
95
+ displayOptions: { show: { resource: ['webhookSubscription'] } },
92
96
  },
97
+ // Chat Message Operations (Edit)
93
98
  {
94
- name: 'Get Many',
95
- value: 'getAll',
96
- action: 'Get many chat messages'
99
+ name: 'Edit Chat Message',
100
+ value: 'chatMessageEdit',
101
+ action: 'Edit a chat message',
102
+ displayOptions: { show: { resource: ['chatMessage'] } },
97
103
  },
104
+ // Chat Operations (Find)
98
105
  {
99
- name: 'Get One',
100
- value: 'getOne',
101
- action: 'Get one chat message'
106
+ name: 'Find Chat',
107
+ value: 'chatFind',
108
+ action: 'Find chats',
109
+ displayOptions: { show: { resource: ['chat'] } },
102
110
  },
111
+ // Chat Message Operations (Get Many)
103
112
  {
104
- name: 'Get Reaction',
105
- value: 'getReaction',
106
- action: 'Get a chat message reaction'
113
+ name: 'Get Many Chat Messages',
114
+ value: 'chatMessageGetAll',
115
+ action: 'Get many chat messages',
116
+ displayOptions: { show: { resource: ['chatMessage'] } },
107
117
  },
118
+ // Chat Operations (Get Many)
108
119
  {
109
- name: 'React',
110
- value: 'react',
111
- action: 'React to a chat message'
120
+ name: 'Get Many Chats',
121
+ value: 'chatGetAll',
122
+ action: 'Get many chats',
123
+ displayOptions: { show: { resource: ['chat'] } },
112
124
  },
113
- ],
114
- default: 'getAll',
115
- },
116
- // Phone Number operations
117
- {
118
- displayName: 'Operation',
119
- name: 'operation',
120
- type: 'options',
121
- noDataExpression: true,
122
- displayOptions: { show: { resource: ['phoneNumber'] } },
123
- options: [
125
+ // Phone Number Operations (Get Many)
124
126
  {
125
- name: 'Check iMessage Availability',
126
- value: 'checkIMessageAvailability',
127
- action: 'Check imessage availability'
127
+ name: 'Get Many Phone Numbers',
128
+ value: 'phoneNumberGetAll',
129
+ action: 'Get many phone numbers',
130
+ displayOptions: { show: { resource: ['phoneNumber'] } },
128
131
  },
132
+ // Webhook Subscription Operations (Get Many)
129
133
  {
130
- name: 'Get Many',
131
- value: 'getAll',
132
- action: 'Get many phone numbers'
134
+ name: 'Get Many Webhook Subscriptions',
135
+ value: 'webhookSubscriptionGetAll',
136
+ action: 'Get many webhook subscriptions',
137
+ displayOptions: { show: { resource: ['webhookSubscription'] } },
133
138
  },
134
- ],
135
- default: 'getAll',
136
- },
137
- // Webhook Subscription operations
138
- {
139
- displayName: 'Operation',
140
- name: 'operation',
141
- type: 'options',
142
- noDataExpression: true,
143
- displayOptions: { show: { resource: ['webhookSubscription'] } },
144
- options: [
139
+ // Chat Operations (Get One)
145
140
  {
146
- name: 'Create',
147
- value: 'create',
148
- action: 'Create a webhook subscription'
141
+ name: 'Get One Chat',
142
+ value: 'chatGetOne',
143
+ action: 'Get one chat',
144
+ displayOptions: { show: { resource: ['chat'] } },
149
145
  },
146
+ // Chat Message Operations (Get One)
150
147
  {
151
- name: 'Delete',
152
- value: 'delete',
153
- action: 'Delete a webhook subscription'
148
+ name: 'Get One Chat Message',
149
+ value: 'chatMessageGetOne',
150
+ action: 'Get one chat message',
151
+ displayOptions: { show: { resource: ['chatMessage'] } },
154
152
  },
153
+ // Contact Operations (Get One)
155
154
  {
156
- name: 'Get Many',
157
- value: 'getAll',
158
- action: 'Get many webhook subscriptions'
155
+ name: 'Get One Contact',
156
+ value: 'contactGetOne',
157
+ action: 'Get one contact',
158
+ displayOptions: { show: { resource: ['contact'] } },
159
159
  },
160
+ // Webhook Subscription Operations (Get One)
160
161
  {
161
- name: 'Get One',
162
- value: 'getOne',
163
- action: 'Get one webhook subscription'
162
+ name: 'Get One Webhook Subscription',
163
+ value: 'webhookSubscriptionGetOne',
164
+ action: 'Get one webhook subscription',
165
+ displayOptions: { show: { resource: ['webhookSubscription'] } },
164
166
  },
167
+ // Chat Message Operations (Get Reaction)
165
168
  {
166
- name: 'Update',
167
- value: 'update',
168
- action: 'Update a webhook subscription'
169
+ name: 'Get Reaction',
170
+ value: 'chatMessageGetReaction',
171
+ action: 'Get a chat message reaction',
172
+ displayOptions: { show: { resource: ['chatMessage'] } },
169
173
  },
170
- ],
171
- default: 'getAll',
172
- },
173
- // Contact operations
174
- {
175
- displayName: 'Operation',
176
- name: 'operation',
177
- type: 'options',
178
- noDataExpression: true,
179
- displayOptions: { show: { resource: ['contact'] } },
180
- options: [
174
+ // Chat Message Operations (React)
181
175
  {
182
- name: 'Create',
183
- value: 'create',
184
- action: 'Create a contact'
176
+ name: 'React',
177
+ value: 'chatMessageReact',
178
+ action: 'React to a chat message',
179
+ displayOptions: { show: { resource: ['chatMessage'] } },
185
180
  },
181
+ // Chat Operations (Share Contact)
186
182
  {
187
- name: 'Delete',
188
- value: 'delete',
189
- action: 'Delete a contact'
183
+ name: 'Share Contact',
184
+ value: 'chatShareContact',
185
+ action: 'Share a contact',
186
+ displayOptions: { show: { resource: ['chat'] } },
190
187
  },
188
+ // Contact Operations (Update)
191
189
  {
192
- name: 'Get One',
193
- value: 'getOne',
194
- action: 'Get one contact'
190
+ name: 'Update Contact',
191
+ value: 'contactUpdate',
192
+ action: 'Update a contact',
193
+ displayOptions: { show: { resource: ['contact'] } },
195
194
  },
195
+ // Webhook Subscription Operations (Update)
196
196
  {
197
- name: 'Update',
198
- value: 'update',
199
- action: 'Update a contact'
197
+ name: 'Update Webhook Subscription',
198
+ value: 'webhookSubscriptionUpdate',
199
+ action: 'Update a webhook subscription',
200
+ displayOptions: { show: { resource: ['webhookSubscription'] } },
200
201
  },
201
202
  ],
202
- default: 'create',
203
+ default: 'chatGetAll',
203
204
  },
204
205
  // Chat parameters
205
206
  {
206
207
  displayName: 'Chat ID',
207
208
  name: 'chatId',
208
209
  type: 'string',
209
- displayOptions: { show: { resource: ['chat'], operation: ['getOne'] } },
210
+ displayOptions: { show: { resource: ['chat'], operation: ['chatGetOne'] } },
210
211
  default: '',
211
212
  description: 'The ID of the chat to retrieve',
212
213
  },
@@ -214,7 +215,7 @@ class Linq {
214
215
  displayName: 'Phone Number',
215
216
  name: 'phoneNumber',
216
217
  type: 'string',
217
- displayOptions: { show: { resource: ['chat'], operation: ['getAll'] } },
218
+ displayOptions: { show: { resource: ['chat'], operation: ['chatGetAll'] } },
218
219
  default: '',
219
220
  description: 'Filter chats by phone number',
220
221
  },
@@ -222,7 +223,7 @@ class Linq {
222
223
  displayName: 'Page',
223
224
  name: 'page',
224
225
  type: 'number',
225
- displayOptions: { show: { resource: ['chat'], operation: ['getAll'] } },
226
+ displayOptions: { show: { resource: ['chat'], operation: ['chatGetAll'] } },
226
227
  default: 1,
227
228
  description: 'Page number for pagination',
228
229
  },
@@ -230,7 +231,7 @@ class Linq {
230
231
  displayName: 'Per Page',
231
232
  name: 'perPage',
232
233
  type: 'number',
233
- displayOptions: { show: { resource: ['chat'], operation: ['getAll'] } },
234
+ displayOptions: { show: { resource: ['chat'], operation: ['chatGetAll'] } },
234
235
  default: 25,
235
236
  description: 'Number of items per page',
236
237
  },
@@ -239,7 +240,7 @@ class Linq {
239
240
  displayName: 'Send From',
240
241
  name: 'sendFrom',
241
242
  type: 'string',
242
- displayOptions: { show: { resource: ['chat'], operation: ['create'] } },
243
+ displayOptions: { show: { resource: ['chat'], operation: ['chatCreate'] } },
243
244
  default: '',
244
245
  description: 'The phone number to send from',
245
246
  },
@@ -247,7 +248,7 @@ class Linq {
247
248
  displayName: 'Display Name',
248
249
  name: 'displayName',
249
250
  type: 'string',
250
- displayOptions: { show: { resource: ['chat'], operation: ['create'] } },
251
+ displayOptions: { show: { resource: ['chat'], operation: ['chatCreate'] } },
251
252
  default: '',
252
253
  description: 'The display name for the chat',
253
254
  },
@@ -255,7 +256,7 @@ class Linq {
255
256
  displayName: 'Phone Numbers',
256
257
  name: 'phoneNumbers',
257
258
  type: 'string',
258
- displayOptions: { show: { resource: ['chat'], operation: ['create'] } },
259
+ displayOptions: { show: { resource: ['chat'], operation: ['chatCreate'] } },
259
260
  default: '',
260
261
  description: 'Comma-separated list of phone numbers',
261
262
  },
@@ -263,7 +264,7 @@ class Linq {
263
264
  displayName: 'Message Text',
264
265
  name: 'messageText',
265
266
  type: 'string',
266
- displayOptions: { show: { resource: ['chat'], operation: ['create'] } },
267
+ displayOptions: { show: { resource: ['chat'], operation: ['chatCreate'] } },
267
268
  default: '',
268
269
  description: 'The text of the message to send',
269
270
  },
@@ -272,7 +273,7 @@ class Linq {
272
273
  displayName: 'Chat Message ID',
273
274
  name: 'chatMessageId',
274
275
  type: 'string',
275
- displayOptions: { show: { resource: ['chatMessage'], operation: ['getOne', 'delete', 'edit', 'react', 'getReaction'] } },
276
+ displayOptions: { show: { resource: ['chatMessage'], operation: ['chatMessageGetOne', 'chatMessageDelete', 'chatMessageEdit', 'chatMessageReact', 'chatMessageGetReaction'] } },
276
277
  default: '',
277
278
  description: 'The ID of the chat message',
278
279
  },
@@ -280,7 +281,7 @@ class Linq {
280
281
  displayName: 'Chat ID',
281
282
  name: 'chatId',
282
283
  type: 'string',
283
- displayOptions: { show: { resource: ['chatMessage'], operation: ['getAll', 'create'] } },
284
+ displayOptions: { show: { resource: ['chatMessage'], operation: ['chatMessageGetAll', 'chatMessageCreate'] } },
284
285
  default: '',
285
286
  description: 'The ID of the chat',
286
287
  },
@@ -288,7 +289,7 @@ class Linq {
288
289
  displayName: 'Message Text',
289
290
  name: 'messageText',
290
291
  type: 'string',
291
- displayOptions: { show: { resource: ['chatMessage'], operation: ['create', 'edit'] } },
292
+ displayOptions: { show: { resource: ['chatMessage'], operation: ['chatMessageCreate', 'chatMessageEdit'] } },
292
293
  default: '',
293
294
  description: 'The text of the message',
294
295
  },
@@ -296,7 +297,7 @@ class Linq {
296
297
  displayName: 'Reaction',
297
298
  name: 'reaction',
298
299
  type: 'string',
299
- displayOptions: { show: { resource: ['chatMessage'], operation: ['react'] } },
300
+ displayOptions: { show: { resource: ['chatMessage'], operation: ['chatMessageReact'] } },
300
301
  default: '',
301
302
  description: 'The reaction to add',
302
303
  },
@@ -305,7 +306,7 @@ class Linq {
305
306
  displayName: 'Phone Number',
306
307
  name: 'phoneNumber',
307
308
  type: 'string',
308
- displayOptions: { show: { resource: ['phoneNumber'], operation: ['checkIMessageAvailability'] } },
309
+ displayOptions: { show: { resource: ['phoneNumber'], operation: ['phoneNumberCheckIMessageAvailability'] } },
309
310
  default: '',
310
311
  description: 'The phone number to check',
311
312
  },
@@ -314,7 +315,7 @@ class Linq {
314
315
  displayName: 'Webhook Subscription ID',
315
316
  name: 'webhookSubscriptionId',
316
317
  type: 'string',
317
- displayOptions: { show: { resource: ['webhookSubscription'], operation: ['getOne', 'update', 'delete'] } },
318
+ displayOptions: { show: { resource: ['webhookSubscription'], operation: ['webhookSubscriptionGetOne', 'webhookSubscriptionUpdate', 'webhookSubscriptionDelete'] } },
318
319
  default: '',
319
320
  description: 'The ID of the webhook subscription',
320
321
  },
@@ -322,7 +323,7 @@ class Linq {
322
323
  displayName: 'Webhook URL',
323
324
  name: 'webhookUrl',
324
325
  type: 'string',
325
- displayOptions: { show: { resource: ['webhookSubscription'], operation: ['create', 'update'] } },
326
+ displayOptions: { show: { resource: ['webhookSubscription'], operation: ['webhookSubscriptionCreate', 'webhookSubscriptionUpdate'] } },
326
327
  default: '',
327
328
  description: 'The URL for the webhook',
328
329
  },
@@ -330,7 +331,7 @@ class Linq {
330
331
  displayName: 'Events',
331
332
  name: 'events',
332
333
  type: 'string',
333
- displayOptions: { show: { resource: ['webhookSubscription'], operation: ['create', 'update'] } },
334
+ displayOptions: { show: { resource: ['webhookSubscription'], operation: ['webhookSubscriptionCreate', 'webhookSubscriptionUpdate'] } },
334
335
  default: '',
335
336
  description: 'Comma-separated list of events',
336
337
  },
@@ -338,7 +339,7 @@ class Linq {
338
339
  displayName: 'Version',
339
340
  name: 'version',
340
341
  type: 'number',
341
- displayOptions: { show: { resource: ['webhookSubscription'], operation: ['create', 'update'] } },
342
+ displayOptions: { show: { resource: ['webhookSubscription'], operation: ['webhookSubscriptionCreate', 'webhookSubscriptionUpdate'] } },
342
343
  default: 2,
343
344
  description: 'The version of the webhook',
344
345
  },
@@ -346,7 +347,7 @@ class Linq {
346
347
  displayName: 'Active',
347
348
  name: 'active',
348
349
  type: 'boolean',
349
- displayOptions: { show: { resource: ['webhookSubscription'], operation: ['create', 'update'] } },
350
+ displayOptions: { show: { resource: ['webhookSubscription'], operation: ['webhookSubscriptionCreate', 'webhookSubscriptionUpdate'] } },
350
351
  default: true,
351
352
  description: 'Whether the webhook is active',
352
353
  },
@@ -355,7 +356,7 @@ class Linq {
355
356
  displayName: 'Contact ID',
356
357
  name: 'contactId',
357
358
  type: 'string',
358
- displayOptions: { show: { resource: ['contact'], operation: ['getOne', 'update', 'delete'] } },
359
+ displayOptions: { show: { resource: ['contact'], operation: ['contactGetOne', 'contactUpdate', 'contactDelete'] } },
359
360
  default: '',
360
361
  description: 'The ID of the contact',
361
362
  },
@@ -363,7 +364,7 @@ class Linq {
363
364
  displayName: 'First Name',
364
365
  name: 'firstName',
365
366
  type: 'string',
366
- displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
367
+ displayOptions: { show: { resource: ['contact'], operation: ['contactCreate', 'contactUpdate'] } },
367
368
  default: '',
368
369
  description: 'The first name of the contact',
369
370
  },
@@ -371,7 +372,7 @@ class Linq {
371
372
  displayName: 'Last Name',
372
373
  name: 'lastName',
373
374
  type: 'string',
374
- displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
375
+ displayOptions: { show: { resource: ['contact'], operation: ['contactCreate', 'contactUpdate'] } },
375
376
  default: '',
376
377
  description: 'The last name of the contact',
377
378
  },
@@ -379,7 +380,7 @@ class Linq {
379
380
  displayName: 'Email',
380
381
  name: 'email',
381
382
  type: 'string',
382
- displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
383
+ displayOptions: { show: { resource: ['contact'], operation: ['contactCreate', 'contactUpdate'] } },
383
384
  default: '',
384
385
  placeholder: 'name@email.com',
385
386
  description: 'The email of the contact',
@@ -388,7 +389,7 @@ class Linq {
388
389
  displayName: 'Phone Number',
389
390
  name: 'phoneNumber',
390
391
  type: 'string',
391
- displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
392
+ displayOptions: { show: { resource: ['contact'], operation: ['contactCreate', 'contactUpdate'] } },
392
393
  default: '',
393
394
  description: 'The phone number of the contact',
394
395
  },
@@ -396,7 +397,7 @@ class Linq {
396
397
  displayName: 'Company',
397
398
  name: 'company',
398
399
  type: 'string',
399
- displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
400
+ displayOptions: { show: { resource: ['contact'], operation: ['contactCreate', 'contactUpdate'] } },
400
401
  default: '',
401
402
  description: 'The company of the contact',
402
403
  },
@@ -404,7 +405,7 @@ class Linq {
404
405
  displayName: 'Title',
405
406
  name: 'title',
406
407
  type: 'string',
407
- displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
408
+ displayOptions: { show: { resource: ['contact'], operation: ['contactCreate', 'contactUpdate'] } },
408
409
  default: '',
409
410
  description: 'The title of the contact',
410
411
  },
@@ -412,7 +413,7 @@ class Linq {
412
413
  displayName: 'Location',
413
414
  name: 'location',
414
415
  type: 'string',
415
- displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
416
+ displayOptions: { show: { resource: ['contact'], operation: ['contactCreate', 'contactUpdate'] } },
416
417
  default: '',
417
418
  description: 'The location of the contact',
418
419
  },
@@ -420,6 +421,7 @@ class Linq {
420
421
  };
421
422
  }
422
423
  async execute() {
424
+ var _a;
423
425
  const items = this.getInputData();
424
426
  const returnData = [];
425
427
  const credentials = await this.getCredentials('linqApi');
@@ -427,381 +429,387 @@ class Linq {
427
429
  const resource = this.getNodeParameter('resource', i);
428
430
  const operation = this.getNodeParameter('operation', i);
429
431
  let responseData;
430
- // Chat operations
431
- if (resource === 'chat') {
432
- if (operation === 'getAll') {
433
- const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
434
- const page = this.getNodeParameter('page', i, 1);
435
- const perPage = this.getNodeParameter('perPage', i, 25);
436
- const qs = { page, per_page: perPage };
437
- if (phoneNumber)
438
- qs.phone_number = phoneNumber;
439
- responseData = await this.helpers.request({
440
- method: 'GET',
441
- url: 'https://api.linqapp.com/api/partner/v2/chats',
442
- qs,
443
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
444
- json: true,
445
- });
446
- }
447
- if (operation === 'getOne') {
448
- const chatId = this.getNodeParameter('chatId', i);
449
- responseData = await this.helpers.request({
450
- method: 'GET',
451
- url: `https://api.linqapp.com/api/partner/v2/chats/${chatId}`,
452
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
453
- json: true,
454
- });
455
- }
456
- if (operation === 'find') {
457
- const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
458
- const qs = {};
459
- if (phoneNumber)
460
- qs.phone_number = phoneNumber;
461
- responseData = await this.helpers.request({
462
- method: 'GET',
463
- url: 'https://api.linqapp.com/api/partner/v2/chats/find',
464
- qs,
465
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
466
- json: true,
467
- });
468
- }
469
- if (operation === 'create') {
470
- const sendFrom = this.getNodeParameter('sendFrom', i);
471
- const displayName = this.getNodeParameter('displayName', i);
472
- const phoneNumbers = this.getNodeParameter('phoneNumbers', i);
473
- const messageText = this.getNodeParameter('messageText', i);
474
- const body = {
475
- chat: {
476
- phone_numbers: phoneNumbers.split(',').map(p => p.trim())
477
- },
478
- message: {
479
- text: messageText
432
+ try {
433
+ // Chat operations
434
+ if (resource === 'chat') {
435
+ if (operation === 'chatGetAll') {
436
+ const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
437
+ const page = this.getNodeParameter('page', i, 1);
438
+ const perPage = this.getNodeParameter('perPage', i, 25);
439
+ const qs = { page, per_page: perPage };
440
+ if (phoneNumber)
441
+ qs.phone_number = phoneNumber;
442
+ responseData = await this.helpers.request({
443
+ method: 'GET',
444
+ url: 'https://api.linqapp.com/api/partner/v2/chats',
445
+ qs,
446
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
447
+ json: true,
448
+ });
449
+ }
450
+ if (operation === 'chatGetOne') {
451
+ const chatId = this.getNodeParameter('chatId', i);
452
+ responseData = await this.helpers.request({
453
+ method: 'GET',
454
+ url: `https://api.linqapp.com/api/partner/v2/chats/${chatId}`,
455
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
456
+ json: true,
457
+ });
458
+ }
459
+ if (operation === 'chatFind') {
460
+ const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
461
+ const qs = {};
462
+ if (phoneNumber)
463
+ qs.phone_number = phoneNumber;
464
+ responseData = await this.helpers.request({
465
+ method: 'GET',
466
+ url: 'https://api.linqapp.com/api/partner/v2/chats/find',
467
+ qs,
468
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
469
+ json: true,
470
+ });
471
+ }
472
+ if (operation === 'chatCreate') {
473
+ const sendFrom = this.getNodeParameter('sendFrom', i);
474
+ const displayName = this.getNodeParameter('displayName', i);
475
+ const phoneNumbers = this.getNodeParameter('phoneNumbers', i);
476
+ const messageText = this.getNodeParameter('messageText', i);
477
+ const body = {
478
+ chat: {
479
+ phone_numbers: phoneNumbers.split(',').map(p => p.trim())
480
+ },
481
+ message: {
482
+ text: messageText
483
+ }
484
+ };
485
+ if (sendFrom) {
486
+ body.send_from = sendFrom;
487
+ }
488
+ if (displayName) {
489
+ body.chat.display_name = displayName;
480
490
  }
481
- };
482
- if (sendFrom) {
483
- body.send_from = sendFrom;
491
+ responseData = await this.helpers.request({
492
+ method: 'POST',
493
+ url: 'https://api.linqapp.com/api/partner/v2/chats',
494
+ headers: {
495
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
496
+ 'Content-Type': 'application/json'
497
+ },
498
+ body: body,
499
+ json: true,
500
+ });
484
501
  }
485
- if (displayName) {
486
- body.chat.display_name = displayName;
502
+ if (operation === 'chatShareContact') {
503
+ responseData = await this.helpers.request({
504
+ method: 'POST',
505
+ url: 'https://api.linqapp.com/api/partner/v2/chats/share-contact',
506
+ headers: {
507
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
508
+ 'Content-Type': 'application/json'
509
+ },
510
+ json: true,
511
+ });
487
512
  }
488
- responseData = await this.helpers.request({
489
- method: 'POST',
490
- url: 'https://api.linqapp.com/api/partner/v2/chats',
491
- headers: {
492
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
493
- 'Content-Type': 'application/json'
494
- },
495
- body: JSON.stringify(body),
496
- json: true,
497
- });
498
- }
499
- if (operation === 'shareContact') {
500
- responseData = await this.helpers.request({
501
- method: 'POST',
502
- url: 'https://api.linqapp.com/api/partner/v2/chats/share-contact',
503
- headers: {
504
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
505
- 'Content-Type': 'application/json'
506
- },
507
- json: true,
508
- });
509
- }
510
- }
511
- // Chat Message operations
512
- if (resource === 'chatMessage') {
513
- if (operation === 'getAll') {
514
- const chatId = this.getNodeParameter('chatId', i);
515
- responseData = await this.helpers.request({
516
- method: 'GET',
517
- url: `https://api.linqapp.com/api/partner/v2/chat_messages`,
518
- qs: { chat_id: chatId },
519
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
520
- json: true,
521
- });
522
513
  }
523
- if (operation === 'getOne') {
524
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
525
- responseData = await this.helpers.request({
526
- method: 'GET',
527
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
528
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
529
- json: true,
530
- });
531
- }
532
- if (operation === 'create') {
533
- const chatId = this.getNodeParameter('chatId', i);
534
- const messageText = this.getNodeParameter('messageText', i);
535
- const body = {
536
- chat_message: {
514
+ // Chat Message operations
515
+ if (resource === 'chatMessage') {
516
+ if (operation === 'chatMessageGetAll') {
517
+ const chatId = this.getNodeParameter('chatId', i);
518
+ responseData = await this.helpers.request({
519
+ method: 'GET',
520
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages`,
521
+ qs: { chat_id: chatId },
522
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
523
+ json: true,
524
+ });
525
+ }
526
+ if (operation === 'chatMessageGetOne') {
527
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
528
+ responseData = await this.helpers.request({
529
+ method: 'GET',
530
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
531
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
532
+ json: true,
533
+ });
534
+ }
535
+ if (operation === 'chatMessageCreate') {
536
+ const chatId = this.getNodeParameter('chatId', i);
537
+ const messageText = this.getNodeParameter('messageText', i);
538
+ const body = {
537
539
  chat_id: chatId,
538
540
  text: messageText
539
- }
540
- };
541
- responseData = await this.helpers.request({
542
- method: 'POST',
543
- url: 'https://api.linqapp.com/api/partner/v2/chat_messages',
544
- headers: {
545
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
546
- 'Content-Type': 'application/json'
547
- },
548
- body: JSON.stringify(body),
549
- json: true,
550
- });
551
- }
552
- if (operation === 'delete') {
553
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
554
- responseData = await this.helpers.request({
555
- method: 'DELETE',
556
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
557
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
558
- json: true,
559
- });
560
- }
561
- if (operation === 'edit') {
562
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
563
- const messageText = this.getNodeParameter('messageText', i);
564
- const body = {
565
- text: messageText
566
- };
567
- responseData = await this.helpers.request({
568
- method: 'POST',
569
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/edit`,
570
- headers: {
571
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
572
- 'Content-Type': 'application/json'
573
- },
574
- body: JSON.stringify(body),
575
- json: true,
576
- });
577
- }
578
- if (operation === 'react') {
579
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
580
- const reaction = this.getNodeParameter('reaction', i);
581
- const body = {
582
- reaction: reaction
583
- };
584
- responseData = await this.helpers.request({
585
- method: 'POST',
586
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/react`,
587
- headers: {
588
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
589
- 'Content-Type': 'application/json'
590
- },
591
- body: JSON.stringify(body),
592
- json: true,
593
- });
594
- }
595
- if (operation === 'getReaction') {
596
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
597
- responseData = await this.helpers.request({
598
- method: 'GET',
599
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/reaction`,
600
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
601
- json: true,
602
- });
603
- }
604
- }
605
- // Phone Number operations
606
- if (resource === 'phoneNumber') {
607
- if (operation === 'getAll') {
608
- responseData = await this.helpers.request({
609
- method: 'GET',
610
- url: 'https://api.linqapp.com/api/partner/v2/phone_numbers',
611
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
612
- json: true,
613
- });
614
- }
615
- if (operation === 'checkIMessageAvailability') {
616
- const phoneNumber = this.getNodeParameter('phoneNumber', i);
617
- const body = {
618
- phone_number: phoneNumber
619
- };
620
- responseData = await this.helpers.request({
621
- method: 'POST',
622
- url: 'https://api.linqapp.com/api/partner/v2/i_message_availability/check',
623
- headers: {
624
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
625
- 'Content-Type': 'application/json'
626
- },
627
- body: JSON.stringify(body),
628
- json: true,
629
- });
630
- }
631
- }
632
- // Webhook Subscription operations
633
- if (resource === 'webhookSubscription') {
634
- if (operation === 'getAll') {
635
- responseData = await this.helpers.request({
636
- method: 'GET',
637
- url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
638
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
639
- json: true,
640
- });
641
- }
642
- if (operation === 'getOne') {
643
- const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
644
- responseData = await this.helpers.request({
645
- method: 'GET',
646
- url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
647
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
648
- json: true,
649
- });
541
+ };
542
+ responseData = await this.helpers.request({
543
+ method: 'POST',
544
+ url: 'https://api.linqapp.com/api/partner/v2/chat_messages',
545
+ headers: {
546
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
547
+ 'Content-Type': 'application/json'
548
+ },
549
+ body: body,
550
+ json: true,
551
+ });
552
+ }
553
+ if (operation === 'chatMessageDelete') {
554
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
555
+ responseData = await this.helpers.request({
556
+ method: 'DELETE',
557
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
558
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
559
+ json: true,
560
+ });
561
+ }
562
+ if (operation === 'chatMessageEdit') {
563
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
564
+ const messageText = this.getNodeParameter('messageText', i);
565
+ const body = {
566
+ text: messageText
567
+ };
568
+ responseData = await this.helpers.request({
569
+ method: 'POST',
570
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/edit`,
571
+ headers: {
572
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
573
+ 'Content-Type': 'application/json'
574
+ },
575
+ body: body,
576
+ json: true,
577
+ });
578
+ }
579
+ if (operation === 'chatMessageReact') {
580
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
581
+ const reaction = this.getNodeParameter('reaction', i);
582
+ const body = {
583
+ reaction: reaction
584
+ };
585
+ responseData = await this.helpers.request({
586
+ method: 'POST',
587
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/react`,
588
+ headers: {
589
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
590
+ 'Content-Type': 'application/json'
591
+ },
592
+ body: body,
593
+ json: true,
594
+ });
595
+ }
596
+ if (operation === 'chatMessageGetReaction') {
597
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
598
+ responseData = await this.helpers.request({
599
+ method: 'GET',
600
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/reaction`,
601
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
602
+ json: true,
603
+ });
604
+ }
650
605
  }
651
- if (operation === 'create') {
652
- const webhookUrl = this.getNodeParameter('webhookUrl', i);
653
- const events = this.getNodeParameter('events', i);
654
- const version = this.getNodeParameter('version', i);
655
- const active = this.getNodeParameter('active', i);
656
- const body = {
657
- webhook_url: webhookUrl,
658
- version: version,
659
- active: active
660
- };
661
- if (events) {
662
- body.events = events.split(',').map(e => e.trim());
606
+ // Phone Number operations
607
+ if (resource === 'phoneNumber') {
608
+ if (operation === 'phoneNumberGetAll') {
609
+ responseData = await this.helpers.request({
610
+ method: 'GET',
611
+ url: 'https://api.linqapp.com/api/partner/v2/phone_numbers',
612
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
613
+ json: true,
614
+ });
615
+ }
616
+ if (operation === 'phoneNumberCheckIMessageAvailability') {
617
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
618
+ const body = {
619
+ phone_number: phoneNumber
620
+ };
621
+ responseData = await this.helpers.request({
622
+ method: 'POST',
623
+ url: 'https://api.linqapp.com/api/partner/v2/i_message_availability/check',
624
+ headers: {
625
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
626
+ 'Content-Type': 'application/json'
627
+ },
628
+ body: body,
629
+ json: true,
630
+ });
663
631
  }
664
- responseData = await this.helpers.request({
665
- method: 'POST',
666
- url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
667
- headers: {
668
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
669
- 'Content-Type': 'application/json'
670
- },
671
- body: JSON.stringify(body),
672
- json: true,
673
- });
674
632
  }
675
- if (operation === 'update') {
676
- const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
677
- const webhookUrl = this.getNodeParameter('webhookUrl', i);
678
- const events = this.getNodeParameter('events', i);
679
- const version = this.getNodeParameter('version', i);
680
- const active = this.getNodeParameter('active', i);
681
- const body = {
682
- version: version,
683
- active: active
684
- };
685
- if (webhookUrl) {
686
- body.webhook_url = webhookUrl;
633
+ // Webhook Subscription operations
634
+ if (resource === 'webhookSubscription') {
635
+ if (operation === 'webhookSubscriptionGetAll') {
636
+ responseData = await this.helpers.request({
637
+ method: 'GET',
638
+ url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
639
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
640
+ json: true,
641
+ });
687
642
  }
688
- if (events) {
689
- body.events = events.split(',').map(e => e.trim());
643
+ if (operation === 'webhookSubscriptionGetOne') {
644
+ const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
645
+ responseData = await this.helpers.request({
646
+ method: 'GET',
647
+ url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
648
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
649
+ json: true,
650
+ });
651
+ }
652
+ if (operation === 'webhookSubscriptionCreate') {
653
+ const webhookUrl = this.getNodeParameter('webhookUrl', i);
654
+ const events = this.getNodeParameter('events', i);
655
+ const version = this.getNodeParameter('version', i);
656
+ const active = this.getNodeParameter('active', i);
657
+ const body = {
658
+ webhook_url: webhookUrl,
659
+ version: version,
660
+ active: active
661
+ };
662
+ if (events) {
663
+ body.events = events.split(',').map(e => e.trim());
664
+ }
665
+ responseData = await this.helpers.request({
666
+ method: 'POST',
667
+ url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
668
+ headers: {
669
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
670
+ 'Content-Type': 'application/json'
671
+ },
672
+ body: body,
673
+ json: true,
674
+ });
675
+ }
676
+ if (operation === 'webhookSubscriptionUpdate') {
677
+ const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
678
+ const webhookUrl = this.getNodeParameter('webhookUrl', i);
679
+ const events = this.getNodeParameter('events', i);
680
+ const version = this.getNodeParameter('version', i);
681
+ const active = this.getNodeParameter('active', i);
682
+ const body = {
683
+ version: version,
684
+ active: active
685
+ };
686
+ if (webhookUrl) {
687
+ body.webhook_url = webhookUrl;
688
+ }
689
+ if (events) {
690
+ body.events = events.split(',').map(e => e.trim());
691
+ }
692
+ responseData = await this.helpers.request({
693
+ method: 'PUT',
694
+ url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
695
+ headers: {
696
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
697
+ 'Content-Type': 'application/json'
698
+ },
699
+ body: body,
700
+ json: true,
701
+ });
702
+ }
703
+ if (operation === 'webhookSubscriptionDelete') {
704
+ const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
705
+ responseData = await this.helpers.request({
706
+ method: 'DELETE',
707
+ url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
708
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
709
+ json: true,
710
+ });
690
711
  }
691
- responseData = await this.helpers.request({
692
- method: 'PUT',
693
- url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
694
- headers: {
695
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
696
- 'Content-Type': 'application/json'
697
- },
698
- body: JSON.stringify(body),
699
- json: true,
700
- });
701
712
  }
702
- if (operation === 'delete') {
703
- const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
704
- responseData = await this.helpers.request({
705
- method: 'DELETE',
706
- url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
707
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
708
- json: true,
709
- });
713
+ // Contact operations
714
+ if (resource === 'contact') {
715
+ if (operation === 'contactCreate') {
716
+ const firstName = this.getNodeParameter('firstName', i);
717
+ const lastName = this.getNodeParameter('lastName', i);
718
+ const email = this.getNodeParameter('email', i);
719
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
720
+ const company = this.getNodeParameter('company', i);
721
+ const title = this.getNodeParameter('title', i);
722
+ const location = this.getNodeParameter('location', i);
723
+ const body = {
724
+ contact: {}
725
+ };
726
+ if (firstName)
727
+ body.contact.first_name = firstName;
728
+ if (lastName)
729
+ body.contact.last_name = lastName;
730
+ if (email)
731
+ body.contact.email = email;
732
+ if (phoneNumber)
733
+ body.contact.phone_number = phoneNumber;
734
+ if (company)
735
+ body.contact.company = company;
736
+ if (title)
737
+ body.contact.title = title;
738
+ if (location)
739
+ body.contact.location = location;
740
+ responseData = await this.helpers.request({
741
+ method: 'POST',
742
+ url: 'https://api.linqapp.com/api/partner/v2/contacts',
743
+ headers: {
744
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
745
+ 'Content-Type': 'application/json'
746
+ },
747
+ body: body,
748
+ json: true,
749
+ });
750
+ }
751
+ if (operation === 'contactGetOne') {
752
+ const contactId = this.getNodeParameter('contactId', i);
753
+ responseData = await this.helpers.request({
754
+ method: 'GET',
755
+ url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
756
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
757
+ json: true,
758
+ });
759
+ }
760
+ if (operation === 'contactUpdate') {
761
+ const contactId = this.getNodeParameter('contactId', i);
762
+ const firstName = this.getNodeParameter('firstName', i);
763
+ const lastName = this.getNodeParameter('lastName', i);
764
+ const email = this.getNodeParameter('email', i);
765
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
766
+ const company = this.getNodeParameter('company', i);
767
+ const title = this.getNodeParameter('title', i);
768
+ const location = this.getNodeParameter('location', i);
769
+ const body = {
770
+ contact: {}
771
+ };
772
+ if (firstName)
773
+ body.contact.first_name = firstName;
774
+ if (lastName)
775
+ body.contact.last_name = lastName;
776
+ if (email)
777
+ body.contact.email = email;
778
+ if (phoneNumber)
779
+ body.contact.phone_number = phoneNumber;
780
+ if (company)
781
+ body.contact.company = company;
782
+ if (title)
783
+ body.contact.title = title;
784
+ if (location)
785
+ body.contact.location = location;
786
+ responseData = await this.helpers.request({
787
+ method: 'PUT',
788
+ url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
789
+ headers: {
790
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
791
+ 'Content-Type': 'application/json'
792
+ },
793
+ body: body,
794
+ json: true,
795
+ });
796
+ }
797
+ if (operation === 'contactDelete') {
798
+ const contactId = this.getNodeParameter('contactId', i);
799
+ responseData = await this.helpers.request({
800
+ method: 'DELETE',
801
+ url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
802
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
803
+ json: true,
804
+ });
805
+ }
710
806
  }
711
807
  }
712
- // Contact operations
713
- if (resource === 'contact') {
714
- if (operation === 'create') {
715
- const firstName = this.getNodeParameter('firstName', i);
716
- const lastName = this.getNodeParameter('lastName', i);
717
- const email = this.getNodeParameter('email', i);
718
- const phoneNumber = this.getNodeParameter('phoneNumber', i);
719
- const company = this.getNodeParameter('company', i);
720
- const title = this.getNodeParameter('title', i);
721
- const location = this.getNodeParameter('location', i);
722
- const body = {
723
- contact: {}
724
- };
725
- if (firstName)
726
- body.contact.first_name = firstName;
727
- if (lastName)
728
- body.contact.last_name = lastName;
729
- if (email)
730
- body.contact.email = email;
731
- if (phoneNumber)
732
- body.contact.phone_number = phoneNumber;
733
- if (company)
734
- body.contact.company = company;
735
- if (title)
736
- body.contact.title = title;
737
- if (location)
738
- body.contact.location = location;
739
- responseData = await this.helpers.request({
740
- method: 'POST',
741
- url: 'https://api.linqapp.com/api/partner/v2/contacts',
742
- headers: {
743
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
744
- 'Content-Type': 'application/json'
745
- },
746
- body: JSON.stringify(body),
747
- json: true,
748
- });
749
- }
750
- if (operation === 'getOne') {
751
- const contactId = this.getNodeParameter('contactId', i);
752
- responseData = await this.helpers.request({
753
- method: 'GET',
754
- url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
755
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
756
- json: true,
757
- });
758
- }
759
- if (operation === 'update') {
760
- const contactId = this.getNodeParameter('contactId', i);
761
- const firstName = this.getNodeParameter('firstName', i);
762
- const lastName = this.getNodeParameter('lastName', i);
763
- const email = this.getNodeParameter('email', i);
764
- const phoneNumber = this.getNodeParameter('phoneNumber', i);
765
- const company = this.getNodeParameter('company', i);
766
- const title = this.getNodeParameter('title', i);
767
- const location = this.getNodeParameter('location', i);
768
- const body = {
769
- contact: {}
770
- };
771
- if (firstName)
772
- body.contact.first_name = firstName;
773
- if (lastName)
774
- body.contact.last_name = lastName;
775
- if (email)
776
- body.contact.email = email;
777
- if (phoneNumber)
778
- body.contact.phone_number = phoneNumber;
779
- if (company)
780
- body.contact.company = company;
781
- if (title)
782
- body.contact.title = title;
783
- if (location)
784
- body.contact.location = location;
785
- responseData = await this.helpers.request({
786
- method: 'PUT',
787
- url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
788
- headers: {
789
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
790
- 'Content-Type': 'application/json'
791
- },
792
- body: JSON.stringify(body),
793
- json: true,
794
- });
795
- }
796
- if (operation === 'delete') {
797
- const contactId = this.getNodeParameter('contactId', i);
798
- responseData = await this.helpers.request({
799
- method: 'DELETE',
800
- url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
801
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
802
- json: true,
803
- });
808
+ catch (error) {
809
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 429) {
810
+ throw new n8n_workflow_1.ApplicationError('Rate limit exceeded. Please try again after 10 seconds.');
804
811
  }
812
+ throw error;
805
813
  }
806
814
  returnData.push({ json: responseData });
807
815
  }