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

from __future__ import annotations
from .amountdecimal import AmountDecimal, AmountDecimalTypedDict
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 CreatePaymentLinkLineItemOptionTypedDict(TypedDict):
    r"""Represents a modifier or option applied to a line item."""

    name: str
    r"""The name of the option or modifier."""
    quantity: int
    r"""The quantity of this option."""
    price_modifier: NotRequired[AmountDecimalTypedDict]
    r"""Optional price modification applied by this option. Can be positive, negative, or zero."""
    image_i_ds: NotRequired[List[str]]
    r"""Optional list of images associated with this line item option.
    This field is being deprecated in favor using the images associated with a productID and will soon be unsupported.
    """
    group: NotRequired[str]
    r"""Optional group identifier to categorize related options (e.g., 'toppings')."""


class CreatePaymentLinkLineItemOption(BaseModel):
    r"""Represents a modifier or option applied to a line item."""

    name: str
    r"""The name of the option or modifier."""

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

    price_modifier: Annotated[
        Optional[AmountDecimal], pydantic.Field(alias="priceModifier")
    ] = None
    r"""Optional price modification applied by this option. Can be positive, negative, or zero."""

    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 option.
    This field is being deprecated in favor using the images associated with a productID and will soon be unsupported.
    """

    group: Optional[str] = None
    r"""Optional group identifier to categorize related options (e.g., 'toppings')."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["priceModifier", "imageIDs", "group"])
        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:
    CreatePaymentLinkLineItemOption.model_rebuild()
except NameError:
    pass
