"""Webhook Model."""

from typing import List, Optional

from netorca_sdk.v2.base import BaseModel


class Webhook(BaseModel):
    """Webhook model."""

    @property
    def name(self) -> Optional[str]:
        """Get webhook name."""
        return self.data.get('name')

    @property
    def url(self) -> Optional[str]:
        """Get webhook URL."""
        return self.data.get('url')

    @property
    def event_types(self) -> List[str]:
        """Get event types that trigger this webhook."""
        return self.data.get('event_types', [])

    @property
    def is_active(self) -> bool:
        """Check if webhook is active."""
        return self.data.get('is_active', False)

    @property
    def secret(self) -> Optional[str]:
        """Get webhook secret for signature verification."""
        return self.data.get('secret')

    def __repr__(self) -> str:
        """String representation."""
        return f"Webhook(id={self.id}, name={self.name!r}, is_active={self.is_active})"
