n8n-nodes-confirm8 0.12.0 → 0.15.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.
@@ -5,214 +5,583 @@ const n8n_workflow_1 = require("n8n-workflow");
5
5
  class ApiConfirm8 {
6
6
  constructor() {
7
7
  this.description = {
8
- displayName: 'API Confirm8',
9
- name: 'apiConfirm8',
10
- icon: 'file:api.svg',
11
- group: ['transform'],
8
+ displayName: "API Confirm8",
9
+ name: "apiConfirm8",
10
+ icon: "file:api.svg",
11
+ group: ["transform"],
12
12
  version: 1,
13
13
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
14
- description: 'Interact with Confirm8 API',
14
+ description: "Complete Confirm8 API integration",
15
15
  defaults: {
16
- name: 'API Confirm8',
16
+ name: "API Confirm8",
17
17
  },
18
- inputs: ['main'],
19
- outputs: ['main'],
18
+ inputs: ["main"],
19
+ outputs: ["main"],
20
20
  properties: [
21
21
  // API Configuration
22
22
  {
23
- displayName: 'Base URL',
24
- name: 'baseUrl',
25
- type: 'string',
26
- default: '',
27
- placeholder: 'https://api.confirm8.com',
23
+ displayName: "Base URL",
24
+ name: "baseUrl",
25
+ type: "string",
26
+ default: "",
27
+ placeholder: "https://api.confirm8.com",
28
28
  required: true,
29
- description: 'Base URL of your API',
29
+ description: "Base URL of your API",
30
30
  },
31
31
  {
32
- displayName: 'Bearer Token',
33
- name: 'bearerToken',
34
- type: 'string',
35
- typeOptions: {
36
- password: true,
37
- },
38
- default: '',
32
+ displayName: "Bearer Token",
33
+ name: "bearerToken",
34
+ type: "string",
35
+ typeOptions: { password: true },
36
+ default: "",
39
37
  required: true,
40
- description: 'Bearer token for authentication',
41
38
  },
42
39
  {
43
- displayName: 'X-API-DOMAIN',
44
- name: 'apiDomain',
45
- type: 'string',
46
- default: '',
40
+ displayName: "X-API-DOMAIN",
41
+ name: "apiDomain",
42
+ type: "string",
43
+ default: "",
47
44
  required: true,
48
- description: 'API Domain header value',
49
45
  },
50
46
  {
51
- displayName: 'X-APIKEY-TOKEN',
52
- name: 'apiKeyToken',
53
- type: 'string',
54
- typeOptions: {
55
- password: true,
56
- },
57
- default: '',
47
+ displayName: "X-APIKEY-TOKEN",
48
+ name: "apiKeyToken",
49
+ type: "string",
50
+ typeOptions: { password: true },
51
+ default: "",
58
52
  required: true,
59
- description: 'API Key Token header value',
60
53
  },
61
54
  // Resource Selection
62
55
  {
63
- displayName: 'Resource',
64
- name: 'resource',
65
- type: 'options',
56
+ displayName: "Resource",
57
+ name: "resource",
58
+ type: "options",
66
59
  noDataExpression: true,
67
60
  options: [
61
+ { name: "User", value: "user" },
62
+ { name: "Client", value: "client" },
63
+ { name: "Item", value: "item" },
64
+ { name: "Item Type", value: "itemType" },
65
+ { name: "Task", value: "task" },
66
+ { name: "Service", value: "service" },
67
+ { name: "Product", value: "product" },
68
+ { name: "Order", value: "order" },
69
+ { name: "Modality", value: "modality" },
70
+ { name: "Ticket", value: "ticket" },
71
+ { name: "Property", value: "property" },
72
+ ],
73
+ default: "user",
74
+ },
75
+ // ============= USER OPERATIONS =============
76
+ {
77
+ displayName: "Operation",
78
+ name: "operation",
79
+ type: "options",
80
+ noDataExpression: true,
81
+ displayOptions: { show: { resource: ["user"] } },
82
+ options: [
83
+ { name: "Create", value: "create", action: "Create a user" },
84
+ { name: "Get", value: "get", action: "Get a user" },
85
+ { name: "Get All", value: "getAll", action: "Get all users" },
86
+ {
87
+ name: "Get By Username",
88
+ value: "getByUsername",
89
+ action: "Get user by username",
90
+ },
91
+ { name: "Update", value: "update", action: "Update a user" },
92
+ { name: "Activate", value: "activate", action: "Activate user" },
93
+ {
94
+ name: "Deactivate",
95
+ value: "deactivate",
96
+ action: "Deactivate user",
97
+ },
98
+ {
99
+ name: "Get Tickets",
100
+ value: "getTickets",
101
+ action: "Get user tickets",
102
+ },
103
+ { name: "Get Tasks", value: "getTasks", action: "Get user tasks" },
104
+ {
105
+ name: "Get Permissions",
106
+ value: "getPermissions",
107
+ action: "Get user permissions",
108
+ },
109
+ {
110
+ name: "Link Tasks",
111
+ value: "linkTasks",
112
+ action: "Link tasks with user",
113
+ },
114
+ {
115
+ name: "Delete Linked Tasks",
116
+ value: "deleteLinkedTasks",
117
+ action: "Delete linked tasks",
118
+ },
119
+ {
120
+ name: "Delete Linked Tasks By User",
121
+ value: "deleteLinkedTasksByUser",
122
+ action: "Delete linked tasks by user",
123
+ },
68
124
  {
69
- name: 'User',
70
- value: 'user',
125
+ name: "Upload Photo",
126
+ value: "uploadPhoto",
127
+ action: "Upload user photo",
71
128
  },
72
129
  {
73
- name: 'Client',
74
- value: 'client',
130
+ name: "Upload Signature",
131
+ value: "uploadSignature",
132
+ action: "Upload user signature",
75
133
  },
76
134
  ],
77
- default: 'user',
135
+ default: "getAll",
78
136
  },
79
- // USER OPERATIONS
137
+ // User ID
80
138
  {
81
- displayName: 'Operation',
82
- name: 'operation',
83
- type: 'options',
84
- noDataExpression: true,
139
+ displayName: "User ID",
140
+ name: "userId",
141
+ type: "string",
142
+ displayOptions: {
143
+ show: {
144
+ resource: ["user"],
145
+ operation: [
146
+ "get",
147
+ "update",
148
+ "activate",
149
+ "deactivate",
150
+ "getTickets",
151
+ "getTasks",
152
+ "getPermissions",
153
+ "uploadPhoto",
154
+ "uploadSignature",
155
+ ],
156
+ },
157
+ },
158
+ default: "",
159
+ required: true,
160
+ },
161
+ // Username
162
+ {
163
+ displayName: "Username",
164
+ name: "username",
165
+ type: "string",
166
+ displayOptions: {
167
+ show: {
168
+ resource: ["user"],
169
+ operation: ["create", "getByUsername"],
170
+ },
171
+ },
172
+ default: "",
173
+ required: true,
174
+ },
175
+ // Employee ID for delete
176
+ {
177
+ displayName: "Employee ID",
178
+ name: "employeeId",
179
+ type: "string",
85
180
  displayOptions: {
86
181
  show: {
87
- resource: ['user'],
182
+ resource: ["user"],
183
+ operation: ["deleteLinkedTasksByUser"],
184
+ },
185
+ },
186
+ default: "",
187
+ required: true,
188
+ },
189
+ // User Additional Fields
190
+ {
191
+ displayName: "Additional Fields",
192
+ name: "additionalFields",
193
+ type: "collection",
194
+ placeholder: "Add Field",
195
+ default: {},
196
+ displayOptions: {
197
+ show: {
198
+ resource: ["user"],
199
+ operation: ["create", "update"],
88
200
  },
89
201
  },
90
202
  options: [
203
+ { displayName: "Email", name: "email", type: "string", default: "" },
204
+ { displayName: "Name", name: "name", type: "string", default: "" },
205
+ { displayName: "Phone", name: "phone", type: "string", default: "" },
91
206
  {
92
- name: 'Get',
93
- value: 'get',
94
- description: 'Get a user',
95
- action: 'Get a user',
207
+ displayName: "Password",
208
+ name: "password",
209
+ type: "string",
210
+ typeOptions: { password: true },
211
+ default: "",
96
212
  },
213
+ ],
214
+ },
215
+ // ============= CLIENT OPERATIONS =============
216
+ {
217
+ displayName: "Operation",
218
+ name: "operation",
219
+ type: "options",
220
+ noDataExpression: true,
221
+ displayOptions: { show: { resource: ["client"] } },
222
+ options: [
223
+ { name: "Create", value: "create", action: "Create a client" },
224
+ { name: "Get", value: "get", action: "Get a client" },
225
+ { name: "Get All", value: "getAll", action: "Get all clients" },
226
+ { name: "Update", value: "update", action: "Update a client" },
227
+ { name: "Activate", value: "activate", action: "Activate client" },
97
228
  {
98
- name: 'Get All',
99
- value: 'getAll',
100
- description: 'Get all users',
101
- action: 'Get all users',
229
+ name: "Deactivate",
230
+ value: "deactivate",
231
+ action: "Deactivate client",
102
232
  },
103
- {
104
- name: 'Create',
105
- value: 'create',
106
- description: 'Create a new user',
107
- action: 'Create a user',
233
+ ],
234
+ default: "getAll",
235
+ },
236
+ {
237
+ displayName: "Client ID",
238
+ name: "clientId",
239
+ type: "string",
240
+ displayOptions: {
241
+ show: {
242
+ resource: ["client"],
243
+ operation: ["get", "update", "activate", "deactivate"],
244
+ },
245
+ },
246
+ default: "",
247
+ required: true,
248
+ },
249
+ {
250
+ displayName: "Additional Fields",
251
+ name: "additionalFields",
252
+ type: "collection",
253
+ placeholder: "Add Field",
254
+ default: {},
255
+ displayOptions: {
256
+ show: {
257
+ resource: ["client"],
258
+ operation: ["create", "update"],
108
259
  },
260
+ },
261
+ options: [
262
+ { displayName: "Name", name: "name", type: "string", default: "" },
263
+ { displayName: "Email", name: "email", type: "string", default: "" },
264
+ { displayName: "Phone", name: "phone", type: "string", default: "" },
265
+ ],
266
+ },
267
+ // ============= ITEM OPERATIONS =============
268
+ {
269
+ displayName: "Operation",
270
+ name: "operation",
271
+ type: "options",
272
+ noDataExpression: true,
273
+ displayOptions: { show: { resource: ["item"] } },
274
+ options: [
275
+ { name: "Create", value: "create", action: "Create an item" },
276
+ { name: "Get", value: "get", action: "Get an item" },
277
+ { name: "Get All", value: "getAll", action: "Get all items" },
278
+ { name: "Update", value: "update", action: "Update an item" },
279
+ { name: "Activate", value: "activate", action: "Activate item" },
109
280
  {
110
- name: 'Update',
111
- value: 'update',
112
- description: 'Update a user',
113
- action: 'Update a user',
281
+ name: "Deactivate",
282
+ value: "deactivate",
283
+ action: "Deactivate item",
114
284
  },
115
285
  ],
116
- default: 'getAll',
286
+ default: "getAll",
117
287
  },
118
- // User ID
119
288
  {
120
- displayName: 'User ID',
121
- name: 'userId',
122
- type: 'string',
123
- required: true,
289
+ displayName: "Item ID",
290
+ name: "itemId",
291
+ type: "string",
124
292
  displayOptions: {
125
293
  show: {
126
- resource: ['user'],
127
- operation: ['get', 'update'],
294
+ resource: ["item"],
295
+ operation: ["get", "update", "activate", "deactivate"],
128
296
  },
129
297
  },
130
- default: '',
131
- description: 'The ID of the user',
298
+ default: "",
299
+ required: true,
300
+ },
301
+ // ============= ITEM TYPE OPERATIONS =============
302
+ {
303
+ displayName: "Operation",
304
+ name: "operation",
305
+ type: "options",
306
+ noDataExpression: true,
307
+ displayOptions: { show: { resource: ["itemType"] } },
308
+ options: [
309
+ { name: "Create", value: "create", action: "Create an item type" },
310
+ { name: "Get", value: "get", action: "Get an item type" },
311
+ { name: "Get All", value: "getAll", action: "Get all item types" },
312
+ { name: "Update", value: "update", action: "Update an item type" },
313
+ { name: "Activate", value: "activate", action: "Activate item type" },
314
+ {
315
+ name: "Deactivate",
316
+ value: "deactivate",
317
+ action: "Deactivate item type",
318
+ },
319
+ ],
320
+ default: "getAll",
132
321
  },
133
- // Username for create
134
322
  {
135
- displayName: 'Username',
136
- name: 'username',
137
- type: 'string',
323
+ displayName: "Item Type ID",
324
+ name: "itemTypeId",
325
+ type: "string",
326
+ displayOptions: {
327
+ show: {
328
+ resource: ["itemType"],
329
+ operation: ["get", "update", "activate", "deactivate"],
330
+ },
331
+ },
332
+ default: "",
138
333
  required: true,
334
+ },
335
+ // ============= TASK OPERATIONS =============
336
+ {
337
+ displayName: "Operation",
338
+ name: "operation",
339
+ type: "options",
340
+ noDataExpression: true,
341
+ displayOptions: { show: { resource: ["task"] } },
342
+ options: [
343
+ { name: "Create", value: "create", action: "Create a task" },
344
+ { name: "Get", value: "get", action: "Get a task" },
345
+ { name: "Get All", value: "getAll", action: "Get all tasks" },
346
+ { name: "Update", value: "update", action: "Update a task" },
347
+ { name: "Activate", value: "activate", action: "Activate task" },
348
+ {
349
+ name: "Deactivate",
350
+ value: "deactivate",
351
+ action: "Deactivate task",
352
+ },
353
+ ],
354
+ default: "getAll",
355
+ },
356
+ {
357
+ displayName: "Task ID",
358
+ name: "taskId",
359
+ type: "string",
139
360
  displayOptions: {
140
361
  show: {
141
- resource: ['user'],
142
- operation: ['create'],
362
+ resource: ["task"],
363
+ operation: ["get", "update", "activate", "deactivate"],
143
364
  },
144
365
  },
145
- default: '',
146
- description: 'Username for the new user',
366
+ default: "",
367
+ required: true,
147
368
  },
148
- // Additional fields
369
+ // ============= SERVICE OPERATIONS =============
149
370
  {
150
- displayName: 'Additional Fields',
151
- name: 'additionalFields',
152
- type: 'collection',
153
- placeholder: 'Add Field',
154
- default: {},
371
+ displayName: "Operation",
372
+ name: "operation",
373
+ type: "options",
374
+ noDataExpression: true,
375
+ displayOptions: { show: { resource: ["service"] } },
376
+ options: [
377
+ { name: "Create", value: "create", action: "Create a service" },
378
+ { name: "Get", value: "get", action: "Get a service" },
379
+ { name: "Get All", value: "getAll", action: "Get all services" },
380
+ { name: "Update", value: "update", action: "Update a service" },
381
+ { name: "Activate", value: "activate", action: "Activate service" },
382
+ {
383
+ name: "Deactivate",
384
+ value: "deactivate",
385
+ action: "Deactivate service",
386
+ },
387
+ ],
388
+ default: "getAll",
389
+ },
390
+ {
391
+ displayName: "Service ID",
392
+ name: "serviceId",
393
+ type: "string",
155
394
  displayOptions: {
156
395
  show: {
157
- resource: ['user'],
158
- operation: ['create', 'update'],
396
+ resource: ["service"],
397
+ operation: ["get", "update", "activate", "deactivate"],
159
398
  },
160
399
  },
400
+ default: "",
401
+ required: true,
402
+ },
403
+ // ============= PRODUCT OPERATIONS =============
404
+ {
405
+ displayName: "Operation",
406
+ name: "operation",
407
+ type: "options",
408
+ noDataExpression: true,
409
+ displayOptions: { show: { resource: ["product"] } },
161
410
  options: [
411
+ { name: "Create", value: "create", action: "Create a product" },
412
+ { name: "Get", value: "get", action: "Get a product" },
413
+ { name: "Get All", value: "getAll", action: "Get all products" },
414
+ { name: "Update", value: "update", action: "Update a product" },
415
+ { name: "Activate", value: "activate", action: "Activate product" },
162
416
  {
163
- displayName: 'Email',
164
- name: 'email',
165
- type: 'string',
166
- default: '',
417
+ name: "Deactivate",
418
+ value: "deactivate",
419
+ action: "Deactivate product",
420
+ },
421
+ ],
422
+ default: "getAll",
423
+ },
424
+ {
425
+ displayName: "Product ID",
426
+ name: "productId",
427
+ type: "string",
428
+ displayOptions: {
429
+ show: {
430
+ resource: ["product"],
431
+ operation: ["get", "update", "activate", "deactivate"],
167
432
  },
433
+ },
434
+ default: "",
435
+ required: true,
436
+ },
437
+ // ============= ORDER (WOS) OPERATIONS =============
438
+ {
439
+ displayName: "Operation",
440
+ name: "operation",
441
+ type: "options",
442
+ noDataExpression: true,
443
+ displayOptions: { show: { resource: ["order"] } },
444
+ options: [
445
+ { name: "Create", value: "create", action: "Create an order" },
446
+ { name: "Get", value: "get", action: "Get an order" },
447
+ { name: "Get All", value: "getAll", action: "Get all orders" },
448
+ { name: "Update", value: "update", action: "Update an order" },
449
+ { name: "Activate", value: "activate", action: "Activate order" },
168
450
  {
169
- displayName: 'Name',
170
- name: 'name',
171
- type: 'string',
172
- default: '',
451
+ name: "Deactivate",
452
+ value: "deactivate",
453
+ action: "Deactivate order",
173
454
  },
174
455
  ],
456
+ default: "getAll",
175
457
  },
176
- // CLIENT OPERATIONS
177
458
  {
178
- displayName: 'Operation',
179
- name: 'operation',
180
- type: 'options',
459
+ displayName: "Order ID",
460
+ name: "orderId",
461
+ type: "string",
462
+ displayOptions: {
463
+ show: {
464
+ resource: ["order"],
465
+ operation: ["get", "update", "activate", "deactivate"],
466
+ },
467
+ },
468
+ default: "",
469
+ required: true,
470
+ },
471
+ // ============= MODALITY OPERATIONS =============
472
+ {
473
+ displayName: "Operation",
474
+ name: "operation",
475
+ type: "options",
181
476
  noDataExpression: true,
477
+ displayOptions: { show: { resource: ["modality"] } },
478
+ options: [
479
+ { name: "Create", value: "create", action: "Create a modality" },
480
+ { name: "Get", value: "get", action: "Get a modality" },
481
+ { name: "Get All", value: "getAll", action: "Get all modalities" },
482
+ { name: "Update", value: "update", action: "Update a modality" },
483
+ { name: "Activate", value: "activate", action: "Activate modality" },
484
+ {
485
+ name: "Deactivate",
486
+ value: "deactivate",
487
+ action: "Deactivate modality",
488
+ },
489
+ ],
490
+ default: "getAll",
491
+ },
492
+ {
493
+ displayName: "Modality ID",
494
+ name: "modalityId",
495
+ type: "string",
182
496
  displayOptions: {
183
497
  show: {
184
- resource: ['client'],
498
+ resource: ["modality"],
499
+ operation: ["get", "update", "activate", "deactivate"],
185
500
  },
186
501
  },
502
+ default: "",
503
+ required: true,
504
+ },
505
+ // ============= TICKET OPERATIONS =============
506
+ {
507
+ displayName: "Operation",
508
+ name: "operation",
509
+ type: "options",
510
+ noDataExpression: true,
511
+ displayOptions: { show: { resource: ["ticket"] } },
187
512
  options: [
513
+ { name: "Create", value: "create", action: "Create a ticket" },
514
+ { name: "Get", value: "get", action: "Get a ticket" },
515
+ { name: "Get All", value: "getAll", action: "Get all tickets" },
516
+ { name: "Update", value: "update", action: "Update a ticket" },
517
+ { name: "Activate", value: "activate", action: "Activate ticket" },
188
518
  {
189
- name: 'Get',
190
- value: 'get',
191
- description: 'Get a client',
192
- action: 'Get a client',
519
+ name: "Deactivate",
520
+ value: "deactivate",
521
+ action: "Deactivate ticket",
522
+ },
523
+ ],
524
+ default: "getAll",
525
+ },
526
+ {
527
+ displayName: "Ticket ID",
528
+ name: "ticketId",
529
+ type: "string",
530
+ displayOptions: {
531
+ show: {
532
+ resource: ["ticket"],
533
+ operation: ["get", "update", "activate", "deactivate"],
193
534
  },
535
+ },
536
+ default: "",
537
+ required: true,
538
+ },
539
+ // ============= PROPERTY OPERATIONS =============
540
+ {
541
+ displayName: "Operation",
542
+ name: "operation",
543
+ type: "options",
544
+ noDataExpression: true,
545
+ displayOptions: { show: { resource: ["property"] } },
546
+ options: [
547
+ { name: "Create", value: "create", action: "Create a property" },
548
+ { name: "Get", value: "get", action: "Get a property" },
549
+ { name: "Get All", value: "getAll", action: "Get all properties" },
550
+ { name: "Update", value: "update", action: "Update a property" },
551
+ { name: "Activate", value: "activate", action: "Activate property" },
194
552
  {
195
- name: 'Get All',
196
- value: 'getAll',
197
- description: 'Get all clients',
198
- action: 'Get all clients',
553
+ name: "Deactivate",
554
+ value: "deactivate",
555
+ action: "Deactivate property",
199
556
  },
200
557
  ],
201
- default: 'getAll',
558
+ default: "getAll",
202
559
  },
203
- // Client ID
204
560
  {
205
- displayName: 'Client ID',
206
- name: 'clientId',
207
- type: 'string',
561
+ displayName: "Property ID",
562
+ name: "propertyId",
563
+ type: "string",
564
+ displayOptions: {
565
+ show: {
566
+ resource: ["property"],
567
+ operation: ["get", "update", "activate", "deactivate"],
568
+ },
569
+ },
570
+ default: "",
208
571
  required: true,
572
+ },
573
+ // Generic Additional Fields for POST/PUT operations
574
+ {
575
+ displayName: "Body Data (JSON)",
576
+ name: "bodyData",
577
+ type: "json",
578
+ default: "{}",
209
579
  displayOptions: {
210
580
  show: {
211
- resource: ['client'],
212
- operation: ['get'],
581
+ operation: ["create", "update", "linkTasks"],
213
582
  },
214
583
  },
215
- default: '',
584
+ description: "Request body as JSON",
216
585
  },
217
586
  ],
218
587
  };
@@ -222,64 +591,413 @@ class ApiConfirm8 {
222
591
  const returnData = [];
223
592
  for (let i = 0; i < items.length; i++) {
224
593
  try {
225
- // Get API configuration
226
- const baseUrl = this.getNodeParameter('baseUrl', i);
227
- const bearerToken = this.getNodeParameter('bearerToken', i);
228
- const apiDomain = this.getNodeParameter('apiDomain', i);
229
- const apiKeyToken = this.getNodeParameter('apiKeyToken', i);
230
- const resource = this.getNodeParameter('resource', i);
231
- const operation = this.getNodeParameter('operation', i);
232
- let endpoint = '';
233
- let method = 'GET';
594
+ const baseUrl = this.getNodeParameter("baseUrl", i);
595
+ const bearerToken = this.getNodeParameter("bearerToken", i);
596
+ const apiDomain = this.getNodeParameter("apiDomain", i);
597
+ const apiKeyToken = this.getNodeParameter("apiKeyToken", i);
598
+ const resource = this.getNodeParameter("resource", i);
599
+ const operation = this.getNodeParameter("operation", i);
600
+ let endpoint = "";
601
+ let method = "GET";
234
602
  let body = {};
235
- // USER OPERATIONS
236
- if (resource === 'user') {
237
- if (operation === 'getAll') {
238
- endpoint = '/users';
239
- }
240
- else if (operation === 'get') {
241
- const userId = this.getNodeParameter('userId', i);
242
- endpoint = `/users/${userId}`;
243
- }
244
- else if (operation === 'create') {
245
- endpoint = '/users';
246
- method = 'POST';
247
- const username = this.getNodeParameter('username', i);
248
- const additionalFields = this.getNodeParameter('additionalFields', i, {});
249
- body = { username, ...additionalFields };
250
- }
251
- else if (operation === 'update') {
252
- const userId = this.getNodeParameter('userId', i);
253
- endpoint = `/users/${userId}`;
254
- method = 'PUT';
255
- body = this.getNodeParameter('additionalFields', i, {});
603
+ // Parse body data if provided
604
+ try {
605
+ const bodyDataStr = this.getNodeParameter("bodyData", i, "{}");
606
+ if (bodyDataStr && bodyDataStr.trim() !== "{}") {
607
+ body = JSON.parse(bodyDataStr);
256
608
  }
257
609
  }
258
- // CLIENT OPERATIONS
259
- else if (resource === 'client') {
260
- if (operation === 'getAll') {
261
- endpoint = '/clients';
262
- }
263
- else if (operation === 'get') {
264
- const clientId = this.getNodeParameter('clientId', i);
265
- endpoint = `/clients/${clientId}`;
266
- }
610
+ catch (e) {
611
+ // Body data is optional
612
+ }
613
+ // Build endpoint and method based on resource and operation
614
+ switch (resource) {
615
+ case "user":
616
+ switch (operation) {
617
+ case "create":
618
+ endpoint = "/users";
619
+ method = "POST";
620
+ const username = this.getNodeParameter("username", i);
621
+ const userFields = this.getNodeParameter("additionalFields", i, {});
622
+ body = { username, ...userFields, ...body };
623
+ break;
624
+ case "getAll":
625
+ endpoint = "/users";
626
+ break;
627
+ case "get":
628
+ const userId = this.getNodeParameter("userId", i);
629
+ endpoint = `/users/${userId}`;
630
+ break;
631
+ case "getByUsername":
632
+ const usernameGet = this.getNodeParameter("username", i);
633
+ endpoint = `/users/${usernameGet}/user`;
634
+ break;
635
+ case "update":
636
+ const userIdUpdate = this.getNodeParameter("userId", i);
637
+ endpoint = `/users/${userIdUpdate}`;
638
+ method = "PUT";
639
+ const updateFields = this.getNodeParameter("additionalFields", i, {});
640
+ body = { ...updateFields, ...body };
641
+ break;
642
+ case "activate":
643
+ const userIdActivate = this.getNodeParameter("userId", i);
644
+ endpoint = `/users/${userIdActivate}/active`;
645
+ method = "PATCH";
646
+ break;
647
+ case "deactivate":
648
+ const userIdDeactivate = this.getNodeParameter("userId", i);
649
+ endpoint = `/users/${userIdDeactivate}/inactive`;
650
+ method = "PATCH";
651
+ break;
652
+ case "getTickets":
653
+ const userIdTickets = this.getNodeParameter("userId", i);
654
+ endpoint = `/users/${userIdTickets}/tickets`;
655
+ break;
656
+ case "getTasks":
657
+ const userIdTasks = this.getNodeParameter("userId", i);
658
+ endpoint = `/users/${userIdTasks}/tasks`;
659
+ break;
660
+ case "getPermissions":
661
+ const userIdPermissions = this.getNodeParameter("userId", i);
662
+ endpoint = `/users/${userIdPermissions}/permissions`;
663
+ break;
664
+ case "linkTasks":
665
+ endpoint = "/users/tasks";
666
+ method = "POST";
667
+ break;
668
+ case "deleteLinkedTasks":
669
+ endpoint = "/users/tasks";
670
+ method = "DELETE";
671
+ break;
672
+ case "deleteLinkedTasksByUser":
673
+ const employeeId = this.getNodeParameter("employeeId", i);
674
+ endpoint = `/users/tasks/${employeeId}`;
675
+ method = "DELETE";
676
+ break;
677
+ case "uploadPhoto":
678
+ const userIdPhoto = this.getNodeParameter("userId", i);
679
+ endpoint = `/users/${userIdPhoto}/photos`;
680
+ method = "PATCH";
681
+ break;
682
+ case "uploadSignature":
683
+ const userIdSignature = this.getNodeParameter("userId", i);
684
+ endpoint = `/users/${userIdSignature}/signatures`;
685
+ method = "PATCH";
686
+ break;
687
+ }
688
+ break;
689
+ case "client":
690
+ const clientId = operation !== "create" && operation !== "getAll"
691
+ ? this.getNodeParameter("clientId", i)
692
+ : "";
693
+ switch (operation) {
694
+ case "create":
695
+ endpoint = "/clients";
696
+ method = "POST";
697
+ break;
698
+ case "getAll":
699
+ endpoint = "/clients";
700
+ break;
701
+ case "get":
702
+ endpoint = `/clients/${clientId}`;
703
+ break;
704
+ case "update":
705
+ endpoint = `/clients/${clientId}`;
706
+ method = "PUT";
707
+ break;
708
+ case "activate":
709
+ endpoint = `/clients/${clientId}/active`;
710
+ method = "PUT";
711
+ break;
712
+ case "deactivate":
713
+ endpoint = `/clients/${clientId}/inactive`;
714
+ method = "PUT";
715
+ break;
716
+ }
717
+ if (operation === "create" || operation === "update") {
718
+ const clientFields = this.getNodeParameter("additionalFields", i, {});
719
+ body = { ...clientFields, ...body };
720
+ }
721
+ break;
722
+ case "item":
723
+ const itemId = operation !== "create" && operation !== "getAll"
724
+ ? this.getNodeParameter("itemId", i)
725
+ : "";
726
+ switch (operation) {
727
+ case "create":
728
+ endpoint = "/items";
729
+ method = "POST";
730
+ break;
731
+ case "getAll":
732
+ endpoint = "/items";
733
+ break;
734
+ case "get":
735
+ endpoint = `/items/${itemId}`;
736
+ break;
737
+ case "update":
738
+ endpoint = `/items/${itemId}`;
739
+ method = "PUT";
740
+ break;
741
+ case "activate":
742
+ endpoint = `/items/${itemId}/active`;
743
+ method = "PUT";
744
+ break;
745
+ case "deactivate":
746
+ endpoint = `/items/${itemId}/inactive`;
747
+ method = "PUT";
748
+ break;
749
+ }
750
+ break;
751
+ case "itemType":
752
+ const itemTypeId = operation !== "create" && operation !== "getAll"
753
+ ? this.getNodeParameter("itemTypeId", i)
754
+ : "";
755
+ switch (operation) {
756
+ case "create":
757
+ endpoint = "/itemTypes";
758
+ method = "POST";
759
+ break;
760
+ case "getAll":
761
+ endpoint = "/itemTypes";
762
+ break;
763
+ case "get":
764
+ endpoint = `/itemTypes/${itemTypeId}`;
765
+ break;
766
+ case "update":
767
+ endpoint = `/itemTypes/${itemTypeId}`;
768
+ method = "PUT";
769
+ break;
770
+ case "activate":
771
+ endpoint = `/itemTypes/${itemTypeId}/active`;
772
+ method = "PUT";
773
+ break;
774
+ case "deactivate":
775
+ endpoint = `/itemTypes/${itemTypeId}/inactive`;
776
+ method = "PUT";
777
+ break;
778
+ }
779
+ break;
780
+ case "task":
781
+ const taskId = operation !== "create" && operation !== "getAll"
782
+ ? this.getNodeParameter("taskId", i)
783
+ : "";
784
+ switch (operation) {
785
+ case "create":
786
+ endpoint = "/tasks";
787
+ method = "POST";
788
+ break;
789
+ case "getAll":
790
+ endpoint = "/tasks";
791
+ break;
792
+ case "get":
793
+ endpoint = `/tasks/${taskId}`;
794
+ break;
795
+ case "update":
796
+ endpoint = `/tasks/${taskId}`;
797
+ method = "PUT";
798
+ break;
799
+ case "activate":
800
+ endpoint = `/tasks/${taskId}/active`;
801
+ method = "PUT";
802
+ break;
803
+ case "deactivate":
804
+ endpoint = `/tasks/${taskId}/inactive`;
805
+ method = "PUT";
806
+ break;
807
+ }
808
+ break;
809
+ case "service":
810
+ const serviceId = operation !== "create" && operation !== "getAll"
811
+ ? this.getNodeParameter("serviceId", i)
812
+ : "";
813
+ switch (operation) {
814
+ case "create":
815
+ endpoint = "/services";
816
+ method = "POST";
817
+ break;
818
+ case "getAll":
819
+ endpoint = "/services";
820
+ break;
821
+ case "get":
822
+ endpoint = `/services/${serviceId}`;
823
+ break;
824
+ case "update":
825
+ endpoint = `/services/${serviceId}`;
826
+ method = "PUT";
827
+ break;
828
+ case "activate":
829
+ endpoint = `/services/${serviceId}/active`;
830
+ method = "PUT";
831
+ break;
832
+ case "deactivate":
833
+ endpoint = `/services/${serviceId}/inactive`;
834
+ method = "PUT";
835
+ break;
836
+ }
837
+ break;
838
+ case "product":
839
+ const productId = operation !== "create" && operation !== "getAll"
840
+ ? this.getNodeParameter("productId", i)
841
+ : "";
842
+ switch (operation) {
843
+ case "create":
844
+ endpoint = "/products";
845
+ method = "POST";
846
+ break;
847
+ case "getAll":
848
+ endpoint = "/products";
849
+ break;
850
+ case "get":
851
+ endpoint = `/products/${productId}`;
852
+ break;
853
+ case "update":
854
+ endpoint = `/products/${productId}`;
855
+ method = "PUT";
856
+ break;
857
+ case "activate":
858
+ endpoint = `/products/${productId}/active`;
859
+ method = "PUT";
860
+ break;
861
+ case "deactivate":
862
+ endpoint = `/products/${productId}/inactive`;
863
+ method = "PUT";
864
+ break;
865
+ }
866
+ break;
867
+ case "order":
868
+ const orderId = operation !== "create" && operation !== "getAll"
869
+ ? this.getNodeParameter("orderId", i)
870
+ : "";
871
+ switch (operation) {
872
+ case "create":
873
+ endpoint = "/wos";
874
+ method = "POST";
875
+ break;
876
+ case "getAll":
877
+ endpoint = "/wos";
878
+ break;
879
+ case "get":
880
+ endpoint = `/wos/${orderId}`;
881
+ break;
882
+ case "update":
883
+ endpoint = `/wos/${orderId}`;
884
+ method = "PUT";
885
+ break;
886
+ case "activate":
887
+ endpoint = `/wos/${orderId}/active`;
888
+ method = "PUT";
889
+ break;
890
+ case "deactivate":
891
+ endpoint = `/wos/${orderId}/inactive`;
892
+ method = "PUT";
893
+ break;
894
+ }
895
+ break;
896
+ case "modality":
897
+ const modalityId = operation !== "create" && operation !== "getAll"
898
+ ? this.getNodeParameter("modalityId", i)
899
+ : "";
900
+ switch (operation) {
901
+ case "create":
902
+ endpoint = "/modalities";
903
+ method = "POST";
904
+ break;
905
+ case "getAll":
906
+ endpoint = "/modalities";
907
+ break;
908
+ case "get":
909
+ endpoint = `/modalities/${modalityId}`;
910
+ break;
911
+ case "update":
912
+ endpoint = `/modalities/${modalityId}`;
913
+ method = "PUT";
914
+ break;
915
+ case "activate":
916
+ endpoint = `/modalities/${modalityId}/active`;
917
+ method = "PUT";
918
+ break;
919
+ case "deactivate":
920
+ endpoint = `/modalities/${modalityId}/inactive`;
921
+ method = "PUT";
922
+ break;
923
+ }
924
+ break;
925
+ case "ticket":
926
+ const ticketId = operation !== "create" && operation !== "getAll"
927
+ ? this.getNodeParameter("ticketId", i)
928
+ : "";
929
+ switch (operation) {
930
+ case "create":
931
+ endpoint = "/tickets";
932
+ method = "POST";
933
+ break;
934
+ case "getAll":
935
+ endpoint = "/tickets";
936
+ break;
937
+ case "get":
938
+ endpoint = `/tickets/${ticketId}`;
939
+ break;
940
+ case "update":
941
+ endpoint = `/tickets/${ticketId}`;
942
+ method = "PUT";
943
+ break;
944
+ case "activate":
945
+ endpoint = "/tickets/active";
946
+ method = "PUT";
947
+ break;
948
+ case "deactivate":
949
+ endpoint = "/tickets/inactive";
950
+ method = "PUT";
951
+ break;
952
+ }
953
+ break;
954
+ case "property":
955
+ const propertyId = operation !== "create" && operation !== "getAll"
956
+ ? this.getNodeParameter("propertyId", i)
957
+ : "";
958
+ switch (operation) {
959
+ case "create":
960
+ endpoint = "/properties";
961
+ method = "POST";
962
+ break;
963
+ case "getAll":
964
+ endpoint = "/properties";
965
+ break;
966
+ case "get":
967
+ endpoint = `/properties/${propertyId}`;
968
+ break;
969
+ case "update":
970
+ endpoint = `/properties/${propertyId}`;
971
+ method = "PUT";
972
+ break;
973
+ case "activate":
974
+ endpoint = `/properties/${propertyId}/active`;
975
+ method = "PATCH";
976
+ break;
977
+ case "deactivate":
978
+ endpoint = `/properties/${propertyId}/inactive`;
979
+ method = "PATCH";
980
+ break;
981
+ }
982
+ break;
267
983
  }
268
- // Make the request
984
+ // Make the HTTP request
269
985
  const url = `${baseUrl}${endpoint}`;
270
986
  const options = {
271
987
  method,
272
988
  uri: url,
273
989
  headers: {
274
- 'Authorization': `Bearer ${bearerToken}`,
275
- 'X-API-DOMAIN': apiDomain,
276
- 'X-APIKEY-TOKEN': apiKeyToken,
277
- 'Content-Type': 'application/json',
990
+ Authorization: `Bearer ${bearerToken}`,
991
+ "X-API-DOMAIN": apiDomain,
992
+ "X-APIKEY-TOKEN": apiKeyToken,
993
+ "Content-Type": "application/json",
278
994
  },
279
995
  json: true,
280
996
  };
281
- if (method !== 'GET' && Object.keys(body).length > 0) {
282
- options['body'] = body;
997
+ if (method !== "GET" &&
998
+ method !== "DELETE" &&
999
+ Object.keys(body).length > 0) {
1000
+ options.body = body;
283
1001
  }
284
1002
  const responseData = await this.helpers.request(options);
285
1003
  returnData.push({
@@ -290,14 +1008,14 @@ class ApiConfirm8 {
290
1008
  catch (error) {
291
1009
  if (this.continueOnFail()) {
292
1010
  returnData.push({
293
- json: {
294
- error: error || 'Unknown Error',
295
- },
1011
+ json: { error: error || "Unknown Error" },
296
1012
  pairedItem: { item: i },
297
1013
  });
298
1014
  continue;
299
1015
  }
300
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
1016
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
1017
+ itemIndex: i,
1018
+ });
301
1019
  }
302
1020
  }
303
1021
  return [returnData];