Spaces:
Runtime error
Runtime error
| from pydantic import BaseModel, ConfigDict, AnyHttpUrl, EmailStr, field_validator | |
| import uuid | |
| from decimal import Decimal | |
| from typing import Optional, Dict, Any | |
| import zoneinfo | |
| ALLOWED_INDUSTRIES = { | |
| # Current admin console dropdown values (lowercased) | |
| "restaurant / food & beverage", | |
| "retail", | |
| "e-commerce", | |
| "healthcare", | |
| "legal", | |
| "education", | |
| "real estate", | |
| "financial services", | |
| "technology", | |
| "travel & hospitality", | |
| "beauty & wellness", | |
| "professional services", | |
| "non-profit", | |
| "other", | |
| # Legacy values kept for backward compatibility with existing DB records | |
| "real-estate", | |
| "saas", | |
| "finance", | |
| } | |
| class GoLiveRequest(BaseModel): | |
| is_active: bool | |
| class TenantSettingsUpdate(BaseModel): | |
| name: Optional[str] = None | |
| website_url: Optional[AnyHttpUrl] = None | |
| industry: Optional[str] = None | |
| timezone: Optional[str] = None | |
| chatbot_name: Optional[str] = None | |
| chatbot_greeting: Optional[str] = None | |
| backup_email: Optional[EmailStr] = None | |
| def validate_industry(cls, v): | |
| if v is not None and v.lower() not in ALLOWED_INDUSTRIES: | |
| raise ValueError(f"Industry must be one of {ALLOWED_INDUSTRIES}") | |
| return v.lower() if v else v | |
| def validate_timezone(cls, v): | |
| if v is not None: | |
| try: | |
| zoneinfo.ZoneInfo(v) | |
| except zoneinfo.ZoneInfoNotFoundError: | |
| raise ValueError("Invalid timezone string") | |
| return v | |
| class TenantResponse(BaseModel): | |
| id: uuid.UUID | |
| name: str | |
| website_url: Optional[str] = None | |
| owner_email: Optional[str] = None | |
| backup_email: Optional[str] = None | |
| is_active: bool | |
| billing_mode: str | |
| balance_usd: Decimal | |
| customization: Optional[Dict[str, Any]] = None | |
| model_config = ConfigDict(from_attributes=True) | |