# app/schemas/user.py
from pydantic import BaseModel, EmailStr, ConfigDict
from datetime import datetime
from typing import Optional

# Shared properties
class UserBase(BaseModel):
    email: EmailStr
    name: Optional[str] = None

# Properties to receive via API on creation
class UserCreate(UserBase):
    password: str

    def create_update_dict(self):
        return {
            "email": self.email,
            "name": self.name,
            "password": self.password,
            "is_active": True,
            "is_superuser": False,
            "is_verified": False
        }

# Properties to receive via API on update
class UserUpdate(UserBase):
    password: Optional[str] = None
    is_active: Optional[bool] = None
    is_superuser: Optional[bool] = None
    is_verified: Optional[bool] = None

# Properties stored in DB
class UserInDBBase(UserBase):
    id: int
    password_hash: str
    created_at: datetime
    model_config = ConfigDict(from_attributes=True) # Use orm_mode in Pydantic v1

# Additional properties to return via API (excluding password)
class UserPublic(UserBase):
    id: int
    created_at: datetime
    model_config = ConfigDict(from_attributes=True)

# Full user model including hashed password (for internal use/reading from DB)
class User(UserInDBBase):
    pass