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

from __future__ import annotations
from .channeltypeenum import ChannelTypeEnum
from .messagesresponsedto import MessagesResponseDto, MessagesResponseDtoTypedDict
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 MessagesControllerGetMessagesRequestTypedDict(TypedDict):
    channel: NotRequired[ChannelTypeEnum]
    r"""Channel type through which the message is sent"""
    subscriber_id: NotRequired[str]
    transaction_id: NotRequired[List[str]]
    context_keys: NotRequired[List[str]]
    r"""Filter by exact context keys, order insensitive (format: \"type:id\")"""
    page: NotRequired[float]
    limit: NotRequired[float]
    idempotency_key: NotRequired[str]
    r"""A header for idempotency purposes"""


class MessagesControllerGetMessagesRequest(BaseModel):
    channel: Annotated[
        Optional[ChannelTypeEnum],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Channel type through which the message is sent"""

    subscriber_id: Annotated[
        Optional[str],
        pydantic.Field(alias="subscriberId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    transaction_id: Annotated[
        Optional[List[str]],
        pydantic.Field(alias="transactionId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None

    context_keys: Annotated[
        Optional[List[str]],
        pydantic.Field(alias="contextKeys"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter by exact context keys, order insensitive (format: \"type:id\")"""

    page: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 0

    limit: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 10

    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(
            [
                "channel",
                "subscriberId",
                "transactionId",
                "contextKeys",
                "page",
                "limit",
                "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 MessagesControllerGetMessagesResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: MessagesResponseDtoTypedDict


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

    result: MessagesResponseDto
