n8n-nodes-digitalsac 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import { ICredentialType, NodePropertyTypes } from 'n8n-workflow';
2
+ export declare class DigitalsacApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: ({
7
+ displayName: string;
8
+ name: string;
9
+ type: NodePropertyTypes;
10
+ default: string;
11
+ description: string;
12
+ } | {
13
+ displayName: string;
14
+ name: string;
15
+ type: NodePropertyTypes;
16
+ default: string;
17
+ description?: undefined;
18
+ })[];
19
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DigitalsacApi = void 0;
4
+ class DigitalsacApi {
5
+ constructor() {
6
+ this.name = 'digitalsacApi';
7
+ this.displayName = 'Izing Pro Digitalsac API';
8
+ this.documentationUrl = '';
9
+ this.properties = [
10
+ {
11
+ displayName: 'API Base URL',
12
+ name: 'baseUrl',
13
+ type: 'string',
14
+ default: 'https://example.digitalsac.io',
15
+ description: 'Ex: https://seudominio.digitalsac.com.br',
16
+ },
17
+ {
18
+ displayName: 'Bearer Token',
19
+ name: 'token',
20
+ type: 'string',
21
+ default: '',
22
+ },
23
+ ];
24
+ }
25
+ }
26
+ exports.DigitalsacApi = DigitalsacApi;
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Digitalsac implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Digitalsac = void 0;
4
+ class Digitalsac {
5
+ constructor() {
6
+ this.description = {
7
+ displayName: 'Digitalsac Izing Pro',
8
+ name: 'digitalsac',
9
+ icon: 'file:digitalsac.svg',
10
+ group: ['transform'],
11
+ version: 1,
12
+ description: 'Interage com a API do Digitalsac',
13
+ defaults: {
14
+ name: 'Digitalsac',
15
+ },
16
+ inputs: ['main'],
17
+ outputs: ['main'],
18
+ credentials: [
19
+ {
20
+ name: 'digitalsacApi',
21
+ required: true,
22
+ },
23
+ ],
24
+ properties: [
25
+ {
26
+ displayName: 'Operação',
27
+ name: 'operation',
28
+ type: 'options',
29
+ options: [
30
+ { name: 'Validar WhatsApp', value: 'validateWhatsapp' },
31
+ { name: 'Validar CPF', value: 'validateCpf' },
32
+ { name: 'Validar Data', value: 'validateDate' },
33
+ { name: 'Listar Filas', value: 'listQueues' },
34
+ { name: 'Listar Atendentes', value: 'listAgents' },
35
+ { name: 'Transferir para Fila', value: 'transferQueue' },
36
+ { name: 'Transferir para Atendente', value: 'transferAgent' },
37
+ { name: 'Fechar Ticket', value: 'closeTicket' },
38
+ { name: 'Enviar Mensagem', value: 'sendMessage' },
39
+ ],
40
+ default: 'validateWhatsapp',
41
+ },
42
+ {
43
+ displayName: 'Parâmetro',
44
+ name: 'param',
45
+ type: 'string',
46
+ default: '',
47
+ displayOptions: {
48
+ show: {
49
+ operation: ['validateWhatsapp', 'validateCpf', 'sendMessage'],
50
+ },
51
+ },
52
+ description: 'Número, CPF ou UUID da mensagem (conforme operação)',
53
+ },
54
+ {
55
+ displayName: 'Dados (JSON)',
56
+ name: 'bodyData',
57
+ type: 'json',
58
+ default: '',
59
+ displayOptions: {
60
+ show: {
61
+ operation: ['validateDate', 'transferQueue', 'transferAgent', 'closeTicket', 'sendMessage'],
62
+ },
63
+ },
64
+ },
65
+ ],
66
+ };
67
+ }
68
+ async execute() {
69
+ const items = this.getInputData();
70
+ const returnData = [];
71
+ const credentials = await this.getCredentials('digitalsacApi');
72
+ const baseUrl = credentials.baseUrl;
73
+ const token = credentials.token;
74
+ for (let i = 0; i < items.length; i++) {
75
+ const operation = this.getNodeParameter('operation', i);
76
+ let responseData;
77
+ const headers = {
78
+ Authorization: `Bearer ${token}`,
79
+ 'Content-Type': 'application/json',
80
+ Accept: 'application/json',
81
+ };
82
+ let url = '';
83
+ let method = 'GET';
84
+ let body;
85
+ let param = this.getNodeParameter('param', i, '');
86
+ switch (operation) {
87
+ case 'validateWhatsapp':
88
+ url = `/typebot/whatsappnumber/${param}`;
89
+ break;
90
+ case 'validateCpf':
91
+ url = `/typebot/validate/cpf/${param}`;
92
+ break;
93
+ case 'validateDate':
94
+ url = '/typebot/validate/data';
95
+ method = 'POST';
96
+ body = this.getNodeParameter('bodyData', i);
97
+ break;
98
+ case 'listQueues':
99
+ url = '/typebot/listar_filas';
100
+ break;
101
+ case 'listAgents':
102
+ url = '/typebot/listar_atendentes';
103
+ break;
104
+ case 'transferQueue':
105
+ url = '/typebot/transferir_para_fila';
106
+ method = 'POST';
107
+ body = this.getNodeParameter('bodyData', i);
108
+ break;
109
+ case 'transferAgent':
110
+ url = '/typebot/transferir_para_atendente';
111
+ method = 'POST';
112
+ body = this.getNodeParameter('bodyData', i);
113
+ break;
114
+ case 'closeTicket':
115
+ url = '/typebot/fechar_ticket';
116
+ method = 'POST';
117
+ body = this.getNodeParameter('bodyData', i);
118
+ break;
119
+ case 'sendMessage':
120
+ url = `/v1/api/external/${param}`;
121
+ method = 'POST';
122
+ body = this.getNodeParameter('bodyData', i);
123
+ break;
124
+ }
125
+ const options = {
126
+ method,
127
+ headers,
128
+ body: body ? JSON.stringify(body) : undefined,
129
+ uri: `${baseUrl}${url}`,
130
+ json: true,
131
+ };
132
+ responseData = await this.helpers.request(options);
133
+ returnData.push({ json: responseData });
134
+ }
135
+ return [returnData];
136
+ }
137
+ }
138
+ exports.Digitalsac = Digitalsac;
package/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Digitalsac } from './nodes/Digitalsac/Digitalsac.node';
2
+ import { DigitalsacApi } from './nodes/Digitalsac/Digitalsac.credentials';
3
+
4
+ export const nodes = [Digitalsac];
5
+ export const credentials = [DigitalsacApi];
@@ -3,6 +3,7 @@ import {
3
3
  INodeExecutionData,
4
4
  INodeType,
5
5
  INodeTypeDescription,
6
+ NodeConnectionType,
6
7
  } from 'n8n-workflow';
7
8
 
8
9
  export class Digitalsac implements INodeType {
@@ -16,8 +17,9 @@ export class Digitalsac implements INodeType {
16
17
  defaults: {
17
18
  name: 'Digitalsac',
18
19
  },
19
- inputs: ['main'],
20
- outputs: ['main'],
20
+ inputs: <NodeConnectionType[]>['main'],
21
+ outputs: <NodeConnectionType[]>['main'],
22
+
21
23
  credentials: [
22
24
  {
23
25
  name: 'digitalsacApi',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-digitalsac",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Izing Pro Digitalsac",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {