<?php

namespace App\EventHooks\System;

use App\EventHooks\HookEvent;
use App\Models\ClientProduct;

/**
 * Fire noktası: AbstractSsl (reseller/manuel akış müşteri girdisi bekliyor)
 * ve HandleInvoiceStatusChange — 'SSLCertificateConfigurationRequired' hook'u
 * (boşluksuz). Context: ssl_certificate_id, client_product_id, service_id,
 * client_id, domain.
 */
class SslConfigurationRequired extends HookEvent
{
    public const HOOK = 'SSLCertificateConfigurationRequired';

    public function serviceId(): ?int
    {
        $id = $this->get('service_id') ?? $this->get('client_product_id');

        return $id ? (int) $id : null;
    }

    public function service(): ?ClientProduct
    {
        $id = $this->serviceId();

        return $id ? ClientProduct::find($id) : null;
    }

    public function domain(): ?string
    {
        return $this->get('domain');
    }
}
