"""
ATS SDK - Data Models

Typed data classes for API responses.
"""

from dataclasses import dataclass
from typing import Optional, List, Dict, Any
from datetime import datetime
from enum import Enum


class DeviceState(str, Enum):
    """Device lifecycle states"""
    STOCKED = "stocked"
    SHIPPED = "shipped"
    CLAIMED = "claimed"
    ACTIVATED = "activated"
    SUSPENDED = "suspended"
    RETIRED = "retired"


class DeviceCategory(str, Enum):
    """Device categories"""
    VSAT_VEHICULAR = "vsat-vehicular"
    IOT_MESSAGING = "iot-messaging"


class Environment(str, Enum):
    """Project environments"""
    SANDBOX = "sandbox"
    PRODUCTION = "production"


@dataclass
class Organization:
    """Organization model"""
    id: str
    name: str
    billing_email: Optional[str]
    status: str
    created_at: datetime
    updated_at: datetime


@dataclass
class Project:
    """Project model"""
    id: str
    org_id: str
    name: str
    description: Optional[str]
    environment: Environment
    status: str
    created_at: datetime
    updated_at: datetime


@dataclass
class DeviceModel:
    """Device model (catalog entry)"""
    id: str
    name: str
    category: DeviceCategory
    manufacturer: str
    capabilities: List[str]
    specifications: Dict[str, Any]
    compatible_plans: List[str]
    pricing: Dict[str, Any]


@dataclass
class Device:
    """Device instance"""
    id: str
    model_id: str
    serial_number: Optional[str]
    imei: Optional[str]
    project_id: Optional[str]
    name: Optional[str]
    state: DeviceState
    capabilities: List[str]
    metadata: Dict[str, Any]
    last_seen_at: Optional[datetime]
    created_at: datetime
    updated_at: datetime


@dataclass
class VsatSession:
    """VSAT session state"""
    device_id: str
    state: str
    link_metrics: Optional[Dict[str, float]]
    connected_at: Optional[datetime]
    last_metrics_at: Optional[datetime]


@dataclass
class Message:
    """IoT message"""
    message_id: str
    device_id: str
    payload: bytes
    status: str
    queued_at: datetime
    delivered_at: Optional[datetime]
    metadata: Dict[str, Any]


@dataclass
class UsageInfo:
    """Project usage information"""
    project_id: str
    period: Dict[str, datetime]
    usage: Dict[str, int]
    quotas: Dict[str, Any]
