<?php

namespace Modules\WhatsApp\Observers;

use App\Contact;
use Modules\WhatsApp\Entities\Services\WaNotifier;

/**
 * Welcomes a newly created customer contact. Default-off (see WaEvents) because
 * bulk contact imports would otherwise blast welcomes — enable intentionally.
 */
class ContactObserver
{
    public function created(Contact $contact): void
    {
        if (!in_array($contact->type, ['customer', 'both'], true)) {
            return;
        }
        if (empty($contact->mobile)) {
            return;
        }

        (new WaNotifier())->contactWelcome($contact);
    }
}
