@wrcb/cb-common 1.0.717 → 1.0.719
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/build/server.d.ts
CHANGED
package/build/server.js
CHANGED
|
@@ -101,3 +101,4 @@ __exportStar(require("./events/compranomia/sellerProductDeletedEvent"), exports)
|
|
|
101
101
|
__exportStar(require("./services/RedisService"), exports);
|
|
102
102
|
__exportStar(require("./services/TenantDataService"), exports);
|
|
103
103
|
__exportStar(require("./services/WasabiUploader"), exports);
|
|
104
|
+
__exportStar(require("./services/WhatsappService"), exports);
|
|
@@ -275,6 +275,8 @@ TenantDataService.tenantDataMap = {
|
|
|
275
275
|
SITE_URL: 'https://politicabet.com',
|
|
276
276
|
SITE_WHATSAPP_SUPPORT: '11915809857',
|
|
277
277
|
SITE_WHATSAPP_BOT: '11915809857',
|
|
278
|
+
WHATSAPP_PHONE_NUMBER_ID: '',
|
|
279
|
+
WHATSAPP_TOKEN: '',
|
|
278
280
|
SITE_DESCRIPTION: 'Mercado de predições sobre política, esportes, cripto e muito mais!',
|
|
279
281
|
KEYWORDS: [
|
|
280
282
|
'apostas',
|
|
@@ -355,6 +357,8 @@ TenantDataService.tenantDataMap = {
|
|
|
355
357
|
SITE_URL: 'https://tourism.dev',
|
|
356
358
|
SITE_WHATSAPP_SUPPORT: '11915809857',
|
|
357
359
|
SITE_WHATSAPP_BOT: '11915809857',
|
|
360
|
+
WHATSAPP_PHONE_NUMBER_ID: '',
|
|
361
|
+
WHATSAPP_TOKEN: '',
|
|
358
362
|
SITE_DESCRIPTION: 'Descrição do outro site',
|
|
359
363
|
KEYWORDS: ['tourism', 'travel', 'vacation', 'explore'],
|
|
360
364
|
SOCIAL_X: 'https://x.com/outro',
|
|
@@ -435,6 +439,8 @@ TenantDataService.tenantDataMap = {
|
|
|
435
439
|
SITE_URL: 'https://privateshow.com.br',
|
|
436
440
|
SITE_WHATSAPP_SUPPORT: '11915809857',
|
|
437
441
|
SITE_WHATSAPP_BOT: '11915809857',
|
|
442
|
+
WHATSAPP_PHONE_NUMBER_ID: '',
|
|
443
|
+
WHATSAPP_TOKEN: '',
|
|
438
444
|
SITE_DESCRIPTION: 'Aqui, você nunca fica sozinho!',
|
|
439
445
|
KEYWORDS: ['porn'],
|
|
440
446
|
SOCIAL_X: 'https://x.com/privateshow',
|
|
@@ -501,6 +507,8 @@ TenantDataService.tenantDataMap = {
|
|
|
501
507
|
SITE_URL: 'https://promoapp.com.br',
|
|
502
508
|
SITE_WHATSAPP_SUPPORT: '11915809857',
|
|
503
509
|
SITE_WHATSAPP_BOT: '11915809857',
|
|
510
|
+
WHATSAPP_PHONE_NUMBER_ID: '',
|
|
511
|
+
WHATSAPP_TOKEN: '',
|
|
504
512
|
SITE_DESCRIPTION: 'Promoções todoos os dias em primeira mão!',
|
|
505
513
|
KEYWORDS: ['porn'],
|
|
506
514
|
SOCIAL_X: 'https://x.com/promoapp',
|
|
@@ -549,6 +557,8 @@ TenantDataService.tenantDataMap = {
|
|
|
549
557
|
SITE_URL: 'https://compranomia.com.br',
|
|
550
558
|
SITE_WHATSAPP_SUPPORT: '11915809857',
|
|
551
559
|
SITE_WHATSAPP_BOT: '11915809857',
|
|
560
|
+
WHATSAPP_PHONE_NUMBER_ID: '',
|
|
561
|
+
WHATSAPP_TOKEN: '',
|
|
552
562
|
SITE_DESCRIPTION: 'Compras locais de supermercado, farmácia e muito mais!',
|
|
553
563
|
KEYWORDS: [
|
|
554
564
|
'supermercado',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface SendWhatsAppMessageInput {
|
|
2
|
+
phoneNumber: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface WhatsAppConfig {
|
|
6
|
+
token: string;
|
|
7
|
+
phoneNumberId: string;
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
apiVersion: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class WhatsAppService {
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: WhatsAppConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Envia mensagem de texto via WhatsApp Business API
|
|
16
|
+
*/
|
|
17
|
+
sendTextMessage(input: SendWhatsAppMessageInput): Promise<boolean>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WhatsAppService = void 0;
|
|
13
|
+
class WhatsAppService {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.config = config;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Envia mensagem de texto via WhatsApp Business API
|
|
19
|
+
*/
|
|
20
|
+
sendTextMessage(input) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const { phoneNumber, text } = input;
|
|
23
|
+
try {
|
|
24
|
+
const url = `${this.config.apiUrl}/${this.config.apiVersion}/${this.config.phoneNumberId}/messages`;
|
|
25
|
+
const body = {
|
|
26
|
+
messaging_product: 'whatsapp',
|
|
27
|
+
recipient_type: 'individual',
|
|
28
|
+
to: phoneNumber,
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: {
|
|
31
|
+
preview_url: false,
|
|
32
|
+
body: text
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const response = yield fetch(url, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: {
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
Authorization: `Bearer ${this.config.token}`
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify(body)
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const errorData = yield response.json().catch(() => ({}));
|
|
45
|
+
throw new Error(`WhatsApp API error: ${response.status} - ${JSON.stringify(errorData)}`);
|
|
46
|
+
}
|
|
47
|
+
console.log(`✅ Mensagem WhatsApp enviada para: ${phoneNumber}`);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('❌ Erro ao enviar mensagem WhatsApp:', error.message);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.WhatsAppService = WhatsAppService;
|