"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .amountdecimal import AmountDecimal, AmountDecimalTypedDict
from .createtransferlineitemoption import (
    CreateTransferLineItemOption,
    CreateTransferLineItemOptionTypedDict,
)
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class CreateTransferLineItemTypedDict(TypedDict):
    r"""Represents a single item in a transfer, including optional modifiers and quantity."""

    name: str
    r"""The name of the item."""
    base_price: AmountDecimalTypedDict
    r"""The base price of the item before applying option modifiers."""
    quantity: int
    r"""The quantity of this item."""
    options: NotRequired[List[CreateTransferLineItemOptionTypedDict]]
    r"""Optional list of modifiers applied to this item (e.g., toppings, upgrades, customizations)."""
    image_i_ds: NotRequired[List[str]]
    r"""Optional list of images associated with this line item.
    This field is being deprecated in favor using the images associated with a productID and will soon be unsupported.
    """
    product_id: NotRequired[str]
    r"""Optional unique identifier associating the line item with a product.
    This is for reporting or tracking purposes, and does not populate other details of the line item.
    """


class CreateTransferLineItem(BaseModel):
    r"""Represents a single item in a transfer, including optional modifiers and quantity."""

    name: str
    r"""The name of the item."""

    base_price: Annotated[AmountDecimal, pydantic.Field(alias="basePrice")]
    r"""The base price of the item before applying option modifiers."""

    quantity: int
    r"""The quantity of this item."""

    options: Optional[List[CreateTransferLineItemOption]] = None
    r"""Optional list of modifiers applied to this item (e.g., toppings, upgrades, customizations)."""

    image_i_ds: Annotated[
        Optional[List[str]],
        pydantic.Field(
            deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible.",
            alias="imageIDs",
        ),
    ] = None
    r"""Optional list of images associated with this line item.
    This field is being deprecated in favor using the images associated with a productID and will soon be unsupported.
    """

    product_id: Annotated[Optional[str], pydantic.Field(alias="productID")] = None
    r"""Optional unique identifier associating the line item with a product.
    This is for reporting or tracking purposes, and does not populate other details of the line item.
    """

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["options", "imageIDs", "productID"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    CreateTransferLineItem.model_rebuild()
except NameError:
    pass
