"""Data types for dtelecom-stt SDK."""

from dataclasses import dataclass, field


@dataclass
class Transcription:
    """A transcription result from the STT server."""

    text: str
    start: float | None = None
    end: float | None = None
    confidence: float | None = None
    is_final: bool = True

    @classmethod
    def from_message(cls, msg: dict) -> "Transcription":
        return cls(
            text=msg.get("text", ""),
            start=msg.get("start"),
            end=msg.get("end"),
            confidence=msg.get("confidence"),
            is_final=msg.get("is_final", True),
        )


@dataclass
class SessionInfo:
    """Info returned when a session is created."""

    session_id: str
    session_key: str
    ws_url: str
    remaining_seconds: float
    minutes: int
    price_usd: str


@dataclass
class PricingInfo:
    """Pricing information from the server."""

    price_per_minute_usd: float
    min_minutes: int
    max_minutes: int
    min_price_usd: float
    currency: str
    network: str
