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

from __future__ import annotations
from .runtransfer import RunTransfer, RunTransferTypedDict
from datetime import datetime
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class RecurResponseTypedDict(TypedDict):
    recurrence_rule: str
    r"""RRule as defined by RFC 5545 (https://www.rfc-editor.org/rfc/rfc5545#section-3.3.10).
    Generators available online at the following sites - https://freetools.textmagic.com/rrule-generator, https://jkbrzt.github.io/rrule/
    """
    run_transfer: RunTransferTypedDict
    indefinite: NotRequired[bool]
    r"""True if the RRule set runs indefinitely."""
    start: NotRequired[datetime]


class RecurResponse(BaseModel):
    recurrence_rule: Annotated[str, pydantic.Field(alias="recurrenceRule")]
    r"""RRule as defined by RFC 5545 (https://www.rfc-editor.org/rfc/rfc5545#section-3.3.10).
    Generators available online at the following sites - https://freetools.textmagic.com/rrule-generator, https://jkbrzt.github.io/rrule/
    """

    run_transfer: Annotated[RunTransfer, pydantic.Field(alias="runTransfer")]

    indefinite: Optional[bool] = None
    r"""True if the RRule set runs indefinitely."""

    start: Optional[datetime] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["indefinite", "start"])
        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:
    RecurResponse.model_rebuild()
except NameError:
    pass
