"""Subscription schemas."""
from datetime import datetime
from typing import Optional, Dict, List

from pydantic import BaseModel


class SubscriptionResponse(BaseModel):
    """Schema for subscription response."""
    id: int
    tier: str
    tier_name: str
    status: str
    domain_limit: int
    domains_used: int = 0
    portfolio_limit: int = 0
    check_frequency: str
    history_days: int
    features: Dict[str, bool]
    started_at: datetime
    expires_at: Optional[datetime]
    
    class Config:
        from_attributes = True


class SubscriptionTierInfo(BaseModel):
    """Schema for subscription tier information."""
    id: str
    name: str
    domain_limit: int
    price: float
    check_frequency: str
    features: List[str]
    feature_flags: Dict[str, bool]


class SubscriptionUpdate(BaseModel):
    """Schema for updating subscription (admin/payment webhook)."""
    tier: str
    expires_at: Optional[datetime] = None
    payment_reference: Optional[str] = None
