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

from __future__ import annotations
from enum import Enum
from panora_sdk.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing import TypedDict


class ObjectTypeOwner(str, Enum):
    COMPANY = "company"
    CONTACT = "contact"
    DEAL = "deal"
    LEAD = "lead"
    NOTE = "note"
    TASK = "task"
    ENGAGEMENT = "engagement"
    STAGE = "stage"
    USER = "user"

class DataType(str, Enum):
    r"""The data type of the target field"""
    STRING = "string"
    NUMBER = "number"

class DefineTargetFieldDtoTypedDict(TypedDict):
    object_type_owner: Nullable[ObjectTypeOwner]
    name: Nullable[str]
    r"""The name of the target field"""
    description: Nullable[str]
    r"""The description of the target field"""
    data_type: Nullable[DataType]
    r"""The data type of the target field"""
    

class DefineTargetFieldDto(BaseModel):
    object_type_owner: Nullable[ObjectTypeOwner]
    name: Nullable[str]
    r"""The name of the target field"""
    description: Nullable[str]
    r"""The description of the target field"""
    data_type: Nullable[DataType]
    r"""The data type of the target field"""
    
    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["object_type_owner", "name", "description", "data_type"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields
                or (
                    k in optional_fields
                    and k in nullable_fields
                    and (
                        self.__pydantic_fields_set__.intersection({n})
                        or k in null_default_fields
                    )  # pylint: disable=no-member
                )
            ):
                m[k] = val

        return m
        
