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

from __future__ import annotations
from .amountdecimal import AmountDecimal, AmountDecimalTypedDict
from .createpaymentlinklineitemoption import (
    CreatePaymentLinkLineItemOption,
    CreatePaymentLinkLineItemOptionTypedDict,
)
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 CreatePaymentLinkLineItemTypedDict(TypedDict):
    r"""Represents a single line item in a payment link, 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[CreatePaymentLinkLineItemOptionTypedDict]]
    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 deprecated and will be ignored. A future release will populate images associated with the given productID.
    """
    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 CreatePaymentLinkLineItem(BaseModel):
    r"""Represents a single line item in a payment link, 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[CreatePaymentLinkLineItemOption]] = 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 deprecated and will be ignored. A future release will populate images associated with the given productID.
    """

    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)

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

        return m
