From 19a236818e41e96af314e9af4a4d4d3673d7af76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez?= Date: Fri, 22 May 2026 22:22:36 -0600 Subject: [PATCH] =?UTF-8?q?Carga=20y=20configuraci=C3=B3n=20de=20platilla?= =?UTF-8?q?=20de=20api=20de=20whats=20app?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 ++- app/Services/WhatsAppService.php | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f9509c63..ba8090e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,8 @@ RUN npm ci && \ npm run build RUN mkdir -p storage/framework/sessions storage/framework/views storage/framework/cache storage/app/livewire-tmp storage/logs \ - && chmod -R 775 storage bootstrap/cache + && chmod -R 775 storage bootstrap/cache \ + && chown -R nobody:nginx storage bootstrap/cache RUN php artisan storage:link diff --git a/app/Services/WhatsAppService.php b/app/Services/WhatsAppService.php index c19ba1b6..b2870b9e 100644 --- a/app/Services/WhatsAppService.php +++ b/app/Services/WhatsAppService.php @@ -61,7 +61,7 @@ class WhatsAppService return $response->json('messages.0.id'); } - public function enviarPromocion(string $telefono, Promocion $promocion): string + /*public function enviarPromocion(string $telefono, Promocion $promocion): string { $payload = [ 'messaging_product' => 'whatsapp', @@ -92,8 +92,27 @@ class WhatsAppService } return $response->json('messages.0.id'); + }*/ + + public function enviarPromocion(string $telefono, Promocion $promocion): string +{ + $response = Http::withToken($this->token)->post($this->apiUrl, [ + 'messaging_product' => 'whatsapp', + 'to' => $this->normalizarTelefono($telefono), + 'type' => 'template', + 'template' => [ + 'name' => 'hello_world', + 'language' => ['code' => 'en_US'], + ], + ]); + + if ($response->failed()) { + throw new \RuntimeException($response->body()); } + return $response->json('messages.0.id'); +} + public function procesarOptOut(string $telefono): void { $normalizado = $this->normalizarTelefono($telefono);