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

from __future__ import annotations
from .address import Address, AddressTypedDict
from datetime import date
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
from paygentic_sdk.utils import FieldMetadata, PathParamMetadata, RequestMetadata
import pydantic
from pydantic import model_serializer
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


UpdateUserType = Literal[
    "COMPANY",
    "INDIVIDUAL",
]
r"""Type of entity the user represents."""


class UpdateUserRequestBodyTypedDict(TypedDict):
    address: NotRequired[AddressTypedDict]
    date_of_birth: NotRequired[date]
    r"""The date of birth of the user."""
    first_name: NotRequired[str]
    r"""The first name of the user."""
    last_name: NotRequired[str]
    r"""The last name of the user."""
    phone: NotRequired[str]
    r"""The phone number of the user."""
    type: NotRequired[UpdateUserType]
    r"""Type of entity the user represents."""


class UpdateUserRequestBody(BaseModel):
    address: Optional[Address] = None

    date_of_birth: Annotated[Optional[date], pydantic.Field(alias="dateOfBirth")] = None
    r"""The date of birth of the user."""

    first_name: Annotated[Optional[str], pydantic.Field(alias="firstName")] = None
    r"""The first name of the user."""

    last_name: Annotated[Optional[str], pydantic.Field(alias="lastName")] = None
    r"""The last name of the user."""

    phone: Optional[str] = None
    r"""The phone number of the user."""

    type: Optional[UpdateUserType] = None
    r"""Type of entity the user represents."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["address", "dateOfBirth", "firstName", "lastName", "phone", "type"]
        )
        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


class UpdateUserRequestTypedDict(TypedDict):
    id: str
    request_body: UpdateUserRequestBodyTypedDict


class UpdateUserRequest(BaseModel):
    id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]

    request_body: Annotated[
        UpdateUserRequestBody,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]


try:
    UpdateUserRequestBody.model_rebuild()
except NameError:
    pass
