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

from __future__ import annotations
from .authdto import AuthDto, AuthDtoTypedDict
from .workspacedto import WorkspaceDto, WorkspaceDtoTypedDict
from novu_py.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class CreateChannelConnectionRequestDtoContext2TypedDict(TypedDict):
    r"""Rich context object with id and optional data"""

    id: str
    data: NotRequired[Dict[str, Any]]
    r"""Optional additional context data"""


class CreateChannelConnectionRequestDtoContext2(BaseModel):
    r"""Rich context object with id and optional data"""

    id: str

    data: Optional[Dict[str, Any]] = None
    r"""Optional additional context data"""

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


CreateChannelConnectionRequestDtoContextTypedDict = TypeAliasType(
    "CreateChannelConnectionRequestDtoContextTypedDict",
    Union[CreateChannelConnectionRequestDtoContext2TypedDict, str],
)


CreateChannelConnectionRequestDtoContext = TypeAliasType(
    "CreateChannelConnectionRequestDtoContext",
    Union[CreateChannelConnectionRequestDtoContext2, str],
)


class CreateChannelConnectionRequestDtoTypedDict(TypedDict):
    integration_identifier: str
    r"""The identifier of the integration to use for this channel connection."""
    workspace: WorkspaceDtoTypedDict
    auth: AuthDtoTypedDict
    identifier: NotRequired[str]
    r"""The unique identifier for the channel connection. If not provided, one will be generated automatically."""
    subscriber_id: NotRequired[str]
    r"""The subscriber ID to link the channel connection to"""
    context: NotRequired[Dict[str, CreateChannelConnectionRequestDtoContextTypedDict]]


class CreateChannelConnectionRequestDto(BaseModel):
    integration_identifier: Annotated[
        str, pydantic.Field(alias="integrationIdentifier")
    ]
    r"""The identifier of the integration to use for this channel connection."""

    workspace: WorkspaceDto

    auth: AuthDto

    identifier: Optional[str] = None
    r"""The unique identifier for the channel connection. If not provided, one will be generated automatically."""

    subscriber_id: Annotated[Optional[str], pydantic.Field(alias="subscriberId")] = None
    r"""The subscriber ID to link the channel connection to"""

    context: Optional[Dict[str, CreateChannelConnectionRequestDtoContext]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["identifier", "subscriberId", "context"])
        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


try:
    CreateChannelConnectionRequestDto.model_rebuild()
except NameError:
    pass
