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

from __future__ import annotations
from .subscriptionpreferencedto import (
    SubscriptionPreferenceDto,
    SubscriptionPreferenceDtoTypedDict,
)
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 SubscriptionDetailsResponseDtoTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the subscription"""
    identifier: NotRequired[str]
    r"""The identifier of the subscription"""
    name: NotRequired[str]
    r"""The name of the subscription"""
    preferences: NotRequired[List[SubscriptionPreferenceDtoTypedDict]]
    r"""The preferences/rules for the subscription"""
    context_keys: NotRequired[List[str]]
    r"""Context keys that scope this subscription (e.g., tenant:org-a, project:proj-123)"""


class SubscriptionDetailsResponseDto(BaseModel):
    id: str
    r"""The unique identifier of the subscription"""

    identifier: Optional[str] = None
    r"""The identifier of the subscription"""

    name: Optional[str] = None
    r"""The name of the subscription"""

    preferences: Optional[List[SubscriptionPreferenceDto]] = None
    r"""The preferences/rules for the subscription"""

    context_keys: Annotated[
        Optional[List[str]], pydantic.Field(alias="contextKeys")
    ] = None
    r"""Context keys that scope this subscription (e.g., tenant:org-a, project:proj-123)"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["identifier", "name", "preferences", "contextKeys"])
        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:
    SubscriptionDetailsResponseDto.model_rebuild()
except NameError:
    pass
