All checks were successful
Banda de modalidades passa a abrir wa.me com mensagem distinta (fallback /briefing). Glossário canônico vive em SPEC.md §8.0. Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Models\SiteSetting;
|
|
|
|
final class PackageContactLink
|
|
{
|
|
private const ORIENTATION_MESSAGE = 'Olá, ainda não sei qual modalidade de acompanhamento combina com o meu casamento e gostaria de orientação da Amare.';
|
|
|
|
/**
|
|
* Resolve the contextual contact link for a wedding package modality.
|
|
*
|
|
* @return array{href: string, isWhatsapp: bool}
|
|
*/
|
|
public static function for(SiteSetting $settings, string $packageName): array
|
|
{
|
|
return self::resolve(
|
|
$settings,
|
|
'Olá, gostaria de conversar sobre a modalidade '.$packageName.' para meu casamento.',
|
|
['servico_interesse' => $packageName],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Resolve the orientation CTA for visitors who have not chosen a modality yet.
|
|
*
|
|
* @return array{href: string, isWhatsapp: bool}
|
|
*/
|
|
public static function forOrientation(SiteSetting $settings): array
|
|
{
|
|
return self::resolve($settings, self::ORIENTATION_MESSAGE, []);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, string> $briefingQuery
|
|
* @return array{href: string, isWhatsapp: bool}
|
|
*/
|
|
private static function resolve(SiteSetting $settings, string $whatsappMessage, array $briefingQuery): array
|
|
{
|
|
$digits = preg_replace('/\D/', '', (string) $settings->whatsapp_number);
|
|
$isWhatsapp = strlen($digits) >= 10;
|
|
|
|
return [
|
|
'href' => $isWhatsapp
|
|
? 'https://wa.me/'.$digits.'?text='.rawurlencode($whatsappMessage)
|
|
: route('briefing', $briefingQuery),
|
|
'isWhatsapp' => $isWhatsapp,
|
|
];
|
|
}
|
|
}
|