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

from __future__ import annotations
from .businesspresence import BusinessPresence
from .collectfunds import CollectFunds, CollectFundsTypedDict
from .geographicreach import GeographicReach
from .moneytransfer import MoneyTransfer, MoneyTransferTypedDict
from .pendinglitigation import PendingLitigation
from .sendfunds import SendFunds, SendFundsTypedDict
from .submissionintent import SubmissionIntent
from .volumesharebycustomertype import (
    VolumeShareByCustomerType,
    VolumeShareByCustomerTypeTypedDict,
)
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 UpsertUnderwritingTypedDict(TypedDict):
    geographic_reach: NotRequired[GeographicReach]
    business_presence: NotRequired[BusinessPresence]
    pending_litigation: NotRequired[PendingLitigation]
    volume_share_by_customer_type: NotRequired[VolumeShareByCustomerTypeTypedDict]
    collect_funds: NotRequired[CollectFundsTypedDict]
    money_transfer: NotRequired[MoneyTransferTypedDict]
    send_funds: NotRequired[SendFundsTypedDict]
    submission_intent: NotRequired[SubmissionIntent]


class UpsertUnderwriting(BaseModel):
    geographic_reach: Annotated[
        Optional[GeographicReach], pydantic.Field(alias="geographicReach")
    ] = None

    business_presence: Annotated[
        Optional[BusinessPresence], pydantic.Field(alias="businessPresence")
    ] = None

    pending_litigation: Annotated[
        Optional[PendingLitigation], pydantic.Field(alias="pendingLitigation")
    ] = None

    volume_share_by_customer_type: Annotated[
        Optional[VolumeShareByCustomerType],
        pydantic.Field(alias="volumeShareByCustomerType"),
    ] = None

    collect_funds: Annotated[
        Optional[CollectFunds], pydantic.Field(alias="collectFunds")
    ] = None

    money_transfer: Annotated[
        Optional[MoneyTransfer], pydantic.Field(alias="moneyTransfer")
    ] = None

    send_funds: Annotated[Optional[SendFunds], pydantic.Field(alias="sendFunds")] = None

    submission_intent: Annotated[
        Optional[SubmissionIntent], pydantic.Field(alias="submissionIntent")
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "geographicReach",
                "businessPresence",
                "pendingLitigation",
                "volumeShareByCustomerType",
                "collectFunds",
                "moneyTransfer",
                "sendFunds",
                "submissionIntent",
            ]
        )
        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:
    UpsertUnderwriting.model_rebuild()
except NameError:
    pass
