"""Submission Model."""

from typing import Optional

from netorca_sdk.v2.base import BaseModel


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

    @property
    def service_id(self) -> Optional[int]:
        """Get associated service ID."""
        return self._extract_nested_id(self.data.get('service'))

    @property
    def service_item_id(self) -> Optional[int]:
        """Get associated service item ID."""
        return self._extract_nested_id(self.data.get('service_item'))

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

    @property
    def declaration(self) -> Optional[dict]:
        """Get declaration data."""
        return self.data.get('declaration')

    @property
    def validation_errors(self) -> Optional[list]:
        """Get validation errors if any."""
        return self.data.get('validation_errors')

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