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

from __future__ import annotations
from .mode import Mode
from .occurrencesresponse import OccurrencesResponse, OccurrencesResponseTypedDict
from .recurresponse import RecurResponse, RecurResponseTypedDict
from datetime import datetime
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ScheduleResponseTypedDict(TypedDict):
    destination_account_id: str
    mode: Mode
    r"""The operating mode for an account."""
    owner_account_id: str
    partner_account_id: str
    schedule_id: str
    source_account_id: str
    created_on: datetime
    updated_on: datetime
    description: NotRequired[str]
    r"""Simple description to place on the transfer."""
    occurrences: NotRequired[List[OccurrencesResponseTypedDict]]
    recur: NotRequired[RecurResponseTypedDict]
    disabled_on: NotRequired[datetime]


class ScheduleResponse(BaseModel):
    destination_account_id: Annotated[str, pydantic.Field(alias="destinationAccountID")]

    mode: Mode
    r"""The operating mode for an account."""

    owner_account_id: Annotated[str, pydantic.Field(alias="ownerAccountID")]

    partner_account_id: Annotated[str, pydantic.Field(alias="partnerAccountID")]

    schedule_id: Annotated[str, pydantic.Field(alias="scheduleID")]

    source_account_id: Annotated[str, pydantic.Field(alias="sourceAccountID")]

    created_on: Annotated[datetime, pydantic.Field(alias="createdOn")]

    updated_on: Annotated[datetime, pydantic.Field(alias="updatedOn")]

    description: Optional[str] = None
    r"""Simple description to place on the transfer."""

    occurrences: Optional[List[OccurrencesResponse]] = None

    recur: Optional[RecurResponse] = None

    disabled_on: Annotated[Optional[datetime], pydantic.Field(alias="disabledOn")] = (
        None
    )

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


try:
    ScheduleResponse.model_rebuild()
except NameError:
    pass
