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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
from .inventory_change_type import InventoryChangeType
import pydantic
from .inventory_physical_count import InventoryPhysicalCount
from .inventory_adjustment import InventoryAdjustment
from .inventory_transfer import InventoryTransfer
from .catalog_measurement_unit import CatalogMeasurementUnit
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class InventoryChange(UncheckedBaseModel):
    """
    Represents a single physical count, inventory, adjustment, or transfer
    that is part of the history of inventory changes for a particular
    [CatalogObject](entity:CatalogObject) instance.
    """

    type: typing.Optional[InventoryChangeType] = pydantic.Field(default=None)
    """
    Indicates how the inventory change is applied. See
    [InventoryChangeType](entity:InventoryChangeType) for all possible values.
    See [InventoryChangeType](#type-inventorychangetype) for possible values
    """

    physical_count: typing.Optional[InventoryPhysicalCount] = pydantic.Field(default=None)
    """
    Contains details about the physical count when `type` is
    `PHYSICAL_COUNT`, and is unset for all other change types.
    """

    adjustment: typing.Optional[InventoryAdjustment] = pydantic.Field(default=None)
    """
    Contains details about the inventory adjustment when `type` is
    `ADJUSTMENT`, and is unset for all other change types.
    """

    transfer: typing.Optional[InventoryTransfer] = pydantic.Field(default=None)
    """
    Contains details about the inventory transfer when `type` is
    `TRANSFER`, and is unset for all other change types.
    
    _Note:_ An [InventoryTransfer](entity:InventoryTransfer) object can only be set in the input to the
    [BatchChangeInventory](api-endpoint:Inventory-BatchChangeInventory) endpoint when the seller has an active Retail Plus subscription.
    """

    measurement_unit: typing.Optional[CatalogMeasurementUnit] = pydantic.Field(default=None)
    """
    The [CatalogMeasurementUnit](entity:CatalogMeasurementUnit) object representing the catalog measurement unit associated with the inventory change.
    """

    measurement_unit_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The ID of the [CatalogMeasurementUnit](entity:CatalogMeasurementUnit) object representing the catalog measurement unit associated with the inventory change.
    """

    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
