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

from __future__ import annotations
from .address import Address, AddressTypedDict
from .enrichedindustrycodes import EnrichedIndustryCodes, EnrichedIndustryCodesTypedDict
from .phonenumber import PhoneNumber, PhoneNumberTypedDict
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class EnrichedBusinessProfileTypedDict(TypedDict):
    address: NotRequired[AddressTypedDict]
    email: NotRequired[str]
    industry_codes: NotRequired[EnrichedIndustryCodesTypedDict]
    legal_business_name: NotRequired[str]
    phone: NotRequired[PhoneNumberTypedDict]
    website: NotRequired[str]


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

    email: Optional[str] = None

    industry_codes: Annotated[
        Optional[EnrichedIndustryCodes], pydantic.Field(alias="industryCodes")
    ] = None

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

    phone: Optional[PhoneNumber] = None

    website: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "address",
                "email",
                "industryCodes",
                "legalBusinessName",
                "phone",
                "website",
            ]
        )
        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:
    EnrichedBusinessProfile.model_rebuild()
except NameError:
    pass
