# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .catalog_entry_create_request_allowances_item import CatalogEntryCreateRequestAllowancesItem
from .catalog_entry_create_request_prices_item import CatalogEntryCreateRequestPricesItem


class CatalogEntryCreateRequest(UniversalBaseModel):
    """
    Request body for creating a catalog entry
    """

    ottimate_company_id: int = pydantic.Field()
    """
    Company ID
    """

    erp_vendor_id: str = pydantic.Field()
    """
    ERP Vendor id from ERP/accounting system
    """

    description: str = pydantic.Field()
    """
    Item name/description
    """

    original_description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Original item description
    """

    sku: typing.Optional[str] = pydantic.Field(default=None)
    """
    SKU code
    """

    upc: typing.Optional[str] = pydantic.Field(default=None)
    """
    UPC code
    """

    size: typing.Optional[str] = pydantic.Field(default=None)
    """
    Pack size
    """

    uom: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unit of measure
    """

    price: typing.Optional[float] = pydantic.Field(default=None)
    """
    Price
    """

    unit_price: typing.Optional[float] = pydantic.Field(default=None)
    """
    Unit price
    """

    is_split_case: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Split case indicator
    """

    authorized_vendor: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether vendor is authorized
    """

    catalog_unique_key: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unique key used to match existing entries for upsert. If omitted, the API auto-generates a key from erp_vendor_id, sku, size, and description. Key normalization: the value is derived from the entry's core identifying fields — the key returned in the response may differ from what you submitted. Always store and reuse the returned catalog_unique_key. Key regeneration: modifying erp_vendor_id, sku, size, or description will generate a new key that no longer matches the existing entry — the API will create a new entry instead of updating the old one, leaving the previous entry as an orphan. To avoid duplicates, store the latest catalog_unique_key from the response and include it in subsequent requests.
    """

    reference_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Datadash unique key
    """

    dimensions: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Dimension values keyed by type (e.g. PROJECT, CLASS). Each value is the ERP external_id of the dimension. For existing entries (matched via catalog_unique_key), REPLACES all existing dimensions — include every dimension you want to keep. For new entries, sets the initial dimensions. Omit the field or pass null to leave dimensions unchanged (updates) or create without dimensions (new entries). Passing {} returns 400.
    """

    properties: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Additional properties
    """

    prices: typing.Optional[typing.List[CatalogEntryCreateRequestPricesItem]] = pydantic.Field(default=None)
    """
    Nested prices to create
    """

    allowances: typing.Optional[typing.List[CatalogEntryCreateRequestAllowancesItem]] = pydantic.Field(default=None)
    """
    Nested allowances to create
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
