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

from __future__ import annotations
from .amountdecimalvalidationerror import (
    AmountDecimalValidationError,
    AmountDecimalValidationErrorTypedDict,
)
from .createtransferlineitemoptionvalidationerror import (
    CreateTransferLineItemOptionValidationError,
    CreateTransferLineItemOptionValidationErrorTypedDict,
)
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class CreateTransferLineItemValidationErrorTypedDict(TypedDict):
    product_id: NotRequired[str]
    name: NotRequired[str]
    base_price: NotRequired[AmountDecimalValidationErrorTypedDict]
    options: NotRequired[
        Dict[str, CreateTransferLineItemOptionValidationErrorTypedDict]
    ]
    quantity: NotRequired[str]
    image_i_ds: NotRequired[str]


class CreateTransferLineItemValidationError(BaseModel):
    product_id: Annotated[Optional[str], pydantic.Field(alias="productID")] = None

    name: Optional[str] = None

    base_price: Annotated[
        Optional[AmountDecimalValidationError], pydantic.Field(alias="basePrice")
    ] = None

    options: Optional[Dict[str, CreateTransferLineItemOptionValidationError]] = None

    quantity: Optional[str] = None

    image_i_ds: Annotated[Optional[str], pydantic.Field(alias="imageIDs")] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["productID", "name", "basePrice", "options", "quantity", "imageIDs"]
        )
        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:
    CreateTransferLineItemValidationError.model_rebuild()
except NameError:
    pass
