feat: agregar soporte para plantillas de WhatsApp en el controlador de notificaciones, incluyendo nuevos parámetros y un endpoint de prueba
This commit is contained in:
@@ -20,6 +20,9 @@ export interface NotificationJobPayload {
|
|||||||
wapMessage?: string;
|
wapMessage?: string;
|
||||||
systemSubject?: string;
|
systemSubject?: string;
|
||||||
systemMessage?: string;
|
systemMessage?: string;
|
||||||
|
templateName?: string;
|
||||||
|
languageCode?: string;
|
||||||
|
templateVariables?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INotificationJob {
|
export interface INotificationJob {
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ export interface NotificationJobPayload {
|
|||||||
wapMessage?: string;
|
wapMessage?: string;
|
||||||
systemSubject?: string;
|
systemSubject?: string;
|
||||||
systemMessage?: string;
|
systemMessage?: string;
|
||||||
|
templateName?: string;
|
||||||
|
languageCode?: string;
|
||||||
|
templateVariables?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INotificationJob {
|
export interface INotificationJob {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export class NotificationsMetaAdapter implements INotificationsAdapter<Notificat
|
|||||||
// ── Datos hardcodeados para pruebas (etapa 1) ──
|
// ── Datos hardcodeados para pruebas (etapa 1) ──
|
||||||
private readonly phoneNumberId = "1379557278565544"; // ej: "1379557278565544"
|
private readonly phoneNumberId = "1379557278565544"; // ej: "1379557278565544"
|
||||||
private readonly authToken =
|
private readonly authToken =
|
||||||
"EAAeZCf8kXotYBSlhC68tvuv6fPhFgfbqwdoF8Ab6r50cAQXJLOPl9qRCYtKYgz4r8ZBYzPIOVg3zZBU8JRcTmgoWU9DAphsWB3xQHQuZCMYZAMs3YHukOK567GUQeZCxOw8oZBnavnaqc0KukT0GzweRB2VC4CD5a6Vj5EsiJnZCjYuZCrffoha5WCkRRyUryook9syNTQ2cexsObVyhMVpRRc7X74BxbCWuzLZAvbZA6ZAb6zIZCHadhUWKX30dpYd1elqZAWuygnVC8pZBQyFG0YET498DAfs"; // tu token de Meta
|
"EAAeZCf8kXotYBSuVCLO7smu3jGxv7qqndFn3OZB6E55QZBRKB2ZCPmOkylVfseI8PuZBzGBIrGa3QO0hUJZCGq7GwwJBgaxhu4A07LJZCOna82ZAQZAYZBljlQVApTurK1Hj0YHVZA4cnSdQa5xKmoYBa8YTuzyqrC1ZC2s9qbIvWHImUkVUgG2ps7F25ZAZCMISympdL1c34iO2IDLW2NGndy3o4E11K0c1FA3RFTCQJJXPmuddK360KLz5Tpj8BOTZC12FztytNQkwqpHZBBdpCpJfrOyQy546"; // tu token de Meta
|
||||||
private readonly apiVersion = "v25.0";
|
private readonly apiVersion = "v25.0";
|
||||||
|
|
||||||
get baseUrl(): string {
|
get baseUrl(): string {
|
||||||
|
|||||||
@@ -72,6 +72,33 @@ export class SendEmailByContentController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TEMPORARY TEST ENDPOINT — remove after testing meta_wap integration
|
||||||
|
* No auth required. Just for curl testing sendWhatsAppTemplate flow.
|
||||||
|
*/
|
||||||
|
@Route("notifications/test-meta-send")
|
||||||
|
export class TestMetaSendController extends Controller {
|
||||||
|
@SuccessResponse(200, "Done")
|
||||||
|
@Post()
|
||||||
|
public async testMetaSend(@Body() requestBody: SendWhatsAppTemplateParams): Promise<ApiVoidResult> {
|
||||||
|
try {
|
||||||
|
await NotificationsManager.sendWhatsAppTemplate({
|
||||||
|
phoneNumber: requestBody.phoneNumber,
|
||||||
|
templateName: requestBody.templateName,
|
||||||
|
languageCode: requestBody.languageCode,
|
||||||
|
templateVariables: requestBody.templateVariables,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setStatus(200);
|
||||||
|
return { message: "Test sent successfully", success: true };
|
||||||
|
} catch (error) {
|
||||||
|
const msg = error instanceof Error ? error.message : String(error);
|
||||||
|
this.setStatus(500);
|
||||||
|
return { message: `Test failed: ${msg}`, success: false };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Route("notifications/send-whatsapp-template")
|
@Route("notifications/send-whatsapp-template")
|
||||||
@Middlewares([rateLimiter, systemTokenMiddleware])
|
@Middlewares([rateLimiter, systemTokenMiddleware])
|
||||||
export class SendWhatsAppTemplateController extends Controller {
|
export class SendWhatsAppTemplateController extends Controller {
|
||||||
|
|||||||
Reference in New Issue
Block a user