"""Instagram account domain model — Pydantic v2 with ORM compatibility."""

from __future__ import annotations

import uuid
from datetime import datetime
from typing import Any

from repo_core.base.models import DomainModel


class InstagramAccount(DomainModel):
    """Instagram account entity — Pydantic representation.

    Built with ``from_attributes=True`` so it can be constructed directly
    from SQLAlchemy ORM objects or database rows.
    """

    id: uuid.UUID
    phone_number: str
    external_id: str | None = None
    username: str | None = None
    display_name: str | None = None
    session_encrypted: str
    account_metadata: dict[str, Any] = {}
    is_active: bool = True
    status: str = "active"
    flood_wait_until: datetime | None = None
    last_active_at: datetime | None = None
    created_at: datetime | None = None
    updated_at: datetime | None = None

    @property
    def platform(self) -> str:
        return "instagram"
