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

from __future__ import annotations
from .getsubscriberpreferencesdto import (
    GetSubscriberPreferencesDto,
    GetSubscriberPreferencesDtoTypedDict,
)
from enum import Enum
from novu_py.types import BaseModel, UNSET_SENTINEL
from novu_py.utils import (
    FieldMetadata,
    HeaderMetadata,
    PathParamMetadata,
    QueryParamMetadata,
)
import pydantic
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class Criticality(str, Enum):
    CRITICAL = "critical"
    NON_CRITICAL = "nonCritical"
    ALL = "all"


class SubscribersControllerGetSubscriberPreferencesRequestTypedDict(TypedDict):
    subscriber_id: str
    criticality: NotRequired[Criticality]
    context_keys: NotRequired[List[str]]
    r"""Context keys for filtering preferences (e.g., [\"tenant:acme\"])"""
    idempotency_key: NotRequired[str]
    r"""A header for idempotency purposes"""


class SubscribersControllerGetSubscriberPreferencesRequest(BaseModel):
    subscriber_id: Annotated[
        str,
        pydantic.Field(alias="subscriberId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]

    criticality: Annotated[
        Optional[Criticality],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = Criticality.NON_CRITICAL

    context_keys: Annotated[
        Optional[List[str]],
        pydantic.Field(alias="contextKeys"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Context keys for filtering preferences (e.g., [\"tenant:acme\"])"""

    idempotency_key: Annotated[
        Optional[str],
        pydantic.Field(alias="idempotency-key"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None
    r"""A header for idempotency purposes"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["criticality", "contextKeys", "idempotency-key"])
        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


class SubscribersControllerGetSubscriberPreferencesResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: GetSubscriberPreferencesDtoTypedDict


class SubscribersControllerGetSubscriberPreferencesResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: GetSubscriberPreferencesDto
