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

from __future__ import annotations
from .beneficiary import Beneficiary, BeneficiaryTypedDict
from .foreignbondtradingdetail import (
    ForeignBondTradingDetail,
    ForeignBondTradingDetailTypedDict,
)
from .relatedpep import RelatedPep, RelatedPepTypedDict
from ascend_sdk import utils
from ascend_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from ascend_sdk.utils import validate_open_enum
from datetime import datetime
from enum import Enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class BeneficiaryEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the BENEFICIARY_DESIGNATION enrollment type."""

    contingent_beneficiaries: NotRequired[List[BeneficiaryTypedDict]]
    r"""Contingent Beneficiary list is optional, with a maximum of five contingent beneficiaries."""
    primary_beneficiaries: NotRequired[List[BeneficiaryTypedDict]]
    r"""At least one primary beneficiary must be provided, with a maximum of five primary beneficiaries."""


class BeneficiaryEnrollmentMetadata(BaseModel):
    r"""Metadata for the BENEFICIARY_DESIGNATION enrollment type."""

    contingent_beneficiaries: Optional[List[Beneficiary]] = None
    r"""Contingent Beneficiary list is optional, with a maximum of five contingent beneficiaries."""

    primary_beneficiaries: Optional[List[Beneficiary]] = None
    r"""At least one primary beneficiary must be provided, with a maximum of five primary beneficiaries."""


class ConsentMethod(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The consent method for the enrollment. Defaults to ESIGNATURE."""

    CONSENT_METHOD_UNSPECIFIED = "CONSENT_METHOD_UNSPECIFIED"
    ESIGNATURE = "ESIGNATURE"
    WET_SIGNATURE = "WET_SIGNATURE"
    NEGATIVE_CONSENT_CONVERSION = "NEGATIVE_CONSENT_CONVERSION"


class EnrollmentCorporationEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class InitialDepositAmountTypedDict(TypedDict):
    r"""The initial deposit amount in USD"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class InitialDepositAmount(BaseModel):
    r"""The initial deposit amount in USD"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class DepositedFundsTypedDict(TypedDict):
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""

    initial_deposit_amount: NotRequired[Nullable[InitialDepositAmountTypedDict]]
    r"""The initial deposit amount in USD"""
    initial_deposit_source: NotRequired[str]
    r"""The source of the initial deposit"""


class DepositedFunds(BaseModel):
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""

    initial_deposit_amount: OptionalNullable[InitialDepositAmount] = UNSET
    r"""The initial deposit amount in USD"""

    initial_deposit_source: Optional[str] = None
    r"""The source of the initial deposit"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["initial_deposit_amount", "initial_deposit_source"]
        nullable_fields = ["initial_deposit_amount"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentCorporationEnrollmentMetadataDeterminedAccountRiskRating(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The client determined account risk rating of the entity customer"""

    DETERMINED_ACCOUNT_RISK_RATING_UNSPECIFIED = (
        "DETERMINED_ACCOUNT_RISK_RATING_UNSPECIFIED"
    )
    LOW = "LOW"
    MEDIUM = "MEDIUM"
    HIGH = "HIGH"


class OtherAccountsTypedDict(TypedDict):
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    account_names: NotRequired[List[str]]
    r"""Other account names held at Apex"""
    account_numbers: NotRequired[List[str]]
    r"""Other account numbers held at Apex"""
    owner_has_other_accounts_at_apex: NotRequired[bool]
    r"""The owner has other accounts at Apex"""


class OtherAccounts(BaseModel):
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    account_names: Optional[List[str]] = None
    r"""Other account names held at Apex"""

    account_numbers: Optional[List[str]] = None
    r"""Other account numbers held at Apex"""

    owner_has_other_accounts_at_apex: Optional[bool] = None
    r"""The owner has other accounts at Apex"""


class FinancialProfileTypedDict(TypedDict):
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    banking_relationships: NotRequired[List[str]]
    r"""Bank names with whom the entity maintains a relationship with (e.g., accounts held with the bank)"""
    other_accounts: NotRequired[Nullable[OtherAccountsTypedDict]]
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""
    primary_source_of_deposited_funds: NotRequired[str]
    r"""The primary source of funds that will be deposited to this account"""


class FinancialProfile(BaseModel):
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    banking_relationships: Optional[List[str]] = None
    r"""Bank names with whom the entity maintains a relationship with (e.g., accounts held with the bank)"""

    other_accounts: OptionalNullable[OtherAccounts] = UNSET
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    primary_source_of_deposited_funds: Optional[str] = None
    r"""The primary source of funds that will be deposited to this account"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "banking_relationships",
            "other_accounts",
            "primary_source_of_deposited_funds",
        ]
        nullable_fields = ["other_accounts"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ForeignBondTradingDetailsTypedDict(TypedDict):
    r"""The foreign bond trading countries details"""

    foreign_bond_trading: NotRequired[bool]
    r"""Does the account anticipate trading in foreign bonds"""
    foreign_bond_trading_detail: NotRequired[List[ForeignBondTradingDetailTypedDict]]
    r"""The foreign bond trading countries details. If yes, than please provide details"""


class ForeignBondTradingDetails(BaseModel):
    r"""The foreign bond trading countries details"""

    foreign_bond_trading: Optional[bool] = None
    r"""Does the account anticipate trading in foreign bonds"""

    foreign_bond_trading_detail: Optional[List[ForeignBondTradingDetail]] = None
    r"""The foreign bond trading countries details. If yes, than please provide details"""


class LowPricedSecuritiesPercentageTypedDict(TypedDict):
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class LowPricedSecuritiesPercentage(BaseModel):
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class LowPricedSecuritiesTypedDict(TypedDict):
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities: NotRequired[bool]
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""
    low_priced_securities_percentage: NotRequired[
        Nullable[LowPricedSecuritiesPercentageTypedDict]
    ]
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""


class LowPricedSecurities(BaseModel):
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities: Optional[bool] = None
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities_percentage: OptionalNullable[
        LowPricedSecuritiesPercentage
    ] = UNSET
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["low_priced_securities", "low_priced_securities_percentage"]
        nullable_fields = ["low_priced_securities_percentage"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentCorporationEnrollmentMetadataPrimaryAccountActivityType(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The primary account activity type"""

    PRIMARY_ACCOUNT_ACTIVITY_TYPE_UNSPECIFIED = (
        "PRIMARY_ACCOUNT_ACTIVITY_TYPE_UNSPECIFIED"
    )
    ACTIVE_TRADING = "ACTIVE_TRADING"
    SHORT_TERM_INVESTING = "SHORT_TERM_INVESTING"
    LONG_TERM_INVESTING = "LONG_TERM_INVESTING"


class EnrollmentCorporationEnrollmentMetadataWithdrawalFrequency(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""

    WITHDRAWAL_FREQUENCY_UNSPECIFIED = "WITHDRAWAL_FREQUENCY_UNSPECIFIED"
    FREQUENT = "FREQUENT"
    OCCASIONAL = "OCCASIONAL"
    RARE = "RARE"


class PlannedActivityTypedDict(TypedDict):
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    foreign_bond_trading_details: NotRequired[
        Nullable[ForeignBondTradingDetailsTypedDict]
    ]
    r"""The foreign bond trading countries details"""
    low_priced_securities: NotRequired[Nullable[LowPricedSecuritiesTypedDict]]
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""
    primary_account_activity_type: NotRequired[
        EnrollmentCorporationEnrollmentMetadataPrimaryAccountActivityType
    ]
    r"""The primary account activity type"""
    withdrawal_frequency: NotRequired[
        EnrollmentCorporationEnrollmentMetadataWithdrawalFrequency
    ]
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""


class PlannedActivity(BaseModel):
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    foreign_bond_trading_details: OptionalNullable[ForeignBondTradingDetails] = UNSET
    r"""The foreign bond trading countries details"""

    low_priced_securities: OptionalNullable[LowPricedSecurities] = UNSET
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    primary_account_activity_type: Annotated[
        Optional[EnrollmentCorporationEnrollmentMetadataPrimaryAccountActivityType],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The primary account activity type"""

    withdrawal_frequency: Annotated[
        Optional[EnrollmentCorporationEnrollmentMetadataWithdrawalFrequency],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "foreign_bond_trading_details",
            "low_priced_securities",
            "primary_account_activity_type",
            "withdrawal_frequency",
        ]
        nullable_fields = ["foreign_bond_trading_details", "low_priced_securities"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class RelatedPepDetailsTypedDict(TypedDict):
    r"""Information about the related politically exposed persons"""

    direct_or_indirect_related_peps: NotRequired[bool]
    r"""Indication as to whether or not an account has direct or indirect related politically exposed persons"""
    related_peps: NotRequired[List[RelatedPepTypedDict]]
    r"""Related Peps"""


class RelatedPepDetails(BaseModel):
    r"""Information about the related politically exposed persons"""

    direct_or_indirect_related_peps: Optional[bool] = None
    r"""Indication as to whether or not an account has direct or indirect related politically exposed persons"""

    related_peps: Optional[List[RelatedPep]] = None
    r"""Related Peps"""


class EddAccountEnrollmentMetadataTypedDict(TypedDict):
    r"""Enrollment metadata for entity accounts"""

    deposited_funds: NotRequired[Nullable[DepositedFundsTypedDict]]
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""
    determined_account_risk_rating: NotRequired[
        EnrollmentCorporationEnrollmentMetadataDeterminedAccountRiskRating
    ]
    r"""The client determined account risk rating of the entity customer"""
    financial_profile: NotRequired[Nullable[FinancialProfileTypedDict]]
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""
    planned_activity: NotRequired[Nullable[PlannedActivityTypedDict]]
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""
    related_pep_details: NotRequired[Nullable[RelatedPepDetailsTypedDict]]
    r"""Information about the related politically exposed persons"""
    scope_of_business: NotRequired[str]
    r"""The scope of the business for the entity customer"""


class EddAccountEnrollmentMetadata(BaseModel):
    r"""Enrollment metadata for entity accounts"""

    deposited_funds: OptionalNullable[DepositedFunds] = UNSET
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""

    determined_account_risk_rating: Annotated[
        Optional[EnrollmentCorporationEnrollmentMetadataDeterminedAccountRiskRating],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The client determined account risk rating of the entity customer"""

    financial_profile: OptionalNullable[FinancialProfile] = UNSET
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    planned_activity: OptionalNullable[PlannedActivity] = UNSET
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    related_pep_details: OptionalNullable[RelatedPepDetails] = UNSET
    r"""Information about the related politically exposed persons"""

    scope_of_business: Optional[str] = None
    r"""The scope of the business for the entity customer"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "deposited_funds",
            "determined_account_risk_rating",
            "financial_profile",
            "planned_activity",
            "related_pep_details",
            "scope_of_business",
        ]
        nullable_fields = [
            "deposited_funds",
            "financial_profile",
            "planned_activity",
            "related_pep_details",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentCorporationEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class CorporationEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_CORPORATION type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentCorporationEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    edd_account_enrollment_metadata: NotRequired[
        Nullable[EddAccountEnrollmentMetadataTypedDict]
    ]
    r"""Enrollment metadata for entity accounts"""
    fdic_cash_sweep: NotRequired[EnrollmentCorporationEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class CorporationEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_CORPORATION type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentCorporationEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    edd_account_enrollment_metadata: OptionalNullable[
        EddAccountEnrollmentMetadata
    ] = UNSET
    r"""Enrollment metadata for entity accounts"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentCorporationEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "dividend_reinvestment_plan",
            "edd_account_enrollment_metadata",
            "fdic_cash_sweep",
        ]
        nullable_fields = ["edd_account_enrollment_metadata"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentCustodialType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The type of custodial account"""

    CUSTODIAL_TYPE_UNSPECIFIED = "CUSTODIAL_TYPE_UNSPECIFIED"
    UGMA = "UGMA"
    UTMA = "UTMA"


class EnrollmentDividendReinvestmentPlan(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentFdicCashSweep(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class CustodialEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_CUSTODIAL type"""

    custodial_type: NotRequired[EnrollmentCustodialType]
    r"""The type of custodial account"""
    dividend_reinvestment_plan: NotRequired[EnrollmentDividendReinvestmentPlan]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[EnrollmentFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class CustodialEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_CUSTODIAL type"""

    custodial_type: Annotated[
        Optional[EnrollmentCustodialType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The type of custodial account"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentFdicCashSweep], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentEstateEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EstateEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_ESTATE enrollment type"""

    certificate_of_appointment_document_id: NotRequired[str]
    r"""The document id for the certificate of appointment"""
    dividend_reinvestment_plan: NotRequired[
        EnrollmentEstateEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""


class EstateEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_ESTATE enrollment type"""

    certificate_of_appointment_document_id: Optional[str] = None
    r"""The document id for the certificate of appointment"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentEstateEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""


class EnrollmentForeignIndividualAccountEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentForeignIndividualAccountEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class EnrollmentInitialDepositAmountTypedDict(TypedDict):
    r"""The initial deposit amount in USD"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentInitialDepositAmount(BaseModel):
    r"""The initial deposit amount in USD"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentDepositedFundsTypedDict(TypedDict):
    r"""The initial amount of money placed into the account by the entity upon or after the account's establishment."""

    initial_deposit_amount: NotRequired[
        Nullable[EnrollmentInitialDepositAmountTypedDict]
    ]
    r"""The initial deposit amount in USD"""
    initial_deposit_source: NotRequired[str]
    r"""The source of the initial deposit"""


class EnrollmentDepositedFunds(BaseModel):
    r"""The initial amount of money placed into the account by the entity upon or after the account's establishment."""

    initial_deposit_amount: OptionalNullable[EnrollmentInitialDepositAmount] = UNSET
    r"""The initial deposit amount in USD"""

    initial_deposit_source: Optional[str] = None
    r"""The source of the initial deposit"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["initial_deposit_amount", "initial_deposit_source"]
        nullable_fields = ["initial_deposit_amount"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentOtherAccountsTypedDict(TypedDict):
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    account_names: NotRequired[List[str]]
    r"""Other account names held at Apex"""
    account_numbers: NotRequired[List[str]]
    r"""Other account numbers held at Apex"""
    owner_has_other_accounts_at_apex: NotRequired[bool]
    r"""The owner has other accounts at Apex"""


class EnrollmentOtherAccounts(BaseModel):
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    account_names: Optional[List[str]] = None
    r"""Other account names held at Apex"""

    account_numbers: Optional[List[str]] = None
    r"""Other account numbers held at Apex"""

    owner_has_other_accounts_at_apex: Optional[bool] = None
    r"""The owner has other accounts at Apex"""


class EnrollmentFinancialProfileTypedDict(TypedDict):
    r"""Disclosure of the entity account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    banking_relationships: NotRequired[List[str]]
    r"""Bank names with whom the entity maintains a relationship with (e.g., accounts held with the bank)"""
    other_accounts: NotRequired[Nullable[EnrollmentOtherAccountsTypedDict]]
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""
    primary_source_of_deposited_funds: NotRequired[str]
    r"""The primary source of funds that will be deposited to this account"""


class EnrollmentFinancialProfile(BaseModel):
    r"""Disclosure of the entity account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    banking_relationships: Optional[List[str]] = None
    r"""Bank names with whom the entity maintains a relationship with (e.g., accounts held with the bank)"""

    other_accounts: OptionalNullable[EnrollmentOtherAccounts] = UNSET
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    primary_source_of_deposited_funds: Optional[str] = None
    r"""The primary source of funds that will be deposited to this account"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "banking_relationships",
            "other_accounts",
            "primary_source_of_deposited_funds",
        ]
        nullable_fields = ["other_accounts"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentForeignBondTradingDetailsTypedDict(TypedDict):
    r"""The foreign bond trading countries details"""

    foreign_bond_trading: NotRequired[bool]
    r"""Does the account anticipate trading in foreign bonds"""
    foreign_bond_trading_detail: NotRequired[List[ForeignBondTradingDetailTypedDict]]
    r"""The foreign bond trading countries details. If yes, than please provide details"""


class EnrollmentForeignBondTradingDetails(BaseModel):
    r"""The foreign bond trading countries details"""

    foreign_bond_trading: Optional[bool] = None
    r"""Does the account anticipate trading in foreign bonds"""

    foreign_bond_trading_detail: Optional[List[ForeignBondTradingDetail]] = None
    r"""The foreign bond trading countries details. If yes, than please provide details"""


class EnrollmentLowPricedSecuritiesPercentageTypedDict(TypedDict):
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentLowPricedSecuritiesPercentage(BaseModel):
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentLowPricedSecuritiesTypedDict(TypedDict):
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities: NotRequired[bool]
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""
    low_priced_securities_percentage: NotRequired[
        Nullable[EnrollmentLowPricedSecuritiesPercentageTypedDict]
    ]
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""


class EnrollmentLowPricedSecurities(BaseModel):
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities: Optional[bool] = None
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities_percentage: OptionalNullable[
        EnrollmentLowPricedSecuritiesPercentage
    ] = UNSET
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["low_priced_securities", "low_priced_securities_percentage"]
        nullable_fields = ["low_priced_securities_percentage"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentPrimaryAccountActivityType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The primary account activity type"""

    PRIMARY_ACCOUNT_ACTIVITY_TYPE_UNSPECIFIED = (
        "PRIMARY_ACCOUNT_ACTIVITY_TYPE_UNSPECIFIED"
    )
    ACTIVE_TRADING = "ACTIVE_TRADING"
    SHORT_TERM_INVESTING = "SHORT_TERM_INVESTING"
    LONG_TERM_INVESTING = "LONG_TERM_INVESTING"


class EnrollmentWithdrawalFrequency(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""

    WITHDRAWAL_FREQUENCY_UNSPECIFIED = "WITHDRAWAL_FREQUENCY_UNSPECIFIED"
    FREQUENT = "FREQUENT"
    OCCASIONAL = "OCCASIONAL"
    RARE = "RARE"


class EnrollmentPlannedActivityTypedDict(TypedDict):
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    foreign_bond_trading_details: NotRequired[
        Nullable[EnrollmentForeignBondTradingDetailsTypedDict]
    ]
    r"""The foreign bond trading countries details"""
    low_priced_securities: NotRequired[Nullable[EnrollmentLowPricedSecuritiesTypedDict]]
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""
    primary_account_activity_type: NotRequired[EnrollmentPrimaryAccountActivityType]
    r"""The primary account activity type"""
    withdrawal_frequency: NotRequired[EnrollmentWithdrawalFrequency]
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""


class EnrollmentPlannedActivity(BaseModel):
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    foreign_bond_trading_details: OptionalNullable[
        EnrollmentForeignBondTradingDetails
    ] = UNSET
    r"""The foreign bond trading countries details"""

    low_priced_securities: OptionalNullable[EnrollmentLowPricedSecurities] = UNSET
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    primary_account_activity_type: Annotated[
        Optional[EnrollmentPrimaryAccountActivityType],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The primary account activity type"""

    withdrawal_frequency: Annotated[
        Optional[EnrollmentWithdrawalFrequency],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "foreign_bond_trading_details",
            "low_priced_securities",
            "primary_account_activity_type",
            "withdrawal_frequency",
        ]
        nullable_fields = ["foreign_bond_trading_details", "low_priced_securities"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentRelatedPepDetailsTypedDict(TypedDict):
    r"""Information about the related politically exposed persons"""

    direct_or_indirect_related_peps: NotRequired[bool]
    r"""Indication as to whether or not an account has direct or indirect related politically exposed persons"""
    related_peps: NotRequired[List[RelatedPepTypedDict]]
    r"""Related Peps"""


class EnrollmentRelatedPepDetails(BaseModel):
    r"""Information about the related politically exposed persons"""

    direct_or_indirect_related_peps: Optional[bool] = None
    r"""Indication as to whether or not an account has direct or indirect related politically exposed persons"""

    related_peps: Optional[List[RelatedPep]] = None
    r"""Related Peps"""


class ForeignNaturalPersonAccountEnrollmentMetadataTypedDict(TypedDict):
    r"""Enrollment metadata for Accounts that have a foreign Legal Natural Person owner."""

    deposited_funds: NotRequired[Nullable[EnrollmentDepositedFundsTypedDict]]
    r"""The initial amount of money placed into the account by the entity upon or after the account's establishment."""
    financial_profile: NotRequired[Nullable[EnrollmentFinancialProfileTypedDict]]
    r"""Disclosure of the entity account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""
    planned_activity: NotRequired[Nullable[EnrollmentPlannedActivityTypedDict]]
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""
    related_pep_details: NotRequired[Nullable[EnrollmentRelatedPepDetailsTypedDict]]
    r"""Information about the related politically exposed persons"""


class ForeignNaturalPersonAccountEnrollmentMetadata(BaseModel):
    r"""Enrollment metadata for Accounts that have a foreign Legal Natural Person owner."""

    deposited_funds: OptionalNullable[EnrollmentDepositedFunds] = UNSET
    r"""The initial amount of money placed into the account by the entity upon or after the account's establishment."""

    financial_profile: OptionalNullable[EnrollmentFinancialProfile] = UNSET
    r"""Disclosure of the entity account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    planned_activity: OptionalNullable[EnrollmentPlannedActivity] = UNSET
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    related_pep_details: OptionalNullable[EnrollmentRelatedPepDetails] = UNSET
    r"""Information about the related politically exposed persons"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "deposited_funds",
            "financial_profile",
            "planned_activity",
            "related_pep_details",
        ]
        nullable_fields = [
            "deposited_funds",
            "financial_profile",
            "planned_activity",
            "related_pep_details",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ForeignIndividualAccountEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_INDIVIDUAL_FOREIGN type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentForeignIndividualAccountEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[
        EnrollmentForeignIndividualAccountEnrollmentMetadataFdicCashSweep
    ]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""
    foreign_natural_person_account_enrollment_metadata: NotRequired[
        Nullable[ForeignNaturalPersonAccountEnrollmentMetadataTypedDict]
    ]
    r"""Enrollment metadata for Accounts that have a foreign Legal Natural Person owner."""


class ForeignIndividualAccountEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_INDIVIDUAL_FOREIGN type"""

    dividend_reinvestment_plan: Annotated[
        Optional[
            EnrollmentForeignIndividualAccountEnrollmentMetadataDividendReinvestmentPlan
        ],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentForeignIndividualAccountEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    foreign_natural_person_account_enrollment_metadata: OptionalNullable[
        ForeignNaturalPersonAccountEnrollmentMetadata
    ] = UNSET
    r"""Enrollment metadata for Accounts that have a foreign Legal Natural Person owner."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "dividend_reinvestment_plan",
            "fdic_cash_sweep",
            "foreign_natural_person_account_enrollment_metadata",
        ]
        nullable_fields = ["foreign_natural_person_account_enrollment_metadata"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class FpslEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the FULLY_PAID_STOCK_LENDING enrollment type"""

    customer_percentage: NotRequired[float]
    r"""Customer Percentage for FPSL Enrollment."""
    firm_percentage: NotRequired[float]
    r"""Firm Percentage for FPSL Enrollment."""
    fpsl_msla_minimum_rate: NotRequired[float]
    r"""FPSL MSLA minimum rate determines which MSLA split agreement to display"""
    introducing_broker_percentage: NotRequired[float]
    r"""Introducing Broker Percentage for FPSL Enrollment."""


class FpslEnrollmentMetadata(BaseModel):
    r"""Metadata for the FULLY_PAID_STOCK_LENDING enrollment type"""

    customer_percentage: Optional[float] = None
    r"""Customer Percentage for FPSL Enrollment."""

    firm_percentage: Optional[float] = None
    r"""Firm Percentage for FPSL Enrollment."""

    fpsl_msla_minimum_rate: Optional[float] = None
    r"""FPSL MSLA minimum rate determines which MSLA split agreement to display"""

    introducing_broker_percentage: Optional[float] = None
    r"""Introducing Broker Percentage for FPSL Enrollment."""


class EnrollmentIndividualEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentIndividualEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class IndividualEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the INDIVIDUAL enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentIndividualEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[EnrollmentIndividualEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class IndividualEnrollmentMetadata(BaseModel):
    r"""Metadata for the INDIVIDUAL enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentIndividualEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentIndividualEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentIraBeneficiaryEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in dividend reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentIraBeneficiaryEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class InheritedFromOwnerBirthDateTypedDict(TypedDict):
    r"""The birth date of the owner from whom the account is inherited"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class InheritedFromOwnerBirthDate(BaseModel):
    r"""The birth date of the owner from whom the account is inherited"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class InheritedFromOwnerDeathDateTypedDict(TypedDict):
    r"""The death date of the owner from whom the account is inherited"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class InheritedFromOwnerDeathDate(BaseModel):
    r"""The death date of the owner from whom the account is inherited"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class IraBeneficiaryEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_IRA_BENEFICIARY_ROTH and REGISTRATION_IRA_BENEFICIARY_TRADITIONAL enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentIraBeneficiaryEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in dividend reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[
        EnrollmentIraBeneficiaryEnrollmentMetadataFdicCashSweep
    ]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""
    inherited_from_owner_birth_date: NotRequired[
        Nullable[InheritedFromOwnerBirthDateTypedDict]
    ]
    r"""The birth date of the owner from whom the account is inherited"""
    inherited_from_owner_death_date: NotRequired[
        Nullable[InheritedFromOwnerDeathDateTypedDict]
    ]
    r"""The death date of the owner from whom the account is inherited"""
    inherited_from_owner_name: NotRequired[str]
    r"""The name of the owner from whom the account is inherited"""
    inheritor_is_decedents_spouse: NotRequired[bool]
    r"""Indicates if the customer is the spouse of the decedent"""


class IraBeneficiaryEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_IRA_BENEFICIARY_ROTH and REGISTRATION_IRA_BENEFICIARY_TRADITIONAL enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentIraBeneficiaryEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in dividend reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentIraBeneficiaryEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    inherited_from_owner_birth_date: OptionalNullable[
        InheritedFromOwnerBirthDate
    ] = UNSET
    r"""The birth date of the owner from whom the account is inherited"""

    inherited_from_owner_death_date: OptionalNullable[
        InheritedFromOwnerDeathDate
    ] = UNSET
    r"""The death date of the owner from whom the account is inherited"""

    inherited_from_owner_name: Optional[str] = None
    r"""The name of the owner from whom the account is inherited"""

    inheritor_is_decedents_spouse: Optional[bool] = None
    r"""Indicates if the customer is the spouse of the decedent"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "dividend_reinvestment_plan",
            "fdic_cash_sweep",
            "inherited_from_owner_birth_date",
            "inherited_from_owner_death_date",
            "inherited_from_owner_name",
            "inheritor_is_decedents_spouse",
        ]
        nullable_fields = [
            "inherited_from_owner_birth_date",
            "inherited_from_owner_death_date",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentIraRolloverEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentIraRolloverEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class IraRolloverEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the ROLLOVER_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentIraRolloverEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[EnrollmentIraRolloverEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class IraRolloverEnrollmentMetadata(BaseModel):
    r"""Metadata for the ROLLOVER_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentIraRolloverEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentIraRolloverEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentIraRothEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentIraRothEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class IraRothEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the ROTH_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentIraRothEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[EnrollmentIraRothEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class IraRothEnrollmentMetadata(BaseModel):
    r"""Metadata for the ROTH_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentIraRothEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentIraRothEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentIraSepEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentIraSepEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class IraSepEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the SEP_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentIraSepEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[EnrollmentIraSepEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class IraSepEnrollmentMetadata(BaseModel):
    r"""Metadata for the SEP_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentIraSepEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentIraSepEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentIraSimpleEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentIraSimpleEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class IraSimpleEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the SIMPLE_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentIraSimpleEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[EnrollmentIraSimpleEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class IraSimpleEnrollmentMetadata(BaseModel):
    r"""Metadata for the SIMPLE_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentIraSimpleEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentIraSimpleEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentIraTraditionalEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentIraTraditionalEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class IraTraditionalEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the TRADITIONAL_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentIraTraditionalEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[
        EnrollmentIraTraditionalEnrollmentMetadataFdicCashSweep
    ]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class IraTraditionalEnrollmentMetadata(BaseModel):
    r"""Metadata for the TRADITIONAL_IRA_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentIraTraditionalEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentIraTraditionalEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentJointCommunityPropertyEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentJointCommunityPropertyEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class EnrollmentJointCommunityPropertyEnrollmentMetadataLegalResidencyStateOfMarriedCouple(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The legal residency state of a married couple"""

    LEGAL_RESIDENCY_STATE_OF_MARRIED_COUPLE_UNSPECIFIED = (
        "LEGAL_RESIDENCY_STATE_OF_MARRIED_COUPLE_UNSPECIFIED"
    )
    AK = "AK"
    AZ = "AZ"
    AR = "AR"
    CA = "CA"
    DE = "DE"
    FL = "FL"
    HI = "HI"
    ID = "ID"
    IL = "IL"
    IN = "IN"
    KY = "KY"
    LA = "LA"
    MD = "MD"
    MA = "MA"
    MI = "MI"
    MS = "MS"
    MO = "MO"
    NV = "NV"
    NJ = "NJ"
    NM = "NM"
    NY = "NY"
    NC = "NC"
    OH = "OH"
    OK = "OK"
    OR = "OR"
    PA = "PA"
    RI = "RI"
    TN = "TN"
    TX = "TX"
    VT = "VT"
    VA = "VA"
    WA = "WA"
    WI = "WI"
    WY = "WY"


class JointCommunityPropertyEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the JOINT_COMMUNITY_PROPERTY_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentJointCommunityPropertyEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[
        EnrollmentJointCommunityPropertyEnrollmentMetadataFdicCashSweep
    ]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""
    legal_residency_state_of_married_couple: NotRequired[
        EnrollmentJointCommunityPropertyEnrollmentMetadataLegalResidencyStateOfMarriedCouple
    ]
    r"""The legal residency state of a married couple"""


class JointCommunityPropertyEnrollmentMetadata(BaseModel):
    r"""Metadata for the JOINT_COMMUNITY_PROPERTY_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[
            EnrollmentJointCommunityPropertyEnrollmentMetadataDividendReinvestmentPlan
        ],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentJointCommunityPropertyEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    legal_residency_state_of_married_couple: Annotated[
        Optional[
            EnrollmentJointCommunityPropertyEnrollmentMetadataLegalResidencyStateOfMarriedCouple
        ],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The legal residency state of a married couple"""


class EnrollmentJointTenantsByEntiretyEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentJointTenantsByEntiretyEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class EnrollmentLegalResidencyStateOfMarriedCouple(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The legal residency state of a married couple"""

    LEGAL_RESIDENCY_STATE_OF_MARRIED_COUPLE_UNSPECIFIED = (
        "LEGAL_RESIDENCY_STATE_OF_MARRIED_COUPLE_UNSPECIFIED"
    )
    AK = "AK"
    AZ = "AZ"
    AR = "AR"
    CA = "CA"
    DE = "DE"
    FL = "FL"
    HI = "HI"
    ID = "ID"
    IL = "IL"
    IN = "IN"
    KY = "KY"
    LA = "LA"
    MD = "MD"
    MA = "MA"
    MI = "MI"
    MS = "MS"
    MO = "MO"
    NV = "NV"
    NJ = "NJ"
    NM = "NM"
    NY = "NY"
    NC = "NC"
    OH = "OH"
    OK = "OK"
    OR = "OR"
    PA = "PA"
    RI = "RI"
    TN = "TN"
    TX = "TX"
    VT = "VT"
    VA = "VA"
    WA = "WA"
    WI = "WI"
    WY = "WY"


class JointTenantsByEntiretyEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the JOINT_TENANTS_BY_ENTIRETY_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentJointTenantsByEntiretyEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[
        EnrollmentJointTenantsByEntiretyEnrollmentMetadataFdicCashSweep
    ]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""
    legal_residency_state_of_married_couple: NotRequired[
        EnrollmentLegalResidencyStateOfMarriedCouple
    ]
    r"""The legal residency state of a married couple"""


class JointTenantsByEntiretyEnrollmentMetadata(BaseModel):
    r"""Metadata for the JOINT_TENANTS_BY_ENTIRETY_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[
            EnrollmentJointTenantsByEntiretyEnrollmentMetadataDividendReinvestmentPlan
        ],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentJointTenantsByEntiretyEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    legal_residency_state_of_married_couple: Annotated[
        Optional[EnrollmentLegalResidencyStateOfMarriedCouple],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The legal residency state of a married couple"""


class EnrollmentJointTenantsInCommonEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentJointTenantsInCommonEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class JointTenantsInCommonEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the JOINT_TENANTS_IN_COMMON_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentJointTenantsInCommonEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[
        EnrollmentJointTenantsInCommonEnrollmentMetadataFdicCashSweep
    ]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class JointTenantsInCommonEnrollmentMetadata(BaseModel):
    r"""Metadata for the JOINT_TENANTS_IN_COMMON_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[
            EnrollmentJointTenantsInCommonEnrollmentMetadataDividendReinvestmentPlan
        ],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentJointTenantsInCommonEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentJointWithRightsOfSurvivorshipEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentJointWithRightsOfSurvivorshipEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class JointWithRightsOfSurvivorshipEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the JOINT_WITH_RIGHTS_OF_SURVIVORSHIP_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentJointWithRightsOfSurvivorshipEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[
        EnrollmentJointWithRightsOfSurvivorshipEnrollmentMetadataFdicCashSweep
    ]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class JointWithRightsOfSurvivorshipEnrollmentMetadata(BaseModel):
    r"""Metadata for the JOINT_WITH_RIGHTS_OF_SURVIVORSHIP_REGISTRATION enrollment type"""

    dividend_reinvestment_plan: Annotated[
        Optional[
            EnrollmentJointWithRightsOfSurvivorshipEnrollmentMetadataDividendReinvestmentPlan
        ],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[
            EnrollmentJointWithRightsOfSurvivorshipEnrollmentMetadataFdicCashSweep
        ],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""


class EnrollmentLlcEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to `DIVIDEND_REINVESTMENT_ENROLL`"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentLlcEnrollmentMetadataInitialDepositAmountTypedDict(TypedDict):
    r"""The initial deposit amount in USD"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentLlcEnrollmentMetadataInitialDepositAmount(BaseModel):
    r"""The initial deposit amount in USD"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentLlcEnrollmentMetadataDepositedFundsTypedDict(TypedDict):
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""

    initial_deposit_amount: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataInitialDepositAmountTypedDict]
    ]
    r"""The initial deposit amount in USD"""
    initial_deposit_source: NotRequired[str]
    r"""The source of the initial deposit"""


class EnrollmentLlcEnrollmentMetadataDepositedFunds(BaseModel):
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""

    initial_deposit_amount: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataInitialDepositAmount
    ] = UNSET
    r"""The initial deposit amount in USD"""

    initial_deposit_source: Optional[str] = None
    r"""The source of the initial deposit"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["initial_deposit_amount", "initial_deposit_source"]
        nullable_fields = ["initial_deposit_amount"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentDeterminedAccountRiskRating(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The client determined account risk rating of the entity customer"""

    DETERMINED_ACCOUNT_RISK_RATING_UNSPECIFIED = (
        "DETERMINED_ACCOUNT_RISK_RATING_UNSPECIFIED"
    )
    LOW = "LOW"
    MEDIUM = "MEDIUM"
    HIGH = "HIGH"


class EnrollmentLlcEnrollmentMetadataOtherAccountsTypedDict(TypedDict):
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    account_names: NotRequired[List[str]]
    r"""Other account names held at Apex"""
    account_numbers: NotRequired[List[str]]
    r"""Other account numbers held at Apex"""
    owner_has_other_accounts_at_apex: NotRequired[bool]
    r"""The owner has other accounts at Apex"""


class EnrollmentLlcEnrollmentMetadataOtherAccounts(BaseModel):
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    account_names: Optional[List[str]] = None
    r"""Other account names held at Apex"""

    account_numbers: Optional[List[str]] = None
    r"""Other account numbers held at Apex"""

    owner_has_other_accounts_at_apex: Optional[bool] = None
    r"""The owner has other accounts at Apex"""


class EnrollmentLlcEnrollmentMetadataFinancialProfileTypedDict(TypedDict):
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    banking_relationships: NotRequired[List[str]]
    r"""Bank names with whom the entity maintains a relationship with (e.g., accounts held with the bank)"""
    other_accounts: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataOtherAccountsTypedDict]
    ]
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""
    primary_source_of_deposited_funds: NotRequired[str]
    r"""The primary source of funds that will be deposited to this account"""


class EnrollmentLlcEnrollmentMetadataFinancialProfile(BaseModel):
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    banking_relationships: Optional[List[str]] = None
    r"""Bank names with whom the entity maintains a relationship with (e.g., accounts held with the bank)"""

    other_accounts: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataOtherAccounts
    ] = UNSET
    r"""A customer-disclosed list of other Apex-held accounts owned by the Entity applicant at the time of this account's application; expressed as zero, one, or many account numbers"""

    primary_source_of_deposited_funds: Optional[str] = None
    r"""The primary source of funds that will be deposited to this account"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "banking_relationships",
            "other_accounts",
            "primary_source_of_deposited_funds",
        ]
        nullable_fields = ["other_accounts"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentLlcEnrollmentMetadataForeignBondTradingDetailsTypedDict(TypedDict):
    r"""The foreign bond trading countries details"""

    foreign_bond_trading: NotRequired[bool]
    r"""Does the account anticipate trading in foreign bonds"""
    foreign_bond_trading_detail: NotRequired[List[ForeignBondTradingDetailTypedDict]]
    r"""The foreign bond trading countries details. If yes, than please provide details"""


class EnrollmentLlcEnrollmentMetadataForeignBondTradingDetails(BaseModel):
    r"""The foreign bond trading countries details"""

    foreign_bond_trading: Optional[bool] = None
    r"""Does the account anticipate trading in foreign bonds"""

    foreign_bond_trading_detail: Optional[List[ForeignBondTradingDetail]] = None
    r"""The foreign bond trading countries details. If yes, than please provide details"""


class EnrollmentLlcEnrollmentMetadataLowPricedSecuritiesPercentageTypedDict(TypedDict):
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentLlcEnrollmentMetadataLowPricedSecuritiesPercentage(BaseModel):
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class EnrollmentLlcEnrollmentMetadataLowPricedSecuritiesTypedDict(TypedDict):
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities: NotRequired[bool]
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""
    low_priced_securities_percentage: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataLowPricedSecuritiesPercentageTypedDict]
    ]
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""


class EnrollmentLlcEnrollmentMetadataLowPricedSecurities(BaseModel):
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities: Optional[bool] = None
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    low_priced_securities_percentage: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataLowPricedSecuritiesPercentage
    ] = UNSET
    r"""The percentage, by volume, of the account's trades which will involve low priced securities"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["low_priced_securities", "low_priced_securities_percentage"]
        nullable_fields = ["low_priced_securities_percentage"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentLlcEnrollmentMetadataPrimaryAccountActivityType(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The primary account activity type"""

    PRIMARY_ACCOUNT_ACTIVITY_TYPE_UNSPECIFIED = (
        "PRIMARY_ACCOUNT_ACTIVITY_TYPE_UNSPECIFIED"
    )
    ACTIVE_TRADING = "ACTIVE_TRADING"
    SHORT_TERM_INVESTING = "SHORT_TERM_INVESTING"
    LONG_TERM_INVESTING = "LONG_TERM_INVESTING"


class EnrollmentLlcEnrollmentMetadataWithdrawalFrequency(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""

    WITHDRAWAL_FREQUENCY_UNSPECIFIED = "WITHDRAWAL_FREQUENCY_UNSPECIFIED"
    FREQUENT = "FREQUENT"
    OCCASIONAL = "OCCASIONAL"
    RARE = "RARE"


class EnrollmentLlcEnrollmentMetadataPlannedActivityTypedDict(TypedDict):
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    foreign_bond_trading_details: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataForeignBondTradingDetailsTypedDict]
    ]
    r"""The foreign bond trading countries details"""
    low_priced_securities: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataLowPricedSecuritiesTypedDict]
    ]
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""
    primary_account_activity_type: NotRequired[
        EnrollmentLlcEnrollmentMetadataPrimaryAccountActivityType
    ]
    r"""The primary account activity type"""
    withdrawal_frequency: NotRequired[
        EnrollmentLlcEnrollmentMetadataWithdrawalFrequency
    ]
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""


class EnrollmentLlcEnrollmentMetadataPlannedActivity(BaseModel):
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    foreign_bond_trading_details: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataForeignBondTradingDetails
    ] = UNSET
    r"""The foreign bond trading countries details"""

    low_priced_securities: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataLowPricedSecurities
    ] = UNSET
    r"""The account anticipates trading in securities trading for less than $5 per share and are typically traded over-the-counter (OTC) or through pink sheets"""

    primary_account_activity_type: Annotated[
        Optional[EnrollmentLlcEnrollmentMetadataPrimaryAccountActivityType],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The primary account activity type"""

    withdrawal_frequency: Annotated[
        Optional[EnrollmentLlcEnrollmentMetadataWithdrawalFrequency],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The frequency by which cash is anticipated to be withdrawn from the account"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "foreign_bond_trading_details",
            "low_priced_securities",
            "primary_account_activity_type",
            "withdrawal_frequency",
        ]
        nullable_fields = ["foreign_bond_trading_details", "low_priced_securities"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentLlcEnrollmentMetadataRelatedPepDetailsTypedDict(TypedDict):
    r"""Information about the related politically exposed persons"""

    direct_or_indirect_related_peps: NotRequired[bool]
    r"""Indication as to whether or not an account has direct or indirect related politically exposed persons"""
    related_peps: NotRequired[List[RelatedPepTypedDict]]
    r"""Related Peps"""


class EnrollmentLlcEnrollmentMetadataRelatedPepDetails(BaseModel):
    r"""Information about the related politically exposed persons"""

    direct_or_indirect_related_peps: Optional[bool] = None
    r"""Indication as to whether or not an account has direct or indirect related politically exposed persons"""

    related_peps: Optional[List[RelatedPep]] = None
    r"""Related Peps"""


class EnrollmentEddAccountEnrollmentMetadataTypedDict(TypedDict):
    r"""Enrollment metadata for entity accounts"""

    deposited_funds: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataDepositedFundsTypedDict]
    ]
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""
    determined_account_risk_rating: NotRequired[EnrollmentDeterminedAccountRiskRating]
    r"""The client determined account risk rating of the entity customer"""
    financial_profile: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataFinancialProfileTypedDict]
    ]
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""
    planned_activity: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataPlannedActivityTypedDict]
    ]
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""
    related_pep_details: NotRequired[
        Nullable[EnrollmentLlcEnrollmentMetadataRelatedPepDetailsTypedDict]
    ]
    r"""Information about the related politically exposed persons"""
    scope_of_business: NotRequired[str]
    r"""The scope of the business for the entity customer"""


class EnrollmentEddAccountEnrollmentMetadata(BaseModel):
    r"""Enrollment metadata for entity accounts"""

    deposited_funds: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataDepositedFunds
    ] = UNSET
    r"""The initial amount of money placed into the account by the customer upon or after the account's establishment."""

    determined_account_risk_rating: Annotated[
        Optional[EnrollmentDeterminedAccountRiskRating],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The client determined account risk rating of the entity customer"""

    financial_profile: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataFinancialProfile
    ] = UNSET
    r"""Disclosure of the account owner's financial relationships and source of brokerage funds; facilitates the creation of the overall customer risk profile"""

    planned_activity: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataPlannedActivity
    ] = UNSET
    r"""Details the customer's intended trading and banking-related activities at the time of account application; informs risk checks and forms a baseline for anomalous activity detection"""

    related_pep_details: OptionalNullable[
        EnrollmentLlcEnrollmentMetadataRelatedPepDetails
    ] = UNSET
    r"""Information about the related politically exposed persons"""

    scope_of_business: Optional[str] = None
    r"""The scope of the business for the entity customer"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "deposited_funds",
            "determined_account_risk_rating",
            "financial_profile",
            "planned_activity",
            "related_pep_details",
            "scope_of_business",
        ]
        nullable_fields = [
            "deposited_funds",
            "financial_profile",
            "planned_activity",
            "related_pep_details",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentLlcEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to `FDIC_CASH_SWEEP_ENROLL`"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class LlcEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_LLC type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentLlcEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to `DIVIDEND_REINVESTMENT_ENROLL`"""
    edd_account_enrollment_metadata: NotRequired[
        Nullable[EnrollmentEddAccountEnrollmentMetadataTypedDict]
    ]
    r"""Enrollment metadata for entity accounts"""
    fdic_cash_sweep: NotRequired[EnrollmentLlcEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to `FDIC_CASH_SWEEP_ENROLL`"""


class LlcEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_LLC type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentLlcEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to `DIVIDEND_REINVESTMENT_ENROLL`"""

    edd_account_enrollment_metadata: OptionalNullable[
        EnrollmentEddAccountEnrollmentMetadata
    ] = UNSET
    r"""Enrollment metadata for entity accounts"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentLlcEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to `FDIC_CASH_SWEEP_ENROLL`"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "dividend_reinvestment_plan",
            "edd_account_enrollment_metadata",
            "fdic_cash_sweep",
        ]
        nullable_fields = ["edd_account_enrollment_metadata"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentOperatingPurpose(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The purpose of the operating account."""

    OPERATING_PURPOSE_UNSPECIFIED = "OPERATING_PURPOSE_UNSPECIFIED"
    CUSTODY = "CUSTODY"
    SEC_FEE = "SEC_FEE"
    TAF_FEE = "TAF_FEE"
    TEFRA_WITHHOLDING = "TEFRA_WITHHOLDING"
    SUSPENSE = "SUSPENSE"
    ALLOCATION = "ALLOCATION"
    ERROR = "ERROR"
    DEPOSIT = "DEPOSIT"
    WRITE_OFF = "WRITE_OFF"
    UNSECURED_RESERVE = "UNSECURED_RESERVE"
    PAYABLE = "PAYABLE"
    COMMISSION = "COMMISSION"
    ESCHEATMENT = "ESCHEATMENT"
    INTEREST_REVENUE = "INTEREST_REVENUE"
    STREET_DEPOSITORY = "STREET_DEPOSITORY"
    INVENTORY = "INVENTORY"
    TAX_WITHHOLDING = "TAX_WITHHOLDING"
    FEE = "FEE"
    PRINCIPAL_TRADING = "PRINCIPAL_TRADING"


class EnrollmentTaxAuthority(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Tax Authority for Enrollment"""

    TAX_AUTHORITY_UNSPECIFIED = "TAX_AUTHORITY_UNSPECIFIED"
    AL = "AL"
    AK = "AK"
    AZ = "AZ"
    AR = "AR"
    CA = "CA"
    CO = "CO"
    CT = "CT"
    DE = "DE"
    FL = "FL"
    GA = "GA"
    HI = "HI"
    ID = "ID"
    IL = "IL"
    IN = "IN"
    IA = "IA"
    KS = "KS"
    KY = "KY"
    LA = "LA"
    ME = "ME"
    MD = "MD"
    MA = "MA"
    MI = "MI"
    MN = "MN"
    MS = "MS"
    MO = "MO"
    MT = "MT"
    NE = "NE"
    NV = "NV"
    NH = "NH"
    NJ = "NJ"
    NM = "NM"
    NY = "NY"
    NC = "NC"
    ND = "ND"
    OH = "OH"
    OK = "OK"
    OR = "OR"
    PA = "PA"
    RI = "RI"
    SC = "SC"
    SD = "SD"
    TN = "TN"
    TX = "TX"
    UT = "UT"
    VT = "VT"
    VA = "VA"
    WA = "WA"
    WV = "WV"
    WI = "WI"
    WY = "WY"
    IRS = "IRS"


class EnrollmentWithholdingType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""A designation used by the custodian to determine how much federal income tax should be withheld from the proceeds of a sale"""

    WITHHOLDING_TYPE_UNSPECIFIED = "WITHHOLDING_TYPE_UNSPECIFIED"
    BACKUP = "BACKUP"
    BACKUP_PROCEEDS = "BACKUP_PROCEEDS"
    BACKUP_DIVIDENDS_AND_INTEREST = "BACKUP_DIVIDENDS_AND_INTEREST"
    IRA = "IRA"


class TaxWithholdingMetadataTypedDict(TypedDict):
    r"""Optional tax withholding metadata for TAX_WITHHOLDING operating purpose"""

    tax_authority: NotRequired[EnrollmentTaxAuthority]
    r"""Tax Authority for Enrollment"""
    withholding_type: NotRequired[EnrollmentWithholdingType]
    r"""A designation used by the custodian to determine how much federal income tax should be withheld from the proceeds of a sale"""


class TaxWithholdingMetadata(BaseModel):
    r"""Optional tax withholding metadata for TAX_WITHHOLDING operating purpose"""

    tax_authority: Annotated[
        Optional[EnrollmentTaxAuthority], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Tax Authority for Enrollment"""

    withholding_type: Annotated[
        Optional[EnrollmentWithholdingType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""A designation used by the custodian to determine how much federal income tax should be withheld from the proceeds of a sale"""


class OperatingEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_OPERATING enrollment type."""

    operating_purpose: NotRequired[EnrollmentOperatingPurpose]
    r"""The purpose of the operating account."""
    subtitle: NotRequired[str]
    r"""Optional subtitle for the operating purpose"""
    tax_withholding_metadata: NotRequired[Nullable[TaxWithholdingMetadataTypedDict]]
    r"""Optional tax withholding metadata for TAX_WITHHOLDING operating purpose"""


class OperatingEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_OPERATING enrollment type."""

    operating_purpose: Annotated[
        Optional[EnrollmentOperatingPurpose], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The purpose of the operating account."""

    subtitle: Optional[str] = None
    r"""Optional subtitle for the operating purpose"""

    tax_withholding_metadata: OptionalNullable[TaxWithholdingMetadata] = UNSET
    r"""Optional tax withholding metadata for TAX_WITHHOLDING operating purpose"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["operating_purpose", "subtitle", "tax_withholding_metadata"]
        nullable_fields = ["tax_withholding_metadata"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class EnrollmentState(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates where in the enrollment is in the process; May be `PENDING_AGREEMENT`, `ACTIVE`, `INACTIVE`, `PROCESSING`, or `EXPIRED`"""

    ENROLLMENT_STATE_UNSPECIFIED = "ENROLLMENT_STATE_UNSPECIFIED"
    ACTIVE = "ACTIVE"
    INACTIVE = "INACTIVE"
    PENDING_AGREEMENT = "PENDING_AGREEMENT"
    PROCESSING = "PROCESSING"
    EXPIRED = "EXPIRED"


class EnrollmentTrustEnrollmentMetadataDividendReinvestmentPlan(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED = (
        "AUTO_ENROLL_DIVIDEND_REINVESTMENT_UNSPECIFIED"
    )
    DIVIDEND_REINVESTMENT_ENROLL = "DIVIDEND_REINVESTMENT_ENROLL"
    DIVIDEND_REINVESTMENT_DECLINE = "DIVIDEND_REINVESTMENT_DECLINE"


class EnrollmentTrustEnrollmentMetadataFdicCashSweep(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED = "AUTO_ENROLL_FDIC_CASH_SWEEP_UNSPECIFIED"
    FDIC_CASH_SWEEP_ENROLL = "FDIC_CASH_SWEEP_ENROLL"
    FDIC_CASH_SWEEP_DECLINE = "FDIC_CASH_SWEEP_DECLINE"


class EnrollmentOpenedOnBehalfOf(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Trust account is opened on behalf of"""

    OPENED_ON_BEHALF_OF_UNSPECIFIED = "OPENED_ON_BEHALF_OF_UNSPECIFIED"
    PERSONAL_TRUST = "PERSONAL_TRUST"
    BUSINESS_TRUST = "BUSINESS_TRUST"
    THIRD_PARTY_ADMINISTRATOR = "THIRD_PARTY_ADMINISTRATOR"


class TrustEnrollmentMetadataTypedDict(TypedDict):
    r"""Metadata for the REGISTRATION_TRUST type"""

    dividend_reinvestment_plan: NotRequired[
        EnrollmentTrustEnrollmentMetadataDividendReinvestmentPlan
    ]
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""
    fdic_cash_sweep: NotRequired[EnrollmentTrustEnrollmentMetadataFdicCashSweep]
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""
    opened_on_behalf_of: NotRequired[EnrollmentOpenedOnBehalfOf]
    r"""Trust account is opened on behalf of"""


class TrustEnrollmentMetadata(BaseModel):
    r"""Metadata for the REGISTRATION_TRUST type"""

    dividend_reinvestment_plan: Annotated[
        Optional[EnrollmentTrustEnrollmentMetadataDividendReinvestmentPlan],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in Dividend Reinvestment; defaults to true"""

    fdic_cash_sweep: Annotated[
        Optional[EnrollmentTrustEnrollmentMetadataFdicCashSweep],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Option to auto-enroll in FDIC cash sweep; defaults to true"""

    opened_on_behalf_of: Annotated[
        Optional[EnrollmentOpenedOnBehalfOf], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Trust account is opened on behalf of"""


class EnrollmentType1(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Describes the name of the enrollment; Expressed as an enum"""

    ENROLLMENT_TYPE_UNSPECIFIED = "ENROLLMENT_TYPE_UNSPECIFIED"
    REGISTRATION_INDIVIDUAL = "REGISTRATION_INDIVIDUAL"
    LENDING_LIMITED_PURPOSE_MARGIN = "LENDING_LIMITED_PURPOSE_MARGIN"
    LENDING_FULLY_PAID_STOCK_LOAN = "LENDING_FULLY_PAID_STOCK_LOAN"
    BENEFICIARY_DESIGNATION = "BENEFICIARY_DESIGNATION"
    REGISTRATION_JOINT_WROS = "REGISTRATION_JOINT_WROS"
    REGISTRATION_JOINT_TIC = "REGISTRATION_JOINT_TIC"
    REGISTRATION_JOINT_TBE = "REGISTRATION_JOINT_TBE"
    REGISTRATION_JOINT_CP = "REGISTRATION_JOINT_CP"
    REGISTRATION_ESTATE = "REGISTRATION_ESTATE"
    REGISTRATION_IRA_TRADITIONAL = "REGISTRATION_IRA_TRADITIONAL"
    REGISTRATION_IRA_SIMPLE = "REGISTRATION_IRA_SIMPLE"
    REGISTRATION_IRA_SEP = "REGISTRATION_IRA_SEP"
    REGISTRATION_IRA_ROTH = "REGISTRATION_IRA_ROTH"
    REGISTRATION_IRA_ROLLOVER = "REGISTRATION_IRA_ROLLOVER"
    REGISTRATION_TRUST = "REGISTRATION_TRUST"
    REGISTRATION_CORPORATION = "REGISTRATION_CORPORATION"
    CASH_FDIC_CASH_SWEEP = "CASH_FDIC_CASH_SWEEP"
    MARGINS_PDT_RESET = "MARGINS_PDT_RESET"
    RETIREMENT_BENEFICIARY_DESIGNATION = "RETIREMENT_BENEFICIARY_DESIGNATION"
    DIVIDEND_REINVESTMENT_PLAN = "DIVIDEND_REINVESTMENT_PLAN"
    REGISTRATION_IRA_BENEFICIARY_TRADITIONAL = (
        "REGISTRATION_IRA_BENEFICIARY_TRADITIONAL"
    )
    REGISTRATION_IRA_BENEFICIARY_ROTH = "REGISTRATION_IRA_BENEFICIARY_ROTH"
    REGISTRATION_CUSTODIAL = "REGISTRATION_CUSTODIAL"
    REG_T_MARGIN = "REG_T_MARGIN"


class EnrollmentTypedDict(TypedDict):
    r"""An Enrollment represents programs the account may enroll in."""

    beneficiary_enrollment_metadata: NotRequired[
        Nullable[BeneficiaryEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the BENEFICIARY_DESIGNATION enrollment type."""
    consent_method: NotRequired[ConsentMethod]
    r"""The consent method for the enrollment. Defaults to ESIGNATURE."""
    corporation_enrollment_metadata: NotRequired[
        Nullable[CorporationEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the REGISTRATION_CORPORATION type"""
    custodial_enrollment_metadata: NotRequired[
        Nullable[CustodialEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the REGISTRATION_CUSTODIAL type"""
    enrollment_id: NotRequired[str]
    r"""A system-generated unique identifier referencing a single instance of an enrollment; Used to access the record after creation"""
    enrollment_time: NotRequired[Nullable[datetime]]
    r"""The time all enrollment requirements were satisfied and the enrollment transitioned to `ACTIVE`"""
    estate_enrollment_metadata: NotRequired[Nullable[EstateEnrollmentMetadataTypedDict]]
    r"""Metadata for the REGISTRATION_ESTATE enrollment type"""
    foreign_individual_account_enrollment_metadata: NotRequired[
        Nullable[ForeignIndividualAccountEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the REGISTRATION_INDIVIDUAL_FOREIGN type"""
    fpsl_enrollment_metadata: NotRequired[Nullable[FpslEnrollmentMetadataTypedDict]]
    r"""Metadata for the FULLY_PAID_STOCK_LENDING enrollment type"""
    individual_enrollment_metadata: NotRequired[
        Nullable[IndividualEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the INDIVIDUAL enrollment type"""
    ira_beneficiary_enrollment_metadata: NotRequired[
        Nullable[IraBeneficiaryEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the REGISTRATION_IRA_BENEFICIARY_ROTH and REGISTRATION_IRA_BENEFICIARY_TRADITIONAL enrollment type"""
    ira_rollover_enrollment_metadata: NotRequired[
        Nullable[IraRolloverEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the ROLLOVER_IRA_REGISTRATION enrollment type"""
    ira_roth_enrollment_metadata: NotRequired[
        Nullable[IraRothEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the ROTH_IRA_REGISTRATION enrollment type"""
    ira_sep_enrollment_metadata: NotRequired[
        Nullable[IraSepEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the SEP_IRA_REGISTRATION enrollment type"""
    ira_simple_enrollment_metadata: NotRequired[
        Nullable[IraSimpleEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the SIMPLE_IRA_REGISTRATION enrollment type"""
    ira_traditional_enrollment_metadata: NotRequired[
        Nullable[IraTraditionalEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the TRADITIONAL_IRA_REGISTRATION enrollment type"""
    joint_community_property_enrollment_metadata: NotRequired[
        Nullable[JointCommunityPropertyEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the JOINT_COMMUNITY_PROPERTY_REGISTRATION enrollment type"""
    joint_tenants_by_entirety_enrollment_metadata: NotRequired[
        Nullable[JointTenantsByEntiretyEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the JOINT_TENANTS_BY_ENTIRETY_REGISTRATION enrollment type"""
    joint_tenants_in_common_enrollment_metadata: NotRequired[
        Nullable[JointTenantsInCommonEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the JOINT_TENANTS_IN_COMMON_REGISTRATION enrollment type"""
    joint_with_rights_of_survivorship_enrollment_metadata: NotRequired[
        Nullable[JointWithRightsOfSurvivorshipEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the JOINT_WITH_RIGHTS_OF_SURVIVORSHIP_REGISTRATION enrollment type"""
    llc_enrollment_metadata: NotRequired[Nullable[LlcEnrollmentMetadataTypedDict]]
    r"""Metadata for the REGISTRATION_LLC type"""
    name: NotRequired[str]
    r"""The name field Format: accounts/{account}/enrollments/{enrollment}"""
    operating_enrollment_metadata: NotRequired[
        Nullable[OperatingEnrollmentMetadataTypedDict]
    ]
    r"""Metadata for the REGISTRATION_OPERATING enrollment type."""
    principal_approver_id: NotRequired[str]
    r"""The ULID is associated with the approver of a given enrollment. The approver you create will contain the CRD Number issued to the person by FINRA. As an RIA, you should use the ULID associated with Apex's approver."""
    state: NotRequired[EnrollmentState]
    r"""Indicates where in the enrollment is in the process; May be `PENDING_AGREEMENT`, `ACTIVE`, `INACTIVE`, `PROCESSING`, or `EXPIRED`"""
    trust_enrollment_metadata: NotRequired[Nullable[TrustEnrollmentMetadataTypedDict]]
    r"""Metadata for the REGISTRATION_TRUST type"""
    type: NotRequired[EnrollmentType1]
    r"""Describes the name of the enrollment; Expressed as an enum"""
    unenrollment_time: NotRequired[Nullable[datetime]]
    r"""The time an unenrollment request was processed and the enrollment transitioned to `INACTIVE`"""


class Enrollment(BaseModel):
    r"""An Enrollment represents programs the account may enroll in."""

    beneficiary_enrollment_metadata: OptionalNullable[
        BeneficiaryEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the BENEFICIARY_DESIGNATION enrollment type."""

    consent_method: Annotated[
        Optional[ConsentMethod], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The consent method for the enrollment. Defaults to ESIGNATURE."""

    corporation_enrollment_metadata: OptionalNullable[
        CorporationEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the REGISTRATION_CORPORATION type"""

    custodial_enrollment_metadata: OptionalNullable[CustodialEnrollmentMetadata] = UNSET
    r"""Metadata for the REGISTRATION_CUSTODIAL type"""

    enrollment_id: Optional[str] = None
    r"""A system-generated unique identifier referencing a single instance of an enrollment; Used to access the record after creation"""

    enrollment_time: OptionalNullable[datetime] = UNSET
    r"""The time all enrollment requirements were satisfied and the enrollment transitioned to `ACTIVE`"""

    estate_enrollment_metadata: OptionalNullable[EstateEnrollmentMetadata] = UNSET
    r"""Metadata for the REGISTRATION_ESTATE enrollment type"""

    foreign_individual_account_enrollment_metadata: OptionalNullable[
        ForeignIndividualAccountEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the REGISTRATION_INDIVIDUAL_FOREIGN type"""

    fpsl_enrollment_metadata: OptionalNullable[FpslEnrollmentMetadata] = UNSET
    r"""Metadata for the FULLY_PAID_STOCK_LENDING enrollment type"""

    individual_enrollment_metadata: OptionalNullable[
        IndividualEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the INDIVIDUAL enrollment type"""

    ira_beneficiary_enrollment_metadata: OptionalNullable[
        IraBeneficiaryEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the REGISTRATION_IRA_BENEFICIARY_ROTH and REGISTRATION_IRA_BENEFICIARY_TRADITIONAL enrollment type"""

    ira_rollover_enrollment_metadata: OptionalNullable[
        IraRolloverEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the ROLLOVER_IRA_REGISTRATION enrollment type"""

    ira_roth_enrollment_metadata: OptionalNullable[IraRothEnrollmentMetadata] = UNSET
    r"""Metadata for the ROTH_IRA_REGISTRATION enrollment type"""

    ira_sep_enrollment_metadata: OptionalNullable[IraSepEnrollmentMetadata] = UNSET
    r"""Metadata for the SEP_IRA_REGISTRATION enrollment type"""

    ira_simple_enrollment_metadata: OptionalNullable[
        IraSimpleEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the SIMPLE_IRA_REGISTRATION enrollment type"""

    ira_traditional_enrollment_metadata: OptionalNullable[
        IraTraditionalEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the TRADITIONAL_IRA_REGISTRATION enrollment type"""

    joint_community_property_enrollment_metadata: OptionalNullable[
        JointCommunityPropertyEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the JOINT_COMMUNITY_PROPERTY_REGISTRATION enrollment type"""

    joint_tenants_by_entirety_enrollment_metadata: OptionalNullable[
        JointTenantsByEntiretyEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the JOINT_TENANTS_BY_ENTIRETY_REGISTRATION enrollment type"""

    joint_tenants_in_common_enrollment_metadata: OptionalNullable[
        JointTenantsInCommonEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the JOINT_TENANTS_IN_COMMON_REGISTRATION enrollment type"""

    joint_with_rights_of_survivorship_enrollment_metadata: OptionalNullable[
        JointWithRightsOfSurvivorshipEnrollmentMetadata
    ] = UNSET
    r"""Metadata for the JOINT_WITH_RIGHTS_OF_SURVIVORSHIP_REGISTRATION enrollment type"""

    llc_enrollment_metadata: OptionalNullable[LlcEnrollmentMetadata] = UNSET
    r"""Metadata for the REGISTRATION_LLC type"""

    name: Optional[str] = None
    r"""The name field Format: accounts/{account}/enrollments/{enrollment}"""

    operating_enrollment_metadata: OptionalNullable[OperatingEnrollmentMetadata] = UNSET
    r"""Metadata for the REGISTRATION_OPERATING enrollment type."""

    principal_approver_id: Optional[str] = None
    r"""The ULID is associated with the approver of a given enrollment. The approver you create will contain the CRD Number issued to the person by FINRA. As an RIA, you should use the ULID associated with Apex's approver."""

    state: Annotated[
        Optional[EnrollmentState], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates where in the enrollment is in the process; May be `PENDING_AGREEMENT`, `ACTIVE`, `INACTIVE`, `PROCESSING`, or `EXPIRED`"""

    trust_enrollment_metadata: OptionalNullable[TrustEnrollmentMetadata] = UNSET
    r"""Metadata for the REGISTRATION_TRUST type"""

    type: Annotated[
        Optional[EnrollmentType1], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Describes the name of the enrollment; Expressed as an enum"""

    unenrollment_time: OptionalNullable[datetime] = UNSET
    r"""The time an unenrollment request was processed and the enrollment transitioned to `INACTIVE`"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "beneficiary_enrollment_metadata",
            "consent_method",
            "corporation_enrollment_metadata",
            "custodial_enrollment_metadata",
            "enrollment_id",
            "enrollment_time",
            "estate_enrollment_metadata",
            "foreign_individual_account_enrollment_metadata",
            "fpsl_enrollment_metadata",
            "individual_enrollment_metadata",
            "ira_beneficiary_enrollment_metadata",
            "ira_rollover_enrollment_metadata",
            "ira_roth_enrollment_metadata",
            "ira_sep_enrollment_metadata",
            "ira_simple_enrollment_metadata",
            "ira_traditional_enrollment_metadata",
            "joint_community_property_enrollment_metadata",
            "joint_tenants_by_entirety_enrollment_metadata",
            "joint_tenants_in_common_enrollment_metadata",
            "joint_with_rights_of_survivorship_enrollment_metadata",
            "llc_enrollment_metadata",
            "name",
            "operating_enrollment_metadata",
            "principal_approver_id",
            "state",
            "trust_enrollment_metadata",
            "type",
            "unenrollment_time",
        ]
        nullable_fields = [
            "beneficiary_enrollment_metadata",
            "corporation_enrollment_metadata",
            "custodial_enrollment_metadata",
            "enrollment_time",
            "estate_enrollment_metadata",
            "foreign_individual_account_enrollment_metadata",
            "fpsl_enrollment_metadata",
            "individual_enrollment_metadata",
            "ira_beneficiary_enrollment_metadata",
            "ira_rollover_enrollment_metadata",
            "ira_roth_enrollment_metadata",
            "ira_sep_enrollment_metadata",
            "ira_simple_enrollment_metadata",
            "ira_traditional_enrollment_metadata",
            "joint_community_property_enrollment_metadata",
            "joint_tenants_by_entirety_enrollment_metadata",
            "joint_tenants_in_common_enrollment_metadata",
            "joint_with_rights_of_survivorship_enrollment_metadata",
            "llc_enrollment_metadata",
            "operating_enrollment_metadata",
            "trust_enrollment_metadata",
            "unenrollment_time",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
