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

from __future__ import annotations
from datetime import datetime
from pydantic import model_serializer
from syllable_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from typing_extensions import NotRequired, TypedDict


class CommunicationBatchInputTypedDict(TypedDict):
    batch_id: str
    r"""Unique ID for conversation batch"""
    campaign_id: int
    r"""Unique ID for campaign"""
    expires_on: NotRequired[Nullable[datetime]]
    r"""Timestamp of batch expiration"""
    paused: NotRequired[Nullable[bool]]
    r"""Whether the batch is on HOLD. When on HOLD, no outreach will be made."""


class CommunicationBatchInput(BaseModel):
    batch_id: str
    r"""Unique ID for conversation batch"""

    campaign_id: int
    r"""Unique ID for campaign"""

    expires_on: OptionalNullable[datetime] = UNSET
    r"""Timestamp of batch expiration"""

    paused: OptionalNullable[bool] = UNSET
    r"""Whether the batch is on HOLD. When on HOLD, no outreach will be made."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["expires_on", "paused"])
        nullable_fields = set(["expires_on", "paused"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m
