n8n-nodes-new-evolution-api 3.0.7 → 3.1.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/dist/nodes/EvolutionApi/EvolutionApiTrigger.node.js +9 -4
- package/dist/nodes/EvolutionApi/EvolutionApiTrigger.node.js.map +1 -1
- package/dist/nodes/EvolutionApi/execute/index.js +12 -0
- package/dist/nodes/EvolutionApi/execute/index.js.map +1 -1
- package/dist/nodes/EvolutionApi/execute/messages/sendAlbum.d.ts +25 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendAlbum.js +93 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendAlbum.js.map +1 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendCarousel.d.ts +25 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendCarousel.js +140 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendCarousel.js.map +1 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendCollection.d.ts +25 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendCollection.js +96 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendCollection.js.map +1 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendPix.js +35 -15
- package/dist/nodes/EvolutionApi/execute/messages/sendPix.js.map +1 -1
- package/dist/nodes/EvolutionApi/execute/messages/sendShop.d.ts +25 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendShop.js +97 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendShop.js.map +1 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendStatusMentions.d.ts +25 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendStatusMentions.js +93 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendStatusMentions.js.map +1 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendStickerPack.d.ts +25 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendStickerPack.js +90 -0
- package/dist/nodes/EvolutionApi/execute/messages/sendStickerPack.js.map +1 -0
- package/dist/nodes/EvolutionApi/properties/messages.fields.js +849 -0
- package/dist/nodes/EvolutionApi/properties/messages.fields.js.map +1 -1
- package/dist/nodes/EvolutionApi/properties/messages.operations.js +37 -1
- package/dist/nodes/EvolutionApi/properties/messages.operations.js.map +1 -1
- package/dist/package.json +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendCollection = sendCollection;
|
|
4
|
+
const evolutionRequest_1 = require("../evolutionRequest");
|
|
5
|
+
async function sendCollection(ef) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
try {
|
|
8
|
+
const instanceName = ef.getNodeParameter('instanceName', 0);
|
|
9
|
+
const recipientType = ef.getNodeParameter('recipientType', 0, 'number');
|
|
10
|
+
let remoteJid;
|
|
11
|
+
if (recipientType === 'group') {
|
|
12
|
+
remoteJid = ef.getNodeParameter('groupJid', 0);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
remoteJid = ef.getNodeParameter('remoteJid', 0);
|
|
16
|
+
}
|
|
17
|
+
const businessJid = ef.getNodeParameter('businessJid', 0);
|
|
18
|
+
const collectionId = ef.getNodeParameter('collectionId', 0);
|
|
19
|
+
const title = ef.getNodeParameter('collectionTitle', 0, '');
|
|
20
|
+
const body = ef.getNodeParameter('collectionBody', 0, '');
|
|
21
|
+
const subtitle = ef.getNodeParameter('collectionSubtitle', 0, '');
|
|
22
|
+
const footer = ef.getNodeParameter('collectionFooter', 0, '');
|
|
23
|
+
const version = ef.getNodeParameter('collectionVersion', 0, 1);
|
|
24
|
+
const imageUrl = ef.getNodeParameter('collectionImageUrl', 0, '');
|
|
25
|
+
const viewOnce = ef.getNodeParameter('collectionViewOnce', 0, false);
|
|
26
|
+
const options = ef.getNodeParameter('options_message', 0, {});
|
|
27
|
+
const body_request = {
|
|
28
|
+
number: remoteJid,
|
|
29
|
+
businessJid,
|
|
30
|
+
collectionId,
|
|
31
|
+
};
|
|
32
|
+
if (title)
|
|
33
|
+
body_request.title = title;
|
|
34
|
+
if (body)
|
|
35
|
+
body_request.body = body;
|
|
36
|
+
if (subtitle)
|
|
37
|
+
body_request.subtitle = subtitle;
|
|
38
|
+
if (footer)
|
|
39
|
+
body_request.footer = footer;
|
|
40
|
+
if (version)
|
|
41
|
+
body_request.version = version;
|
|
42
|
+
if (imageUrl)
|
|
43
|
+
body_request.imageUrl = imageUrl;
|
|
44
|
+
if (viewOnce)
|
|
45
|
+
body_request.viewOnce = viewOnce;
|
|
46
|
+
if (options.delay)
|
|
47
|
+
body_request.delay = options.delay;
|
|
48
|
+
if ((_b = (_a = options.quoted) === null || _a === void 0 ? void 0 : _a.messageQuoted) === null || _b === void 0 ? void 0 : _b.messageId) {
|
|
49
|
+
body_request.quoted = {
|
|
50
|
+
key: {
|
|
51
|
+
id: options.quoted.messageQuoted.messageId,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if ((_c = options.mentions) === null || _c === void 0 ? void 0 : _c.mentionsSettings) {
|
|
56
|
+
const { mentionsEveryOne, mentioned } = options.mentions.mentionsSettings;
|
|
57
|
+
if (mentionsEveryOne) {
|
|
58
|
+
body_request.mentionsEveryOne = true;
|
|
59
|
+
}
|
|
60
|
+
else if (mentioned) {
|
|
61
|
+
body_request.mentioned = mentioned.split(',').map((m) => m.trim());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const requestOptions = {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
headers: {
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
},
|
|
69
|
+
uri: `/message/sendCollection/${instanceName}`,
|
|
70
|
+
body: body_request,
|
|
71
|
+
json: true,
|
|
72
|
+
};
|
|
73
|
+
const response = await (0, evolutionRequest_1.evolutionRequest)(ef, requestOptions);
|
|
74
|
+
return {
|
|
75
|
+
json: {
|
|
76
|
+
success: true,
|
|
77
|
+
data: response,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
const errorData = {
|
|
83
|
+
success: false,
|
|
84
|
+
error: {
|
|
85
|
+
message: 'Erro ao enviar collection',
|
|
86
|
+
details: error instanceof Error ? error.message : 'Erro desconhecido',
|
|
87
|
+
timestamp: new Date().toISOString(),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
json: errorData,
|
|
92
|
+
error: errorData,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=sendCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendCollection.js","sourceRoot":"","sources":["../../../../../nodes/EvolutionApi/execute/messages/sendCollection.ts"],"names":[],"mappings":";;AAOA,wCA8GC;AAhHD,0DAAuD;AAEhD,KAAK,UAAU,cAAc,CAAC,EAAqB;;IACzD,IAAI,CAAC;QAEJ,MAAM,YAAY,GAAG,EAAE,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAW,CAAC;QAGtE,MAAM,aAAa,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,EAAE,QAAQ,CAAW,CAAC;QAClF,IAAI,SAAiB,CAAC;QAEtB,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;YAC/B,SAAS,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAW,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,SAAS,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAW,CAAC;QAC3D,CAAC;QAGD,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAW,CAAC;QACpE,MAAM,YAAY,GAAG,EAAE,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAW,C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,CAAC;QAChB,MAAM,SAAS,GAAG;YACjB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACN,OAAO,EAAE,2BAA2B;gBACpC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;gBACrE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACnC;SACD,CAAC;QACF,OAAO;YACN,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;SAChB,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.sendPix = sendPix;
|
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const evolutionRequest_1 = require("../evolutionRequest");
|
|
6
6
|
async function sendPix(ef) {
|
|
7
|
+
var _a, _b;
|
|
7
8
|
try {
|
|
8
9
|
const instanceName = ef.getNodeParameter('instanceName', 0);
|
|
9
10
|
const recipientType = ef.getNodeParameter('recipientType', 0, 'number');
|
|
@@ -14,15 +15,16 @@ async function sendPix(ef) {
|
|
|
14
15
|
else {
|
|
15
16
|
remoteJid = ef.getNodeParameter('remoteJid', 0);
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
+
const merchantName = ef.getNodeParameter('name', 0);
|
|
18
19
|
const keyType = ef.getNodeParameter('keyType', 0);
|
|
19
20
|
let body;
|
|
21
|
+
let endpoint;
|
|
20
22
|
if (keyType === 'emv') {
|
|
21
23
|
const emvCode = ef.getNodeParameter('emvCode', 0);
|
|
22
24
|
const buttonText = ef.getNodeParameter('buttonText', 0, 'Copiar código PIX');
|
|
23
25
|
body = {
|
|
24
26
|
number: remoteJid,
|
|
25
|
-
title:
|
|
27
|
+
title: merchantName,
|
|
26
28
|
buttons: [
|
|
27
29
|
{
|
|
28
30
|
type: 'copy',
|
|
@@ -31,15 +33,25 @@ async function sendPix(ef) {
|
|
|
31
33
|
},
|
|
32
34
|
],
|
|
33
35
|
};
|
|
36
|
+
endpoint = `/message/sendButtons/${instanceName}`;
|
|
34
37
|
}
|
|
35
38
|
else {
|
|
36
|
-
const validKeyTypes = ['
|
|
37
|
-
|
|
39
|
+
const validKeyTypes = ['PHONE', 'EMAIL', 'CPF', 'CNPJ', 'EVP'];
|
|
40
|
+
const keyTypeUpper = keyType.toUpperCase();
|
|
41
|
+
const keyTypeMapping = {
|
|
42
|
+
'phone': 'PHONE',
|
|
43
|
+
'email': 'EMAIL',
|
|
44
|
+
'cpf': 'CPF',
|
|
45
|
+
'cnpj': 'CNPJ',
|
|
46
|
+
'random': 'EVP',
|
|
47
|
+
};
|
|
48
|
+
const mappedKeyType = keyTypeMapping[keyType.toLowerCase()] || keyTypeUpper;
|
|
49
|
+
if (!validKeyTypes.includes(mappedKeyType)) {
|
|
38
50
|
const errorData = {
|
|
39
51
|
success: false,
|
|
40
52
|
error: {
|
|
41
53
|
message: 'Tipo de chave PIX inválida',
|
|
42
|
-
details: 'O tipo de chave PIX deve ser:
|
|
54
|
+
details: 'O tipo de chave PIX deve ser: PHONE, EMAIL, CPF, CNPJ, EVP ou emv',
|
|
43
55
|
code: 'INVALID_PIX_KEY_TYPE',
|
|
44
56
|
timestamp: new Date().toISOString(),
|
|
45
57
|
},
|
|
@@ -50,17 +62,25 @@ async function sendPix(ef) {
|
|
|
50
62
|
};
|
|
51
63
|
}
|
|
52
64
|
const key = ef.getNodeParameter('key', 0);
|
|
65
|
+
const text = ef.getNodeParameter('pixText', 0, '');
|
|
53
66
|
body = {
|
|
54
67
|
number: remoteJid,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
merchantName,
|
|
69
|
+
key,
|
|
70
|
+
keyType: mappedKeyType,
|
|
71
|
+
};
|
|
72
|
+
if (text)
|
|
73
|
+
body.text = text;
|
|
74
|
+
endpoint = `/message/sendPix/${instanceName}`;
|
|
75
|
+
}
|
|
76
|
+
const options = ef.getNodeParameter('options_message', 0, {});
|
|
77
|
+
if (options.delay)
|
|
78
|
+
body.delay = options.delay;
|
|
79
|
+
if ((_b = (_a = options.quoted) === null || _a === void 0 ? void 0 : _a.messageQuoted) === null || _b === void 0 ? void 0 : _b.messageId) {
|
|
80
|
+
body.quoted = {
|
|
81
|
+
key: {
|
|
82
|
+
id: options.quoted.messageQuoted.messageId,
|
|
83
|
+
},
|
|
64
84
|
};
|
|
65
85
|
}
|
|
66
86
|
const requestOptions = {
|
|
@@ -68,7 +88,7 @@ async function sendPix(ef) {
|
|
|
68
88
|
headers: {
|
|
69
89
|
'Content-Type': 'application/json',
|
|
70
90
|
},
|
|
71
|
-
uri:
|
|
91
|
+
uri: endpoint,
|
|
72
92
|
body,
|
|
73
93
|
json: true,
|
|
74
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPix.js","sourceRoot":"","sources":["../../../../../nodes/EvolutionApi/execute/messages/sendPix.ts"],"names":[],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"sendPix.js","sourceRoot":"","sources":["../../../../../nodes/EvolutionApi/execute/messages/sendPix.ts"],"names":[],"mappings":";;AAQA,0BAsJC;AA9JD,+CAKsB;AACtB,0DAAuD;AAEhD,KAAK,UAAU,OAAO,CAAC,EAAqB;;IAClD,IAAI,CAAC;QAEJ,MAAM,YAAY,GAAG,EAAE,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAW,CAAC;QAGtE,MAAM,aAAa,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,EAAE,QAAQ,CAAW,CAAC;QAClF,IAAI,SAAiB,CAAC;QAEtB,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;YAC/B,SAAS,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAW,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,SAAS,GAAG,EAAE,CAAC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IAAI;YACJ,IAAI,EAAE,IAAI;SACV,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,mCAAgB,EAAC,EAAE,EAAE,cAAc,CAAC,CAAC;QAC5D,OAAO;YACN,IAAI,EAAE;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,QAAQ;aACd;SACD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,SAAS,GAAG;YACjB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACN,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC;oBACzD,CAAC,CAAC,kCAAkC;oBACpC,CAAC,CAAC,0BAA0B;gBAC7B,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC;oBACzD,CAAC,CAAC,0EAA0E;oBAC5E,CAAC,CAAC,KAAK,CAAC,OAAO;gBAChB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,eAAe;gBACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACnC;SACD,CAAC;QAEF,IAAI,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC;YAC1B,MAAM,IAAI,iCAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE;gBACzD,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO;gBAChC,WAAW,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO;aACpC,CAAC,CAAC;QACJ,CAAC;QAED,OAAO;YACN,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;SAChB,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare function sendShop(ef: IExecuteFunctions): Promise<{
|
|
3
|
+
json: {
|
|
4
|
+
success: boolean;
|
|
5
|
+
data: any;
|
|
6
|
+
};
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
json: {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: {
|
|
12
|
+
message: string;
|
|
13
|
+
details: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
error: {
|
|
18
|
+
success: boolean;
|
|
19
|
+
error: {
|
|
20
|
+
message: string;
|
|
21
|
+
details: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendShop = sendShop;
|
|
4
|
+
const evolutionRequest_1 = require("../evolutionRequest");
|
|
5
|
+
async function sendShop(ef) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
try {
|
|
8
|
+
const instanceName = ef.getNodeParameter('instanceName', 0);
|
|
9
|
+
const recipientType = ef.getNodeParameter('recipientType', 0, 'number');
|
|
10
|
+
let remoteJid;
|
|
11
|
+
if (recipientType === 'group') {
|
|
12
|
+
remoteJid = ef.getNodeParameter('groupJid', 0);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
remoteJid = ef.getNodeParameter('remoteJid', 0);
|
|
16
|
+
}
|
|
17
|
+
const shopId = ef.getNodeParameter('shopId', 0);
|
|
18
|
+
const title = ef.getNodeParameter('shopTitle', 0, '');
|
|
19
|
+
const body = ef.getNodeParameter('shopBody', 0, '');
|
|
20
|
+
const subtitle = ef.getNodeParameter('shopSubtitle', 0, '');
|
|
21
|
+
const footer = ef.getNodeParameter('shopFooter', 0, '');
|
|
22
|
+
const surface = ef.getNodeParameter('shopSurface', 0, 1);
|
|
23
|
+
const imageUrl = ef.getNodeParameter('shopImageUrl', 0, '');
|
|
24
|
+
const videoUrl = ef.getNodeParameter('shopVideoUrl', 0, '');
|
|
25
|
+
const viewOnce = ef.getNodeParameter('shopViewOnce', 0, false);
|
|
26
|
+
const options = ef.getNodeParameter('options_message', 0, {});
|
|
27
|
+
const body_request = {
|
|
28
|
+
number: remoteJid,
|
|
29
|
+
shopId,
|
|
30
|
+
};
|
|
31
|
+
if (title)
|
|
32
|
+
body_request.title = title;
|
|
33
|
+
if (body)
|
|
34
|
+
body_request.body = body;
|
|
35
|
+
if (subtitle)
|
|
36
|
+
body_request.subtitle = subtitle;
|
|
37
|
+
if (footer)
|
|
38
|
+
body_request.footer = footer;
|
|
39
|
+
if (surface)
|
|
40
|
+
body_request.surface = surface;
|
|
41
|
+
if (imageUrl)
|
|
42
|
+
body_request.imageUrl = imageUrl;
|
|
43
|
+
if (videoUrl)
|
|
44
|
+
body_request.videoUrl = videoUrl;
|
|
45
|
+
if (viewOnce)
|
|
46
|
+
body_request.viewOnce = viewOnce;
|
|
47
|
+
if (options.delay)
|
|
48
|
+
body_request.delay = options.delay;
|
|
49
|
+
if ((_b = (_a = options.quoted) === null || _a === void 0 ? void 0 : _a.messageQuoted) === null || _b === void 0 ? void 0 : _b.messageId) {
|
|
50
|
+
body_request.quoted = {
|
|
51
|
+
key: {
|
|
52
|
+
id: options.quoted.messageQuoted.messageId,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if ((_c = options.mentions) === null || _c === void 0 ? void 0 : _c.mentionsSettings) {
|
|
57
|
+
const { mentionsEveryOne, mentioned } = options.mentions.mentionsSettings;
|
|
58
|
+
if (mentionsEveryOne) {
|
|
59
|
+
body_request.mentionsEveryOne = true;
|
|
60
|
+
}
|
|
61
|
+
else if (mentioned) {
|
|
62
|
+
body_request.mentioned = mentioned.split(',').map((m) => m.trim());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const requestOptions = {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'application/json',
|
|
69
|
+
},
|
|
70
|
+
uri: `/message/sendShop/${instanceName}`,
|
|
71
|
+
body: body_request,
|
|
72
|
+
json: true,
|
|
73
|
+
};
|
|
74
|
+
const response = await (0, evolutionRequest_1.evolutionRequest)(ef, requestOptions);
|
|
75
|
+
return {
|
|
76
|
+
json: {
|
|
77
|
+
success: true,
|
|
78
|
+
data: response,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const errorData = {
|
|
84
|
+
success: false,
|
|
85
|
+
error: {
|
|
86
|
+
message: 'Erro ao enviar shop',
|
|
87
|
+
details: error instanceof Error ? error.message : 'Erro desconhecido',
|
|
88
|
+
timestamp: new Date().toISOString(),
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
json: errorData,
|
|
93
|
+
error: errorData,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=sendShop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendShop.js","sourceRoot":"","sources":["../../../../../nodes/EvolutionApi/execute/messages/sendShop.ts"],"names":[],"mappings":";;AAOA,4BA8GC;AAhHD,0DAAuD;AAEhD,KAAK,UAAU,QAAQ,CAAC,EAAqB;;IACnD,IAAI,CAAC;QAEJ,MAAM,YAAY,GAAG,EAAE,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAW,CAAC;QAGtE,MAAM,aAAa,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,EAAE,QAAQ,CAAW,CAAC;QAClF,IAAI,SAAiB,CAAC;QAEtB,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;YAC/B,SAAS,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAW,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,SAAS,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAW,CAAC;QAC3D,CAAC;QA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AM,QAAQ,GAAG,MAAM,IAAA,mCAAgB,EAAC,EAAE,EAAE,cAAc,CAAC,CAAC;QAC5D,OAAO;YACN,IAAI,EAAE;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,QAAQ;aACd;SACD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,SAAS,GAAG;YACjB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACN,OAAO,EAAE,qBAAqB;gBAC9B,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;gBACrE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACnC;SACD,CAAC;QACF,OAAO;YACN,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;SAChB,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare function sendStatusMentions(ef: IExecuteFunctions): Promise<{
|
|
3
|
+
json: {
|
|
4
|
+
success: boolean;
|
|
5
|
+
data: any;
|
|
6
|
+
};
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
json: {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: {
|
|
12
|
+
message: string;
|
|
13
|
+
details: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
error: {
|
|
18
|
+
success: boolean;
|
|
19
|
+
error: {
|
|
20
|
+
message: string;
|
|
21
|
+
details: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendStatusMentions = sendStatusMentions;
|
|
4
|
+
const evolutionRequest_1 = require("../evolutionRequest");
|
|
5
|
+
async function sendStatusMentions(ef) {
|
|
6
|
+
try {
|
|
7
|
+
const instanceName = ef.getNodeParameter('instanceName', 0);
|
|
8
|
+
const statusType = ef.getNodeParameter('statusType', 0);
|
|
9
|
+
const content = ef.getNodeParameter('statusContent', 0);
|
|
10
|
+
const caption = ef.getNodeParameter('statusCaption', 0, '');
|
|
11
|
+
const mentionsInput = ef.getNodeParameter('statusMentions', 0);
|
|
12
|
+
if (!mentionsInput || mentionsInput.trim() === '') {
|
|
13
|
+
const errorData = {
|
|
14
|
+
success: false,
|
|
15
|
+
error: {
|
|
16
|
+
message: 'Menções são obrigatórias',
|
|
17
|
+
details: 'É necessário fornecer pelo menos um número para mencionar no status',
|
|
18
|
+
code: 'INVALID_MENTIONS',
|
|
19
|
+
timestamp: new Date().toISOString(),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
json: errorData,
|
|
24
|
+
error: errorData,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const mentions = mentionsInput.split(',').map((m) => m.trim());
|
|
28
|
+
if (mentions.length > 5) {
|
|
29
|
+
const errorData = {
|
|
30
|
+
success: false,
|
|
31
|
+
error: {
|
|
32
|
+
message: 'Limite de menções excedido',
|
|
33
|
+
details: 'O máximo permitido é 5 menções por status',
|
|
34
|
+
code: 'TOO_MANY_MENTIONS',
|
|
35
|
+
timestamp: new Date().toISOString(),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
json: errorData,
|
|
40
|
+
error: errorData,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const font = ef.getNodeParameter('statusFont', 0, 0);
|
|
44
|
+
const textColor = ef.getNodeParameter('statusTextColor', 0, '');
|
|
45
|
+
const backgroundColor = ef.getNodeParameter('statusBackgroundColor', 0, '');
|
|
46
|
+
const body = {
|
|
47
|
+
type: statusType,
|
|
48
|
+
content,
|
|
49
|
+
mentions,
|
|
50
|
+
};
|
|
51
|
+
if (caption)
|
|
52
|
+
body.caption = caption;
|
|
53
|
+
if (statusType === 'text') {
|
|
54
|
+
if (font)
|
|
55
|
+
body.font = font;
|
|
56
|
+
if (textColor)
|
|
57
|
+
body.textColor = textColor;
|
|
58
|
+
if (backgroundColor)
|
|
59
|
+
body.backgroundColor = backgroundColor;
|
|
60
|
+
}
|
|
61
|
+
const requestOptions = {
|
|
62
|
+
method: 'POST',
|
|
63
|
+
headers: {
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
},
|
|
66
|
+
uri: `/message/sendStatusMentions/${instanceName}`,
|
|
67
|
+
body,
|
|
68
|
+
json: true,
|
|
69
|
+
};
|
|
70
|
+
const response = await (0, evolutionRequest_1.evolutionRequest)(ef, requestOptions);
|
|
71
|
+
return {
|
|
72
|
+
json: {
|
|
73
|
+
success: true,
|
|
74
|
+
data: response,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const errorData = {
|
|
80
|
+
success: false,
|
|
81
|
+
error: {
|
|
82
|
+
message: 'Erro ao enviar status com menções',
|
|
83
|
+
details: error instanceof Error ? error.message : 'Erro desconhecido',
|
|
84
|
+
timestamp: new Date().toISOString(),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
json: errorData,
|
|
89
|
+
error: errorData,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=sendStatusMentions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendStatusMentions.js","sourceRoot":"","sources":["../../../../../nodes/EvolutionApi/execute/messages/sendStatusMentions.ts"],"names":[],"mappings":";;AAOA,gDAsGC;AAxGD,0DAAuD;AAEhD,KAAK,UAAU,kBAAkB,CAAC,EAAqB;IAC7D,IAAI,CAAC;QAEJ,MAAM,YAAY,GAAG,EAAE,CAAC,gBAAgB,CAA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,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;gBACrE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACnC;SACD,CAAC;QACF,OAAO;YACN,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;SAChB,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare function sendStickerPack(ef: IExecuteFunctions): Promise<{
|
|
3
|
+
json: {
|
|
4
|
+
success: boolean;
|
|
5
|
+
data: any;
|
|
6
|
+
};
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
json: {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error: {
|
|
12
|
+
message: string;
|
|
13
|
+
details: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
error: {
|
|
18
|
+
success: boolean;
|
|
19
|
+
error: {
|
|
20
|
+
message: string;
|
|
21
|
+
details: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendStickerPack = sendStickerPack;
|
|
4
|
+
const evolutionRequest_1 = require("../evolutionRequest");
|
|
5
|
+
async function sendStickerPack(ef) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
try {
|
|
8
|
+
const instanceName = ef.getNodeParameter('instanceName', 0);
|
|
9
|
+
const recipientType = ef.getNodeParameter('recipientType', 0, 'number');
|
|
10
|
+
let remoteJid;
|
|
11
|
+
if (recipientType === 'group') {
|
|
12
|
+
remoteJid = ef.getNodeParameter('groupJid', 0);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
remoteJid = ef.getNodeParameter('remoteJid', 0);
|
|
16
|
+
}
|
|
17
|
+
const name = ef.getNodeParameter('packName', 0);
|
|
18
|
+
const publisher = ef.getNodeParameter('packPublisher', 0);
|
|
19
|
+
const description = ef.getNodeParameter('packDescription', 0, '');
|
|
20
|
+
const cover = ef.getNodeParameter('packCover', 0, '');
|
|
21
|
+
const stickersInput = ef.getNodeParameter('packStickers.stickerValues', 0, []);
|
|
22
|
+
if (!Array.isArray(stickersInput) || stickersInput.length === 0) {
|
|
23
|
+
const errorData = {
|
|
24
|
+
success: false,
|
|
25
|
+
error: {
|
|
26
|
+
message: 'Lista de stickers inválida',
|
|
27
|
+
details: 'É necessário fornecer pelo menos um sticker para o pack',
|
|
28
|
+
code: 'INVALID_STICKERS',
|
|
29
|
+
timestamp: new Date().toISOString(),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
json: errorData,
|
|
34
|
+
error: errorData,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const options = ef.getNodeParameter('options_message', 0, {});
|
|
38
|
+
const stickers = stickersInput.map(s => s.stickerUrl);
|
|
39
|
+
const body = {
|
|
40
|
+
number: remoteJid,
|
|
41
|
+
name,
|
|
42
|
+
publisher,
|
|
43
|
+
stickers,
|
|
44
|
+
};
|
|
45
|
+
if (description)
|
|
46
|
+
body.description = description;
|
|
47
|
+
if (cover)
|
|
48
|
+
body.cover = cover;
|
|
49
|
+
if (options.delay)
|
|
50
|
+
body.delay = options.delay;
|
|
51
|
+
if ((_b = (_a = options.quoted) === null || _a === void 0 ? void 0 : _a.messageQuoted) === null || _b === void 0 ? void 0 : _b.messageId) {
|
|
52
|
+
body.quoted = {
|
|
53
|
+
key: {
|
|
54
|
+
id: options.quoted.messageQuoted.messageId,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const requestOptions = {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
},
|
|
63
|
+
uri: `/message/sendStickerPack/${instanceName}`,
|
|
64
|
+
body,
|
|
65
|
+
json: true,
|
|
66
|
+
};
|
|
67
|
+
const response = await (0, evolutionRequest_1.evolutionRequest)(ef, requestOptions);
|
|
68
|
+
return {
|
|
69
|
+
json: {
|
|
70
|
+
success: true,
|
|
71
|
+
data: response,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
const errorData = {
|
|
77
|
+
success: false,
|
|
78
|
+
error: {
|
|
79
|
+
message: 'Erro ao enviar sticker pack',
|
|
80
|
+
details: error instanceof Error ? error.message : 'Erro desconhecido',
|
|
81
|
+
timestamp: new Date().toISOString(),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
json: errorData,
|
|
86
|
+
error: errorData,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=sendStickerPack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendStickerPack.js","sourceRoot":"","sources":["../../../../../nodes/EvolutionApi/execute/messages/sendStickerPack.ts"],"names":[],"mappings":";;AAOA,0CA6GC;AA/GD,0DAAuD;AAEhD,KAAK,UAAU,eAAe,CAAC,EAAqB;;IAC1D,IAAI,CAAC;QAEJ,MAAM,YAAY,GAAG,EAAE,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAW,CAAC;QAGtE,MAAM,aAAa,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,EAAE,QAAQ,CAAW,CAAC;QAClF,IAAI,SAAiB,CAAC;QAEtB,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;YAC/B,SAAS,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAW,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,SAAS,GAAG,EAAE,CAAC,gBAAgB,CAAC,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