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

from __future__ import annotations
from .subscriberpreferencechannels import (
    SubscriberPreferenceChannels,
    SubscriberPreferenceChannelsTypedDict,
)
from .subscriberpreferenceoverridedto import (
    SubscriberPreferenceOverrideDto,
    SubscriberPreferenceOverrideDtoTypedDict,
)
from .subscriberpreferencesworkflowinfodto import (
    SubscriberPreferencesWorkflowInfoDto,
    SubscriberPreferencesWorkflowInfoDtoTypedDict,
)
from novu_py.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class SubscriberWorkflowPreferenceDtoTypedDict(TypedDict):
    enabled: bool
    r"""Whether notifications are enabled for this workflow"""
    channels: SubscriberPreferenceChannelsTypedDict
    r"""Channel-specific preference settings for this workflow"""
    overrides: List[SubscriberPreferenceOverrideDtoTypedDict]
    r"""List of preference overrides"""
    workflow: SubscriberPreferencesWorkflowInfoDtoTypedDict
    r"""Workflow information"""
    updated_at: NotRequired[str]
    r"""Timestamp when the subscriber last updated their preference. Only present if subscriber explicitly set preferences."""


class SubscriberWorkflowPreferenceDto(BaseModel):
    enabled: bool
    r"""Whether notifications are enabled for this workflow"""

    channels: SubscriberPreferenceChannels
    r"""Channel-specific preference settings for this workflow"""

    overrides: List[SubscriberPreferenceOverrideDto]
    r"""List of preference overrides"""

    workflow: SubscriberPreferencesWorkflowInfoDto
    r"""Workflow information"""

    updated_at: Annotated[Optional[str], pydantic.Field(alias="updatedAt")] = None
    r"""Timestamp when the subscriber last updated their preference. Only present if subscriber explicitly set preferences."""

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

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    SubscriberWorkflowPreferenceDto.model_rebuild()
except NameError:
    pass
