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

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


class QueryParamOrderDirection(str, Enum):
    r"""Direction of sorting"""

    ASC = "ASC"
    DESC = "DESC"


class SubscribersControllerSearchSubscribersRequestTypedDict(TypedDict):
    after: NotRequired[str]
    r"""Cursor for pagination indicating the starting point after which to fetch results."""
    before: NotRequired[str]
    r"""Cursor for pagination indicating the ending point before which to fetch results."""
    limit: NotRequired[float]
    r"""Limit the number of items to return"""
    order_direction: NotRequired[QueryParamOrderDirection]
    r"""Direction of sorting"""
    order_by: NotRequired[str]
    r"""Field to order by"""
    include_cursor: NotRequired[bool]
    r"""Include cursor item in response"""
    email: NotRequired[str]
    r"""Email address of the subscriber to filter results."""
    name: NotRequired[str]
    r"""Name of the subscriber to filter results."""
    phone: NotRequired[str]
    r"""Phone number of the subscriber to filter results."""
    subscriber_id: NotRequired[str]
    r"""Unique identifier of the subscriber to filter results."""
    idempotency_key: NotRequired[str]
    r"""A header for idempotency purposes"""


class SubscribersControllerSearchSubscribersRequest(BaseModel):
    after: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Cursor for pagination indicating the starting point after which to fetch results."""

    before: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Cursor for pagination indicating the ending point before which to fetch results."""

    limit: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Limit the number of items to return"""

    order_direction: Annotated[
        Optional[QueryParamOrderDirection],
        pydantic.Field(alias="orderDirection"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Direction of sorting"""

    order_by: Annotated[
        Optional[str],
        pydantic.Field(alias="orderBy"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Field to order by"""

    include_cursor: Annotated[
        Optional[bool],
        pydantic.Field(alias="includeCursor"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Include cursor item in response"""

    email: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Email address of the subscriber to filter results."""

    name: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Name of the subscriber to filter results."""

    phone: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Phone number of the subscriber to filter results."""

    subscriber_id: Annotated[
        Optional[str],
        pydantic.Field(alias="subscriberId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Unique identifier of the subscriber to filter results."""

    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(
            [
                "after",
                "before",
                "limit",
                "orderDirection",
                "orderBy",
                "includeCursor",
                "email",
                "name",
                "phone",
                "subscriberId",
                "idempotency-key",
            ]
        )
        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


class SubscribersControllerSearchSubscribersResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: ListSubscribersResponseDtoTypedDict


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

    result: ListSubscribersResponseDto
