"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: 2d7ee4c4db46

from __future__ import annotations
from .locale_response import LocaleResponse
from mollie import models
from mollie.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
import pydantic
from pydantic import field_serializer, model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class OwnerTypedDict(TypedDict):
    r"""Personal data of your customer."""

    email: str
    r"""The email address of your customer."""
    given_name: str
    r"""The given name (first name) of your customer."""
    family_name: str
    r"""The family name (surname) of your customer."""
    locale: NotRequired[Nullable[LocaleResponse]]
    r"""Allows you to preset the language to be used."""


class Owner(BaseModel):
    r"""Personal data of your customer."""

    email: str
    r"""The email address of your customer."""

    given_name: Annotated[str, pydantic.Field(alias="givenName")]
    r"""The given name (first name) of your customer."""

    family_name: Annotated[str, pydantic.Field(alias="familyName")]
    r"""The family name (surname) of your customer."""

    locale: OptionalNullable[LocaleResponse] = UNSET
    r"""Allows you to preset the language to be used."""

    @field_serializer("locale")
    def serialize_locale(self, value):
        if isinstance(value, str):
            try:
                return models.LocaleResponse(value)
            except ValueError:
                return value
        return value

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["locale"])
        nullable_fields = set(["locale"])
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class ClientLinkRequestAddressTypedDict(TypedDict):
    r"""Address of the organization."""

    country: str
    r"""The country of the address in
    [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format.
    """
    street_and_number: NotRequired[Nullable[str]]
    r"""The street name and house number of the organization."""
    postal_code: NotRequired[Nullable[str]]
    r"""The postal code of the organization. Required if a street address is provided and if the country has a postal
    code system.
    """
    city: NotRequired[Nullable[str]]
    r"""The city of the organization. Required if a street address is provided."""


class ClientLinkRequestAddress(BaseModel):
    r"""Address of the organization."""

    country: str
    r"""The country of the address in
    [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format.
    """

    street_and_number: Annotated[
        OptionalNullable[str], pydantic.Field(alias="streetAndNumber")
    ] = UNSET
    r"""The street name and house number of the organization."""

    postal_code: Annotated[
        OptionalNullable[str], pydantic.Field(alias="postalCode")
    ] = UNSET
    r"""The postal code of the organization. Required if a street address is provided and if the country has a postal
    code system.
    """

    city: OptionalNullable[str] = UNSET
    r"""The city of the organization. Required if a street address is provided."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["streetAndNumber", "postalCode", "city"])
        nullable_fields = set(["streetAndNumber", "postalCode", "city"])
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class ClientLinkRequestTypedDict(TypedDict):
    owner: OwnerTypedDict
    r"""Personal data of your customer."""
    name: str
    r"""Name of the organization."""
    address: ClientLinkRequestAddressTypedDict
    r"""Address of the organization."""
    registration_number: NotRequired[Nullable[str]]
    r"""The registration number of the organization at their local chamber of commerce."""
    vat_number: NotRequired[Nullable[str]]
    r"""The VAT number of the organization, if based in the European Union. VAT numbers are verified against the
    international registry *VIES*.
    """
    legal_entity: NotRequired[str]
    r"""The legal entity type of the organization, based on its country of origin. Please refer to the
    [legal entity list](common-data-types#legal-entity) for all possible options.
    """
    registration_office: NotRequired[str]
    r"""The registration office that the organization was registered at. Please refer to the
    [registration office list](common-data-types#registration-office) for all possible options.
    """
    incorporation_date: NotRequired[Nullable[str]]
    r"""The incorporation date of the organization (format `YYYY-MM-DD`)"""


class ClientLinkRequest(BaseModel):
    owner: Owner
    r"""Personal data of your customer."""

    name: str
    r"""Name of the organization."""

    address: ClientLinkRequestAddress
    r"""Address of the organization."""

    registration_number: Annotated[
        OptionalNullable[str], pydantic.Field(alias="registrationNumber")
    ] = UNSET
    r"""The registration number of the organization at their local chamber of commerce."""

    vat_number: Annotated[OptionalNullable[str], pydantic.Field(alias="vatNumber")] = (
        UNSET
    )
    r"""The VAT number of the organization, if based in the European Union. VAT numbers are verified against the
    international registry *VIES*.
    """

    legal_entity: Annotated[Optional[str], pydantic.Field(alias="legalEntity")] = None
    r"""The legal entity type of the organization, based on its country of origin. Please refer to the
    [legal entity list](common-data-types#legal-entity) for all possible options.
    """

    registration_office: Annotated[
        Optional[str], pydantic.Field(alias="registrationOffice")
    ] = None
    r"""The registration office that the organization was registered at. Please refer to the
    [registration office list](common-data-types#registration-office) for all possible options.
    """

    incorporation_date: Annotated[
        OptionalNullable[str], pydantic.Field(alias="incorporationDate")
    ] = UNSET
    r"""The incorporation date of the organization (format `YYYY-MM-DD`)"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "registrationNumber",
                "vatNumber",
                "legalEntity",
                "registrationOffice",
                "incorporationDate",
            ]
        )
        nullable_fields = set(["registrationNumber", "vatNumber", "incorporationDate"])
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


try:
    Owner.model_rebuild()
except NameError:
    pass
try:
    ClientLinkRequestAddress.model_rebuild()
except NameError:
    pass
try:
    ClientLinkRequest.model_rebuild()
except NameError:
    pass
