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

from __future__ import annotations
from .amountdecimal import AmountDecimal, AmountDecimalTypedDict
from .invoicelineitemimagemetadata import (
    InvoiceLineItemImageMetadata,
    InvoiceLineItemImageMetadataTypedDict,
)
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 InvoiceLineItemOptionTypedDict(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."""
    group: NotRequired[str]
    r"""Optional group identifier to categorize related options (e.g., 'toppings')."""
    images: NotRequired[List[InvoiceLineItemImageMetadataTypedDict]]
    r"""Optional list of images associated with this line item option."""


class InvoiceLineItemOption(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."""

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["priceModifier", "group", "images"])
        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


try:
    InvoiceLineItemOption.model_rebuild()
except NameError:
    pass
