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

from __future__ import annotations
from .directoryextension import DirectoryExtension, DirectoryExtensionTypedDict
from pydantic import model_serializer
from syllable_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from typing import Dict, List
from typing_extensions import NotRequired, TypedDict


class DirectoryMemberCreateTypedDict(TypedDict):
    r"""Request model to create a directory member."""

    name: str
    r"""Name of the directory member"""
    type: str
    r"""Type of the directory member"""
    extensions: NotRequired[Nullable[List[DirectoryExtensionTypedDict]]]
    r"""List of extensions for the directory member"""
    contact_tags: NotRequired[Nullable[Dict[str, List[str]]]]
    r"""Tags for the directory member"""


class DirectoryMemberCreate(BaseModel):
    r"""Request model to create a directory member."""

    name: str
    r"""Name of the directory member"""

    type: str
    r"""Type of the directory member"""

    extensions: OptionalNullable[List[DirectoryExtension]] = UNSET
    r"""List of extensions for the directory member"""

    contact_tags: OptionalNullable[Dict[str, List[str]]] = UNSET
    r"""Tags for the directory member"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["extensions", "contact_tags"])
        nullable_fields = set(["extensions", "contact_tags"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            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
