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

from __future__ import annotations
from .emailcontroldto import EmailControlDto, EmailControlDtoTypedDict
from .steptypeenum import StepTypeEnum
from novu_py.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


EmailStepUpsertDtoControlValuesTypedDict = TypeAliasType(
    "EmailStepUpsertDtoControlValuesTypedDict",
    Union[EmailControlDtoTypedDict, Dict[str, Any]],
)
r"""Control values for the Email step."""


EmailStepUpsertDtoControlValues = TypeAliasType(
    "EmailStepUpsertDtoControlValues", Union[EmailControlDto, Dict[str, Any]]
)
r"""Control values for the Email step."""


class EmailStepUpsertDtoTypedDict(TypedDict):
    name: str
    r"""Name of the step"""
    type: StepTypeEnum
    r"""Type of the step"""
    id: NotRequired[str]
    r"""Database identifier of the step. Used for updating the step."""
    step_id: NotRequired[str]
    r"""Unique identifier for the step"""
    control_values: NotRequired[EmailStepUpsertDtoControlValuesTypedDict]
    r"""Control values for the Email step."""


class EmailStepUpsertDto(BaseModel):
    name: str
    r"""Name of the step"""

    type: StepTypeEnum
    r"""Type of the step"""

    id: Annotated[Optional[str], pydantic.Field(alias="_id")] = None
    r"""Database identifier of the step. Used for updating the step."""

    step_id: Annotated[Optional[str], pydantic.Field(alias="stepId")] = None
    r"""Unique identifier for the step"""

    control_values: Annotated[
        Optional[EmailStepUpsertDtoControlValues], pydantic.Field(alias="controlValues")
    ] = None
    r"""Control values for the Email step."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["_id", "stepId", "controlValues"])
        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:
    EmailStepUpsertDto.model_rebuild()
except NameError:
    pass
