n8n-nodes-digitalsac 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,12 @@ Este pacote adiciona um nó personalizado ao n8n para interagir com a API do Dig
20
20
  - Vincular Kanban
21
21
  - Listar Carteiras
22
22
  - Vincular Carteira
23
+ - **Agendamento:**
24
+ - Listar Serviços
25
+ - Listar Usuários Disponíveis
26
+ - Listar Horários Disponíveis
27
+ - Criar Agendamento
28
+ - Cancelar Agendamento
23
29
 
24
30
  ## Instalação
25
31
 
@@ -323,6 +329,85 @@ Onde:
323
329
  }
324
330
  ```
325
331
 
332
+ ## Funcionalidades de Agendamento
333
+
334
+ ### Listar Serviços
335
+ Lista todos os serviços disponíveis para agendamento.
336
+ 1. Selecione a operação **Listar Serviços**
337
+ 2. (Opcional) No campo **ID do Usuário**, insira o ID do usuário para filtrar apenas os serviços que ele atende
338
+
339
+ **Retorno exemplo:**
340
+ ```json
341
+ {
342
+ "servicos": "*1* - Consulta (30min - R$ 100,00)\n*2* - Retorno (15min - R$ 50,00)"
343
+ }
344
+ ```
345
+
346
+ ### Listar Usuários Disponíveis
347
+ Lista os usuários/atendentes disponíveis para um serviço em uma data específica.
348
+ 1. Selecione a operação **Listar Usuários Disponíveis**
349
+ 2. Preencha:
350
+ - **ID do Serviço**: ID do serviço desejado
351
+ - **Data**: Data no formato YYYY-MM-DD (ex: 2025-08-07)
352
+ - **Horário** (opcional): Horário específico no formato HH:mm (ex: 09:00)
353
+
354
+ **Retorno exemplo:**
355
+ ```json
356
+ {
357
+ "usuarios": "*28* - João Silva\n*29* - Maria Santos"
358
+ }
359
+ ```
360
+
361
+ ### Listar Horários Disponíveis
362
+ Lista os horários disponíveis para um serviço e usuário em uma data específica.
363
+ 1. Selecione a operação **Listar Horários Disponíveis**
364
+ 2. Preencha:
365
+ - **ID do Serviço**: ID do serviço desejado
366
+ - **ID do Usuário**: ID do atendente/usuário
367
+ - **Data**: Data no formato YYYY-MM-DD
368
+
369
+ **Retorno exemplo:**
370
+ ```json
371
+ {
372
+ "horarios": "*1* - 09:00\n*2* - 09:30\n*3* - 10:00\n*4* - 10:30"
373
+ }
374
+ ```
375
+
376
+ ### Criar Agendamento
377
+ Cria um novo agendamento no sistema.
378
+ 1. Selecione a operação **Criar Agendamento**
379
+ 2. Preencha:
380
+ - **ID do Serviço**: ID do serviço
381
+ - **ID do Usuário**: ID do atendente/usuário
382
+ - **Data**: Data do agendamento (YYYY-MM-DD)
383
+ - **Horário**: Horário do agendamento (HH:mm)
384
+ - **Nome do Contato**: Nome do cliente
385
+ - **Telefone do Contato**: Telefone do cliente (formato: 5511999999999)
386
+ - **Observações** (opcional): Notas sobre o agendamento
387
+
388
+ **Retorno exemplo:**
389
+ ```json
390
+ {
391
+ "status": 0,
392
+ "mensagem": "Agendamento criado com sucesso",
393
+ "scheduleId": 123
394
+ }
395
+ ```
396
+
397
+ ### Cancelar Agendamento
398
+ Cancela um agendamento existente.
399
+ 1. Selecione a operação **Cancelar Agendamento**
400
+ 2. Preencha:
401
+ - **ID do Agendamento**: ID do agendamento a ser cancelado
402
+
403
+ **Retorno exemplo:**
404
+ ```json
405
+ {
406
+ "status": 0,
407
+ "mensagem": "Agendamento cancelado com sucesso"
408
+ }
409
+ ```
410
+
326
411
  ## Suporte
327
412
 
328
413
  Para suporte, entre em contato com [contato@digitalsac.io](mailto:contato@digitalsac.io).
@@ -43,6 +43,12 @@ class Digitalsac {
43
43
  { name: 'Vincular Kanban', value: 'linkKanban' },
44
44
  { name: 'Listar Carteiras', value: 'listCarteiras' },
45
45
  { name: 'Vincular Carteira', value: 'linkCarteira' },
46
+ // Agendamento
47
+ { name: 'Listar Serviços', value: 'listServices' },
48
+ { name: 'Listar Usuários Disponíveis', value: 'listAvailableUsers' },
49
+ { name: 'Listar Horários Disponíveis', value: 'listAvailableSlots' },
50
+ { name: 'Criar Agendamento', value: 'createSchedule' },
51
+ { name: 'Cancelar Agendamento', value: 'cancelSchedule' },
46
52
  ],
47
53
  default: 'validateWhatsapp',
48
54
  },
@@ -214,6 +220,118 @@ class Digitalsac {
214
220
  },
215
221
  description: 'ID do ticket e ID do usuário da carteira',
216
222
  },
223
+ // Campos para Agendamento
224
+ {
225
+ displayName: 'ID do Usuário',
226
+ name: 'scheduleUserId',
227
+ type: 'number',
228
+ default: 0,
229
+ displayOptions: {
230
+ show: {
231
+ operation: ['listServices'],
232
+ },
233
+ },
234
+ description: 'ID do usuário para filtrar serviços (opcional)',
235
+ },
236
+ {
237
+ displayName: 'ID do Serviço',
238
+ name: 'serviceId',
239
+ type: 'number',
240
+ default: 1,
241
+ displayOptions: {
242
+ show: {
243
+ operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
244
+ },
245
+ },
246
+ description: 'ID do serviço',
247
+ },
248
+ {
249
+ displayName: 'Data',
250
+ name: 'scheduleDate',
251
+ type: 'string',
252
+ default: '',
253
+ placeholder: '2025-08-07',
254
+ displayOptions: {
255
+ show: {
256
+ operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
257
+ },
258
+ },
259
+ description: 'Data no formato YYYY-MM-DD',
260
+ },
261
+ {
262
+ displayName: 'Horário',
263
+ name: 'scheduleTime',
264
+ type: 'string',
265
+ default: '',
266
+ placeholder: '09:00',
267
+ displayOptions: {
268
+ show: {
269
+ operation: ['listAvailableUsers', 'createSchedule'],
270
+ },
271
+ },
272
+ description: 'Horário no formato HH:mm (opcional para listar usuários)',
273
+ },
274
+ {
275
+ displayName: 'ID do Usuário',
276
+ name: 'scheduleAttendantId',
277
+ type: 'number',
278
+ default: 1,
279
+ displayOptions: {
280
+ show: {
281
+ operation: ['listAvailableSlots', 'createSchedule'],
282
+ },
283
+ },
284
+ description: 'ID do atendente/usuário',
285
+ },
286
+ {
287
+ displayName: 'Nome do Contato',
288
+ name: 'contactName',
289
+ type: 'string',
290
+ default: '',
291
+ displayOptions: {
292
+ show: {
293
+ operation: ['createSchedule'],
294
+ },
295
+ },
296
+ description: 'Nome do cliente/contato',
297
+ },
298
+ {
299
+ displayName: 'Telefone do Contato',
300
+ name: 'contactPhone',
301
+ type: 'string',
302
+ default: '',
303
+ placeholder: '5511999999999',
304
+ displayOptions: {
305
+ show: {
306
+ operation: ['createSchedule'],
307
+ },
308
+ },
309
+ description: 'Telefone do cliente/contato',
310
+ },
311
+ {
312
+ displayName: 'Observações',
313
+ name: 'scheduleNotes',
314
+ type: 'string',
315
+ default: '',
316
+ displayOptions: {
317
+ show: {
318
+ operation: ['createSchedule'],
319
+ },
320
+ },
321
+ description: 'Observações sobre o agendamento (opcional)',
322
+ },
323
+ {
324
+ displayName: 'ID do Agendamento',
325
+ name: 'scheduleId',
326
+ type: 'number',
327
+ default: 0,
328
+ displayOptions: {
329
+ show: {
330
+ operation: ['cancelSchedule'],
331
+ },
332
+ },
333
+ description: 'ID do agendamento a ser cancelado',
334
+ },
217
335
  ],
218
336
  };
219
337
  }
@@ -474,6 +592,75 @@ class Digitalsac {
474
592
  json: true,
475
593
  };
476
594
  break;
595
+ // Casos para Agendamento
596
+ case 'listServices':
597
+ const scheduleUserId = this.getNodeParameter('scheduleUserId', i);
598
+ if (scheduleUserId > 0) {
599
+ url = `/typebot/listar_servicos?userId=${scheduleUserId}`;
600
+ }
601
+ else {
602
+ url = '/typebot/listar_servicos';
603
+ }
604
+ break;
605
+ case 'listAvailableUsers':
606
+ const serviceIdForUsers = this.getNodeParameter('serviceId', i);
607
+ const dateForUsers = this.getNodeParameter('scheduleDate', i);
608
+ const timeForUsers = this.getNodeParameter('scheduleTime', i);
609
+ url = `/typebot/listar_usuarios_disponiveis?serviceId=${serviceIdForUsers}&date=${dateForUsers}`;
610
+ if (timeForUsers) {
611
+ url += `&time=${timeForUsers}`;
612
+ }
613
+ break;
614
+ case 'listAvailableSlots':
615
+ const serviceIdForSlots = this.getNodeParameter('serviceId', i);
616
+ const userIdForSlots = this.getNodeParameter('scheduleAttendantId', i);
617
+ const dateForSlots = this.getNodeParameter('scheduleDate', i);
618
+ url = `/typebot/listar_horarios_disponiveis?serviceId=${serviceIdForSlots}&userId=${userIdForSlots}&date=${dateForSlots}`;
619
+ break;
620
+ case 'createSchedule':
621
+ url = '/typebot/criar_agendamento';
622
+ method = 'POST';
623
+ const serviceIdForCreate = this.getNodeParameter('serviceId', i);
624
+ const userIdForCreate = this.getNodeParameter('scheduleAttendantId', i);
625
+ const dateForCreate = this.getNodeParameter('scheduleDate', i);
626
+ const timeForCreate = this.getNodeParameter('scheduleTime', i);
627
+ const contactNameForCreate = this.getNodeParameter('contactName', i);
628
+ const contactPhoneForCreate = this.getNodeParameter('contactPhone', i);
629
+ const notesForCreate = this.getNodeParameter('scheduleNotes', i);
630
+ body = {
631
+ serviceId: serviceIdForCreate,
632
+ userId: userIdForCreate,
633
+ date: dateForCreate,
634
+ time: timeForCreate,
635
+ contactName: contactNameForCreate,
636
+ contactPhone: contactPhoneForCreate,
637
+ notes: notesForCreate
638
+ };
639
+ headers['Content-Type'] = 'application/json';
640
+ options = {
641
+ method,
642
+ headers,
643
+ body,
644
+ uri: `${baseUrl}${url}`,
645
+ json: true,
646
+ };
647
+ break;
648
+ case 'cancelSchedule':
649
+ url = '/typebot/cancelar_agendamento';
650
+ method = 'POST';
651
+ const scheduleIdForCancel = this.getNodeParameter('scheduleId', i);
652
+ body = {
653
+ scheduleId: scheduleIdForCancel
654
+ };
655
+ headers['Content-Type'] = 'application/json';
656
+ options = {
657
+ method,
658
+ headers,
659
+ body,
660
+ uri: `${baseUrl}${url}`,
661
+ json: true,
662
+ };
663
+ break;
477
664
  }
478
665
  // Se as opções não foram definidas no switch, defina-as aqui para operações GET
479
666
  if (!options.method) {
@@ -50,6 +50,12 @@ export class Digitalsac implements INodeType {
50
50
  { name: 'Vincular Kanban', value: 'linkKanban' },
51
51
  { name: 'Listar Carteiras', value: 'listCarteiras' },
52
52
  { name: 'Vincular Carteira', value: 'linkCarteira' },
53
+ // Agendamento
54
+ { name: 'Listar Serviços', value: 'listServices' },
55
+ { name: 'Listar Usuários Disponíveis', value: 'listAvailableUsers' },
56
+ { name: 'Listar Horários Disponíveis', value: 'listAvailableSlots' },
57
+ { name: 'Criar Agendamento', value: 'createSchedule' },
58
+ { name: 'Cancelar Agendamento', value: 'cancelSchedule' },
53
59
  ],
54
60
  default: 'validateWhatsapp',
55
61
  },
@@ -221,6 +227,118 @@ export class Digitalsac implements INodeType {
221
227
  },
222
228
  description: 'ID do ticket e ID do usuário da carteira',
223
229
  },
230
+ // Campos para Agendamento
231
+ {
232
+ displayName: 'ID do Usuário',
233
+ name: 'scheduleUserId',
234
+ type: 'number',
235
+ default: 0,
236
+ displayOptions: {
237
+ show: {
238
+ operation: ['listServices'],
239
+ },
240
+ },
241
+ description: 'ID do usuário para filtrar serviços (opcional)',
242
+ },
243
+ {
244
+ displayName: 'ID do Serviço',
245
+ name: 'serviceId',
246
+ type: 'number',
247
+ default: 1,
248
+ displayOptions: {
249
+ show: {
250
+ operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
251
+ },
252
+ },
253
+ description: 'ID do serviço',
254
+ },
255
+ {
256
+ displayName: 'Data',
257
+ name: 'scheduleDate',
258
+ type: 'string',
259
+ default: '',
260
+ placeholder: '2025-08-07',
261
+ displayOptions: {
262
+ show: {
263
+ operation: ['listAvailableUsers', 'listAvailableSlots', 'createSchedule'],
264
+ },
265
+ },
266
+ description: 'Data no formato YYYY-MM-DD',
267
+ },
268
+ {
269
+ displayName: 'Horário',
270
+ name: 'scheduleTime',
271
+ type: 'string',
272
+ default: '',
273
+ placeholder: '09:00',
274
+ displayOptions: {
275
+ show: {
276
+ operation: ['listAvailableUsers', 'createSchedule'],
277
+ },
278
+ },
279
+ description: 'Horário no formato HH:mm (opcional para listar usuários)',
280
+ },
281
+ {
282
+ displayName: 'ID do Usuário',
283
+ name: 'scheduleAttendantId',
284
+ type: 'number',
285
+ default: 1,
286
+ displayOptions: {
287
+ show: {
288
+ operation: ['listAvailableSlots', 'createSchedule'],
289
+ },
290
+ },
291
+ description: 'ID do atendente/usuário',
292
+ },
293
+ {
294
+ displayName: 'Nome do Contato',
295
+ name: 'contactName',
296
+ type: 'string',
297
+ default: '',
298
+ displayOptions: {
299
+ show: {
300
+ operation: ['createSchedule'],
301
+ },
302
+ },
303
+ description: 'Nome do cliente/contato',
304
+ },
305
+ {
306
+ displayName: 'Telefone do Contato',
307
+ name: 'contactPhone',
308
+ type: 'string',
309
+ default: '',
310
+ placeholder: '5511999999999',
311
+ displayOptions: {
312
+ show: {
313
+ operation: ['createSchedule'],
314
+ },
315
+ },
316
+ description: 'Telefone do cliente/contato',
317
+ },
318
+ {
319
+ displayName: 'Observações',
320
+ name: 'scheduleNotes',
321
+ type: 'string',
322
+ default: '',
323
+ displayOptions: {
324
+ show: {
325
+ operation: ['createSchedule'],
326
+ },
327
+ },
328
+ description: 'Observações sobre o agendamento (opcional)',
329
+ },
330
+ {
331
+ displayName: 'ID do Agendamento',
332
+ name: 'scheduleId',
333
+ type: 'number',
334
+ default: 0,
335
+ displayOptions: {
336
+ show: {
337
+ operation: ['cancelSchedule'],
338
+ },
339
+ },
340
+ description: 'ID do agendamento a ser cancelado',
341
+ },
224
342
  ],
225
343
  };
226
344
 
@@ -489,6 +607,87 @@ export class Digitalsac implements INodeType {
489
607
  json: true,
490
608
  };
491
609
  break;
610
+
611
+ // Casos para Agendamento
612
+ case 'listServices':
613
+ const scheduleUserId = this.getNodeParameter('scheduleUserId', i) as number;
614
+ if (scheduleUserId > 0) {
615
+ url = `/typebot/listar_servicos?userId=${scheduleUserId}`;
616
+ } else {
617
+ url = '/typebot/listar_servicos';
618
+ }
619
+ break;
620
+
621
+ case 'listAvailableUsers':
622
+ const serviceIdForUsers = this.getNodeParameter('serviceId', i) as number;
623
+ const dateForUsers = this.getNodeParameter('scheduleDate', i) as string;
624
+ const timeForUsers = this.getNodeParameter('scheduleTime', i) as string;
625
+
626
+ url = `/typebot/listar_usuarios_disponiveis?serviceId=${serviceIdForUsers}&date=${dateForUsers}`;
627
+ if (timeForUsers) {
628
+ url += `&time=${timeForUsers}`;
629
+ }
630
+ break;
631
+
632
+ case 'listAvailableSlots':
633
+ const serviceIdForSlots = this.getNodeParameter('serviceId', i) as number;
634
+ const userIdForSlots = this.getNodeParameter('scheduleAttendantId', i) as number;
635
+ const dateForSlots = this.getNodeParameter('scheduleDate', i) as string;
636
+
637
+ url = `/typebot/listar_horarios_disponiveis?serviceId=${serviceIdForSlots}&userId=${userIdForSlots}&date=${dateForSlots}`;
638
+ break;
639
+
640
+ case 'createSchedule':
641
+ url = '/typebot/criar_agendamento';
642
+ method = 'POST';
643
+
644
+ const serviceIdForCreate = this.getNodeParameter('serviceId', i) as number;
645
+ const userIdForCreate = this.getNodeParameter('scheduleAttendantId', i) as number;
646
+ const dateForCreate = this.getNodeParameter('scheduleDate', i) as string;
647
+ const timeForCreate = this.getNodeParameter('scheduleTime', i) as string;
648
+ const contactNameForCreate = this.getNodeParameter('contactName', i) as string;
649
+ const contactPhoneForCreate = this.getNodeParameter('contactPhone', i) as string;
650
+ const notesForCreate = this.getNodeParameter('scheduleNotes', i) as string;
651
+
652
+ body = {
653
+ serviceId: serviceIdForCreate,
654
+ userId: userIdForCreate,
655
+ date: dateForCreate,
656
+ time: timeForCreate,
657
+ contactName: contactNameForCreate,
658
+ contactPhone: contactPhoneForCreate,
659
+ notes: notesForCreate
660
+ };
661
+
662
+ headers['Content-Type'] = 'application/json';
663
+ options = {
664
+ method,
665
+ headers,
666
+ body,
667
+ uri: `${baseUrl}${url}`,
668
+ json: true,
669
+ };
670
+ break;
671
+
672
+ case 'cancelSchedule':
673
+ url = '/typebot/cancelar_agendamento';
674
+ method = 'POST';
675
+
676
+ const scheduleIdForCancel = this.getNodeParameter('scheduleId', i) as number;
677
+
678
+ body = {
679
+ scheduleId: scheduleIdForCancel
680
+ };
681
+
682
+ headers['Content-Type'] = 'application/json';
683
+ options = {
684
+ method,
685
+ headers,
686
+ body,
687
+ uri: `${baseUrl}${url}`,
688
+ json: true,
689
+ };
690
+ break;
492
691
  }
493
692
 
494
693
  // Se as opções não foram definidas no switch, defina-as aqui para operações GET
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-digitalsac",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Izing Pro Digitalsac",
5
5
  "keywords": [
6
6
  "n8n",
@@ -49,7 +49,7 @@
49
49
  "n8n-core": "^1.0.0",
50
50
  "n8n-workflow": "^1.0.0",
51
51
  "prettier": "^2.8.8",
52
- "typescript": "^5.0.0"
52
+ "typescript": "^5.9.2"
53
53
  },
54
54
  "dependencies": {
55
55
  "axios": "^1.9.0"