"""Charge Model."""

from typing import Optional

from netorca_sdk.v2.base import BaseModel


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

    @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 consumer_team_id(self) -> Optional[int]:
        """Get consumer team ID."""
        return self._extract_nested_id(self.data.get('consumer_team'))

    @property
    def amount(self) -> Optional[float]:
        """Get charge amount."""
        return self.data.get('amount')

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

    @property
    def period_start(self) -> Optional[str]:
        """Get period start date."""
        return self.data.get('period_start')

    @property
    def period_end(self) -> Optional[str]:
        """Get period end date."""
        return self.data.get('period_end')

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

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