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

from __future__ import annotations
from .amountdecimal import AmountDecimal, AmountDecimalTypedDict
from .paymentlinklineitemimagemetadata import (
    PaymentLinkLineItemImageMetadata,
    PaymentLinkLineItemImageMetadataTypedDict,
)
from .paymentlinklineitemoption import (
    PaymentLinkLineItemOption,
    PaymentLinkLineItemOptionTypedDict,
)
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 PaymentLinkLineItemTypedDict(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[PaymentLinkLineItemOptionTypedDict]]
    r"""Optional list of modifiers applied to this item (e.g., toppings, upgrades, customizations)."""
    images: NotRequired[List[PaymentLinkLineItemImageMetadataTypedDict]]
    r"""Optional list of images associated with this line item."""
    product_id: NotRequired[str]
    r"""Optional unique identifier associating the line item with a product."""


class PaymentLinkLineItem(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[PaymentLinkLineItemOption]] = None
    r"""Optional list of modifiers applied to this item (e.g., toppings, upgrades, customizations)."""

    images: Optional[List[PaymentLinkLineItemImageMetadata]] = None
    r"""Optional list of images associated with this line item."""

    product_id: Annotated[Optional[str], pydantic.Field(alias="productID")] = None
    r"""Optional unique identifier associating the line item with a product."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["options", "images", "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:
    PaymentLinkLineItem.model_rebuild()
except NameError:
    pass
