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

from __future__ import annotations
from .businessprofile import BusinessProfile, BusinessProfileTypedDict
from .guestprofile import GuestProfile, GuestProfileTypedDict
from .individualprofile import IndividualProfile, IndividualProfileTypedDict
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class ProfileTypedDict(TypedDict):
    r"""Describes a Moov account profile. A profile will have a business, individual, or guest depending on the account's type."""

    individual: NotRequired[IndividualProfileTypedDict]
    r"""Describes an individual."""
    business: NotRequired[BusinessProfileTypedDict]
    r"""Describes a business."""
    guest: NotRequired[GuestProfileTypedDict]
    r"""Describes a guest account profile."""


class Profile(BaseModel):
    r"""Describes a Moov account profile. A profile will have a business, individual, or guest depending on the account's type."""

    individual: Optional[IndividualProfile] = None
    r"""Describes an individual."""

    business: Optional[BusinessProfile] = None
    r"""Describes a business."""

    guest: Optional[GuestProfile] = None
    r"""Describes a guest account profile."""

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