# models/schema/marketplace_products.py - Simplified validation
from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field

from models.schema.inventory import ProductInventorySummary


class MarketplaceProductBase(BaseModel):
    marketplace_product_id: str | None = None
    title: str | None = None
    description: str | None = None
    link: str | None = None
    image_link: str | None = None
    availability: str | None = None
    price: str | None = None
    brand: str | None = None
    gtin: str | None = None
    mpn: str | None = None
    condition: str | None = None
    adult: str | None = None
    multipack: int | None = None
    is_bundle: str | None = None
    age_group: str | None = None
    color: str | None = None
    gender: str | None = None
    material: str | None = None
    pattern: str | None = None
    size: str | None = None
    size_type: str | None = None
    size_system: str | None = None
    item_group_id: str | None = None
    google_product_category: str | None = None
    product_type: str | None = None
    custom_label_0: str | None = None
    custom_label_1: str | None = None
    custom_label_2: str | None = None
    custom_label_3: str | None = None
    custom_label_4: str | None = None
    additional_image_link: str | None = None
    sale_price: str | None = None
    unit_pricing_measure: str | None = None
    unit_pricing_base_measure: str | None = None
    identifier_exists: str | None = None
    shipping: str | None = None
    currency: str | None = None
    marketplace: str | None = None
    vendor_name: str | None = None


class MarketplaceProductCreate(MarketplaceProductBase):
    marketplace_product_id: str = Field(
        ..., description="MarketplaceProduct identifier"
    )
    title: str = Field(..., description="MarketplaceProduct title")
    # Removed: min_length constraints and custom validators
    # Service will handle empty string validation with proper domain exceptions


class MarketplaceProductUpdate(MarketplaceProductBase):
    pass


class MarketplaceProductResponse(MarketplaceProductBase):
    model_config = ConfigDict(from_attributes=True)
    id: int
    created_at: datetime
    updated_at: datetime


class MarketplaceProductListResponse(BaseModel):
    products: list[MarketplaceProductResponse]
    total: int
    skip: int
    limit: int


class MarketplaceProductDetailResponse(BaseModel):
    product: MarketplaceProductResponse
    inventory_info: ProductInventorySummary | None = None
