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

from __future__ import annotations
from .createtransferachaddendarecord import (
    CreateTransferACHAddendaRecord,
    CreateTransferACHAddendaRecordTypedDict,
)
from .debitholdperiod import DebitHoldPeriod
from .seccode import SECCode
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 CreateTransferSourceACHTypedDict(TypedDict):
    company_entry_description: NotRequired[str]
    r"""An optional override of the default NACHA company entry description for a transfer."""
    originating_company_name: NotRequired[str]
    r"""An optional override of the default NACHA company name for a transfer."""
    debit_hold_period: NotRequired[DebitHoldPeriod]
    r"""An optional override of your default ACH hold period in banking days. The hold period must be longer than or equal to your default setting."""
    sec_code: NotRequired[SECCode]
    r"""Code used to identify the ACH authorization method."""
    addenda: NotRequired[List[CreateTransferACHAddendaRecordTypedDict]]


class CreateTransferSourceACH(BaseModel):
    company_entry_description: Annotated[
        Optional[str], pydantic.Field(alias="companyEntryDescription")
    ] = None
    r"""An optional override of the default NACHA company entry description for a transfer."""

    originating_company_name: Annotated[
        Optional[str], pydantic.Field(alias="originatingCompanyName")
    ] = None
    r"""An optional override of the default NACHA company name for a transfer."""

    debit_hold_period: Annotated[
        Optional[DebitHoldPeriod], pydantic.Field(alias="debitHoldPeriod")
    ] = None
    r"""An optional override of your default ACH hold period in banking days. The hold period must be longer than or equal to your default setting."""

    sec_code: Annotated[Optional[SECCode], pydantic.Field(alias="secCode")] = None
    r"""Code used to identify the ACH authorization method."""

    addenda: Optional[List[CreateTransferACHAddendaRecord]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "companyEntryDescription",
                "originatingCompanyName",
                "debitHoldPeriod",
                "secCode",
                "addenda",
            ]
        )
        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:
    CreateTransferSourceACH.model_rebuild()
except NameError:
    pass
