# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations
from ...core.pydantic_utilities import UniversalBaseModel
import typing
import pydantic
from .custom_payment_method_schema_id import CustomPaymentMethodSchemaId
from ...core.pydantic_utilities import IS_PYDANTIC_V2
from .plaid_link_request import PlaidLinkRequest
from .bank_account_check_options import BankAccountCheckOptions


class PaymentMethodUpdateRequest_Custom(UniversalBaseModel):
    """
    Update a payment method. for non custom payment methods.

    Examples
    --------
    from mercoa.payment_method_types import PaymentMethodUpdateRequest_BankAccount

    PaymentMethodUpdateRequest_BankAccount(
        default_source=True,
        default_destination=True,
    )
    """

    type: typing.Literal["custom"] = "custom"
    foreign_id: typing.Optional[str] = pydantic.Field(alias="foreignId", default=None)
    account_name: typing.Optional[str] = pydantic.Field(alias="accountName", default=None)
    account_number: typing.Optional[str] = pydantic.Field(alias="accountNumber", default=None)
    available_balance: typing.Optional[float] = pydantic.Field(alias="availableBalance", default=None)
    schema_id: typing.Optional[CustomPaymentMethodSchemaId] = pydantic.Field(alias="schemaId", default=None)
    data: typing.Optional[typing.Dict[str, str]] = None
    default_source: typing.Optional[bool] = pydantic.Field(alias="defaultSource", default=None)
    default_destination: typing.Optional[bool] = pydantic.Field(alias="defaultDestination", default=None)
    external_accounting_system_id: typing.Optional[str] = pydantic.Field(
        alias="externalAccountingSystemId", default=None
    )
    frozen: typing.Optional[bool] = None
    metadata: typing.Optional[typing.Dict[str, str]] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class PaymentMethodUpdateRequest_BankAccount(UniversalBaseModel):
    """
    Update a payment method. for non custom payment methods.

    Examples
    --------
    from mercoa.payment_method_types import PaymentMethodUpdateRequest_BankAccount

    PaymentMethodUpdateRequest_BankAccount(
        default_source=True,
        default_destination=True,
    )
    """

    type: typing.Literal["bankAccount"] = "bankAccount"
    account_name: typing.Optional[str] = pydantic.Field(alias="accountName", default=None)
    plaid: typing.Optional[PlaidLinkRequest] = None
    check_options: typing.Optional[BankAccountCheckOptions] = pydantic.Field(alias="checkOptions", default=None)
    default_source: typing.Optional[bool] = pydantic.Field(alias="defaultSource", default=None)
    default_destination: typing.Optional[bool] = pydantic.Field(alias="defaultDestination", default=None)
    external_accounting_system_id: typing.Optional[str] = pydantic.Field(
        alias="externalAccountingSystemId", default=None
    )
    frozen: typing.Optional[bool] = None
    metadata: typing.Optional[typing.Dict[str, str]] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class PaymentMethodUpdateRequest_Card(UniversalBaseModel):
    """
    Update a payment method. for non custom payment methods.

    Examples
    --------
    from mercoa.payment_method_types import PaymentMethodUpdateRequest_BankAccount

    PaymentMethodUpdateRequest_BankAccount(
        default_source=True,
        default_destination=True,
    )
    """

    type: typing.Literal["card"] = "card"
    default_source: typing.Optional[bool] = pydantic.Field(alias="defaultSource", default=None)
    default_destination: typing.Optional[bool] = pydantic.Field(alias="defaultDestination", default=None)
    external_accounting_system_id: typing.Optional[str] = pydantic.Field(
        alias="externalAccountingSystemId", default=None
    )
    frozen: typing.Optional[bool] = None
    metadata: typing.Optional[typing.Dict[str, str]] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class PaymentMethodUpdateRequest_Check(UniversalBaseModel):
    """
    Update a payment method. for non custom payment methods.

    Examples
    --------
    from mercoa.payment_method_types import PaymentMethodUpdateRequest_BankAccount

    PaymentMethodUpdateRequest_BankAccount(
        default_source=True,
        default_destination=True,
    )
    """

    type: typing.Literal["check"] = "check"
    default_source: typing.Optional[bool] = pydantic.Field(alias="defaultSource", default=None)
    default_destination: typing.Optional[bool] = pydantic.Field(alias="defaultDestination", default=None)
    external_accounting_system_id: typing.Optional[str] = pydantic.Field(
        alias="externalAccountingSystemId", default=None
    )
    frozen: typing.Optional[bool] = None
    metadata: typing.Optional[typing.Dict[str, str]] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class PaymentMethodUpdateRequest_OffPlatform(UniversalBaseModel):
    """
    Update a payment method. for non custom payment methods.

    Examples
    --------
    from mercoa.payment_method_types import PaymentMethodUpdateRequest_BankAccount

    PaymentMethodUpdateRequest_BankAccount(
        default_source=True,
        default_destination=True,
    )
    """

    type: typing.Literal["offPlatform"] = "offPlatform"
    default_source: typing.Optional[bool] = pydantic.Field(alias="defaultSource", default=None)
    default_destination: typing.Optional[bool] = pydantic.Field(alias="defaultDestination", default=None)
    external_accounting_system_id: typing.Optional[str] = pydantic.Field(
        alias="externalAccountingSystemId", default=None
    )
    frozen: typing.Optional[bool] = None
    metadata: typing.Optional[typing.Dict[str, str]] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class PaymentMethodUpdateRequest_Utility(UniversalBaseModel):
    """
    Update a payment method. for non custom payment methods.

    Examples
    --------
    from mercoa.payment_method_types import PaymentMethodUpdateRequest_BankAccount

    PaymentMethodUpdateRequest_BankAccount(
        default_source=True,
        default_destination=True,
    )
    """

    type: typing.Literal["utility"] = "utility"
    default_source: typing.Optional[bool] = pydantic.Field(alias="defaultSource", default=None)
    default_destination: typing.Optional[bool] = pydantic.Field(alias="defaultDestination", default=None)
    external_accounting_system_id: typing.Optional[str] = pydantic.Field(
        alias="externalAccountingSystemId", default=None
    )
    frozen: typing.Optional[bool] = None
    metadata: typing.Optional[typing.Dict[str, str]] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


"""
from mercoa.payment_method_types import PaymentMethodUpdateRequest_BankAccount

PaymentMethodUpdateRequest_BankAccount(
    default_source=True,
    default_destination=True,
)
"""
PaymentMethodUpdateRequest = typing.Union[
    PaymentMethodUpdateRequest_Custom,
    PaymentMethodUpdateRequest_BankAccount,
    PaymentMethodUpdateRequest_Card,
    PaymentMethodUpdateRequest_Check,
    PaymentMethodUpdateRequest_OffPlatform,
    PaymentMethodUpdateRequest_Utility,
]
