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

from __future__ import annotations
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 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 BirthDateTypedDict(TypedDict):
    r"""The legal day, month, and year of birth for a natural person."""

    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 BirthDate(BaseModel):
    r"""The legal day, month, and year of birth for a natural person."""

    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 DeathDateTypedDict(TypedDict):
    r"""The day, month, and year of death of a legal natural person"""

    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 DeathDate(BaseModel):
    r"""The day, month, and year of death of a legal natural person"""

    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 EmployerAddressTypedDict(TypedDict):
    r"""The data structure containing attributes describing the location of an investor's employer. If input, the required fields within the `employer_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """

    address_lines: NotRequired[List[str]]
    r"""Unstructured address lines describing the lower levels of an address.

    Because values in address_lines do not have type information and may sometimes contain multiple values in a single field (e.g. \"Austin, TX\"), it is important that the line order is clear. The order of address lines should be \"envelope order\" for the country/region of the address. In places where this can vary (e.g. Japan), address_language is used to make it explicit (e.g. \"ja\" for large-to-small ordering and \"ja-Latn\" or \"en\" for small-to-large). This way, the most specific line of an address can be selected based on the language.

    The minimum permitted structural representation of an address consists of a region_code with all remaining information placed in the address_lines. It would be possible to format such an address very approximately without geocoding, but no semantic reasoning could be made about any of the address components until it was at least partially resolved.

    Creating an address only containing a region_code and address_lines, and then geocoding is the recommended way to handle completely unstructured addresses (as opposed to guessing which parts of the address should be localities or administrative areas).
    """
    administrative_area: NotRequired[str]
    r"""Optional. Highest administrative subdivision which is used for postal addresses of a country or region. For example, this can be a state, a province, an oblast, or a prefecture. Specifically, for Spain this is the province and not the autonomous community (e.g. \"Barcelona\" and not \"Catalonia\"). Many countries don't use an administrative area in postal addresses. E.g. in Switzerland this should be left unpopulated."""
    language_code: NotRequired[str]
    r"""Optional. BCP-47 language code of the contents of this address (if known). This is often the UI language of the input form or is expected to match one of the languages used in the address' country/region, or their transliterated equivalents. This can affect formatting in certain countries, but is not critical to the correctness of the data and will never affect any validation or other non-formatting related operations.

    If this value is not known, it should be omitted (rather than specifying a possibly incorrect default).

    Examples: \"zh-Hant\", \"ja\", \"ja-Latn\", \"en\".
    """
    locality: NotRequired[str]
    r"""Optional. Generally refers to the city/town portion of the address. Examples: US city, IT comune, UK post town. In regions of the world where localities are not well defined or do not fit into this structure well, leave locality empty and use address_lines."""
    organization: NotRequired[str]
    r"""Optional. The name of the organization at the address."""
    postal_code: NotRequired[str]
    r"""Optional. Postal code of the address. Not all countries use or require postal codes to be present, but where they are used, they may trigger additional validation with other parts of the address (e.g. state/zip validation in the U.S.A.)."""
    recipients: NotRequired[List[str]]
    r"""Optional. The recipient at the address. This field may, under certain circumstances, contain multiline information. For example, it might contain \"care of\" information."""
    region_code: NotRequired[str]
    r"""Required. CLDR region code of the country/region of the address. This is never inferred and it is up to the user to ensure the value is correct. See http://cldr.unicode.org/ and http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html for details. Example: \"CH\" for Switzerland."""
    revision: NotRequired[int]
    r"""The schema revision of the `PostalAddress`. This must be set to 0, which is the latest revision.

    All new revisions **must** be backward compatible with old revisions.
    """
    sorting_code: NotRequired[str]
    r"""Optional. Additional, country-specific, sorting code. This is not used in most regions. Where it is used, the value is either a string like \"CEDEX\", optionally followed by a number (e.g. \"CEDEX 7\"), or just a number alone, representing the \"sector code\" (Jamaica), \"delivery area indicator\" (Malawi) or \"post office indicator\" (e.g. Côte d'Ivoire)."""
    sublocality: NotRequired[str]
    r"""Optional. Sublocality of the address. For example, this can be neighborhoods, boroughs, districts."""


class EmployerAddress(BaseModel):
    r"""The data structure containing attributes describing the location of an investor's employer. If input, the required fields within the `employer_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """

    address_lines: Optional[List[str]] = None
    r"""Unstructured address lines describing the lower levels of an address.

    Because values in address_lines do not have type information and may sometimes contain multiple values in a single field (e.g. \"Austin, TX\"), it is important that the line order is clear. The order of address lines should be \"envelope order\" for the country/region of the address. In places where this can vary (e.g. Japan), address_language is used to make it explicit (e.g. \"ja\" for large-to-small ordering and \"ja-Latn\" or \"en\" for small-to-large). This way, the most specific line of an address can be selected based on the language.

    The minimum permitted structural representation of an address consists of a region_code with all remaining information placed in the address_lines. It would be possible to format such an address very approximately without geocoding, but no semantic reasoning could be made about any of the address components until it was at least partially resolved.

    Creating an address only containing a region_code and address_lines, and then geocoding is the recommended way to handle completely unstructured addresses (as opposed to guessing which parts of the address should be localities or administrative areas).
    """

    administrative_area: Optional[str] = None
    r"""Optional. Highest administrative subdivision which is used for postal addresses of a country or region. For example, this can be a state, a province, an oblast, or a prefecture. Specifically, for Spain this is the province and not the autonomous community (e.g. \"Barcelona\" and not \"Catalonia\"). Many countries don't use an administrative area in postal addresses. E.g. in Switzerland this should be left unpopulated."""

    language_code: Optional[str] = None
    r"""Optional. BCP-47 language code of the contents of this address (if known). This is often the UI language of the input form or is expected to match one of the languages used in the address' country/region, or their transliterated equivalents. This can affect formatting in certain countries, but is not critical to the correctness of the data and will never affect any validation or other non-formatting related operations.

    If this value is not known, it should be omitted (rather than specifying a possibly incorrect default).

    Examples: \"zh-Hant\", \"ja\", \"ja-Latn\", \"en\".
    """

    locality: Optional[str] = None
    r"""Optional. Generally refers to the city/town portion of the address. Examples: US city, IT comune, UK post town. In regions of the world where localities are not well defined or do not fit into this structure well, leave locality empty and use address_lines."""

    organization: Optional[str] = None
    r"""Optional. The name of the organization at the address."""

    postal_code: Optional[str] = None
    r"""Optional. Postal code of the address. Not all countries use or require postal codes to be present, but where they are used, they may trigger additional validation with other parts of the address (e.g. state/zip validation in the U.S.A.)."""

    recipients: Optional[List[str]] = None
    r"""Optional. The recipient at the address. This field may, under certain circumstances, contain multiline information. For example, it might contain \"care of\" information."""

    region_code: Optional[str] = None
    r"""Required. CLDR region code of the country/region of the address. This is never inferred and it is up to the user to ensure the value is correct. See http://cldr.unicode.org/ and http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html for details. Example: \"CH\" for Switzerland."""

    revision: Optional[int] = None
    r"""The schema revision of the `PostalAddress`. This must be set to 0, which is the latest revision.

    All new revisions **must** be backward compatible with old revisions.
    """

    sorting_code: Optional[str] = None
    r"""Optional. Additional, country-specific, sorting code. This is not used in most regions. Where it is used, the value is either a string like \"CEDEX\", optionally followed by a number (e.g. \"CEDEX 7\"), or just a number alone, representing the \"sector code\" (Jamaica), \"delivery area indicator\" (Malawi) or \"post office indicator\" (e.g. Côte d'Ivoire)."""

    sublocality: Optional[str] = None
    r"""Optional. Sublocality of the address. For example, this can be neighborhoods, boroughs, districts."""


class LegalNaturalPersonEmploymentStatus(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Classifies in what capacity (or if) the underlying natural person holds a job"""

    STATUS_UNSPECIFIED = "STATUS_UNSPECIFIED"
    EMPLOYED = "EMPLOYED"
    SELF_EMPLOYED = "SELF_EMPLOYED"
    UNEMPLOYED = "UNEMPLOYED"
    RETIRED = "RETIRED"
    STUDENT = "STUDENT"


class EmploymentTypedDict(TypedDict):
    r"""Object containing information pertaining to a investor's current employer including the name, address, and duration of employment."""

    employer: NotRequired[str]
    r"""The business name of an investor's employer."""
    employer_address: NotRequired[Nullable[EmployerAddressTypedDict]]
    r"""The data structure containing attributes describing the location of an investor's employer. If input, the required fields within the `employer_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """
    employment_id: NotRequired[str]
    r"""System-generated GUID representing the employment record of a natural person"""
    employment_status: NotRequired[LegalNaturalPersonEmploymentStatus]
    r"""Classifies in what capacity (or if) the underlying natural person holds a job"""
    occupation: NotRequired[str]
    r"""The nature of work performed at an investor's place of employment."""
    start_year: NotRequired[int]
    r"""The start year of employment related to a person's stated employer Must be from birth year to current year, or 0 to clear start year value"""


class Employment(BaseModel):
    r"""Object containing information pertaining to a investor's current employer including the name, address, and duration of employment."""

    employer: Optional[str] = None
    r"""The business name of an investor's employer."""

    employer_address: OptionalNullable[EmployerAddress] = UNSET
    r"""The data structure containing attributes describing the location of an investor's employer. If input, the required fields within the `employer_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """

    employment_id: Optional[str] = None
    r"""System-generated GUID representing the employment record of a natural person"""

    employment_status: Annotated[
        Optional[LegalNaturalPersonEmploymentStatus],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Classifies in what capacity (or if) the underlying natural person holds a job"""

    occupation: Optional[str] = None
    r"""The nature of work performed at an investor's place of employment."""

    start_year: Optional[int] = None
    r"""The start year of employment related to a person's stated employer Must be from birth year to current year, or 0 to clear start year value"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "employer",
            "employer_address",
            "employment_id",
            "employment_status",
            "occupation",
            "start_year",
        ]
        nullable_fields = ["employer_address"]
        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 ExpirationDateTypedDict(TypedDict):
    r"""Identification expiration date"""

    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 ExpirationDate(BaseModel):
    r"""Identification expiration date"""

    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 IssueDateTypedDict(TypedDict):
    r"""Identification issue date"""

    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 IssueDate(BaseModel):
    r"""Identification issue date"""

    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 LegalNaturalPersonType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Identification type"""

    IDENTIFICATION_TYPE_UNSPECIFIED = "IDENTIFICATION_TYPE_UNSPECIFIED"
    PASSPORT = "PASSPORT"
    NATIONAL_ID = "NATIONAL_ID"
    DRIVERS_LICENSE = "DRIVERS_LICENSE"


class ForeignIdentificationTypedDict(TypedDict):
    r"""Foreign identification. Must be provided if the person does not have a U.S. tax ID"""

    expiration_date: NotRequired[Nullable[ExpirationDateTypedDict]]
    r"""Identification expiration date"""
    ftin: NotRequired[bool]
    r"""Denotes if the identification is a tax id or other"""
    identification_number: NotRequired[str]
    r"""Identification number"""
    issue_date: NotRequired[Nullable[IssueDateTypedDict]]
    r"""Identification issue date"""
    issuing_region_code: NotRequired[str]
    r"""Region of issuance must be provided as a two-character CLDR country code"""
    type: NotRequired[LegalNaturalPersonType]
    r"""Identification type"""


class ForeignIdentification(BaseModel):
    r"""Foreign identification. Must be provided if the person does not have a U.S. tax ID"""

    expiration_date: OptionalNullable[ExpirationDate] = UNSET
    r"""Identification expiration date"""

    ftin: Optional[bool] = None
    r"""Denotes if the identification is a tax id or other"""

    identification_number: Optional[str] = None
    r"""Identification number"""

    issue_date: OptionalNullable[IssueDate] = UNSET
    r"""Identification issue date"""

    issuing_region_code: Optional[str] = None
    r"""Region of issuance must be provided as a two-character CLDR country code"""

    type: Annotated[
        Optional[LegalNaturalPersonType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Identification type"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "expiration_date",
            "ftin",
            "identification_number",
            "issue_date",
            "issuing_region_code",
            "type",
        ]
        nullable_fields = ["expiration_date", "issue_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 ExecutionDateTypedDict(TypedDict):
    r"""The datetime external identity verification results were run on a natural person"""

    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 ExecutionDate(BaseModel):
    r"""The datetime external identity verification results were run on a natural person"""

    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 LegalNaturalPersonIdentityVerificationResultTypedDict(TypedDict):
    r"""Third-party data result used to verify the identity of an introduced investor. If the client identity_verification_model is PROVIDED_BY_CLIENT, this field is required"""

    address_verified: NotRequired[bool]
    r"""Attestation that external result and review have verified the supplied investor's address has been verified in conjunction with other PII"""
    birth_date_verified: NotRequired[bool]
    r"""Attestation that external result and review have verified the supplied investor's date of birth has been verified in conjunction with other PII"""
    execution_date: NotRequired[Nullable[ExecutionDateTypedDict]]
    r"""The datetime external identity verification results were run on a natural person"""
    external_case_id: NotRequired[str]
    r"""Client-generated identifier associated with the KYC results for the appropriate case"""
    identity_verification_document_ids: NotRequired[List[str]]
    r"""System generated document IDs returned after uploading identity documents to the Documents API"""
    identity_verification_result_id: NotRequired[str]
    r"""System-generated GUID used to uniquely identify the verification_result"""
    name_verified: NotRequired[bool]
    r"""Attestation that external result and review have verified the supplied investor's name has been verified in conjunction with other PII"""
    raw_vendor_data_document_id: NotRequired[str]
    r"""A system-generated document ID assigned when raw vendor results are uploaded to the Documents API; This field is optional for person record creation, but required for account creation if the Correspondent provides IDV results"""
    tax_id_verified: NotRequired[bool]
    r"""Attestation that external result and review have verified the supplied investor's Tax ID has been verified in conjunction with other PII"""
    vendor: NotRequired[str]
    r"""The name(s) of the vendor(s) used to externally verify and screen a natural person; relates to the identity_verification_result"""


class LegalNaturalPersonIdentityVerificationResult(BaseModel):
    r"""Third-party data result used to verify the identity of an introduced investor. If the client identity_verification_model is PROVIDED_BY_CLIENT, this field is required"""

    address_verified: Optional[bool] = None
    r"""Attestation that external result and review have verified the supplied investor's address has been verified in conjunction with other PII"""

    birth_date_verified: Optional[bool] = None
    r"""Attestation that external result and review have verified the supplied investor's date of birth has been verified in conjunction with other PII"""

    execution_date: OptionalNullable[ExecutionDate] = UNSET
    r"""The datetime external identity verification results were run on a natural person"""

    external_case_id: Optional[str] = None
    r"""Client-generated identifier associated with the KYC results for the appropriate case"""

    identity_verification_document_ids: Optional[List[str]] = None
    r"""System generated document IDs returned after uploading identity documents to the Documents API"""

    identity_verification_result_id: Optional[str] = None
    r"""System-generated GUID used to uniquely identify the verification_result"""

    name_verified: Optional[bool] = None
    r"""Attestation that external result and review have verified the supplied investor's name has been verified in conjunction with other PII"""

    raw_vendor_data_document_id: Optional[str] = None
    r"""A system-generated document ID assigned when raw vendor results are uploaded to the Documents API; This field is optional for person record creation, but required for account creation if the Correspondent provides IDV results"""

    tax_id_verified: Optional[bool] = None
    r"""Attestation that external result and review have verified the supplied investor's Tax ID has been verified in conjunction with other PII"""

    vendor: Optional[str] = None
    r"""The name(s) of the vendor(s) used to externally verify and screen a natural person; relates to the identity_verification_result"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "address_verified",
            "birth_date_verified",
            "execution_date",
            "external_case_id",
            "identity_verification_document_ids",
            "identity_verification_result_id",
            "name_verified",
            "raw_vendor_data_document_id",
            "tax_id_verified",
            "vendor",
        ]
        nullable_fields = ["execution_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 LegalNaturalPersonEffectiveDateTypedDict(TypedDict):
    r"""The date on which the trader meets or exceeds the large trader reporting threshold, which is defined by the U.S. Securities and Exchange Commission (SEC) as trades of 2 million shares or $20 million in a single day or 20 million shares or $200 million during a calendar month"""

    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 LegalNaturalPersonEffectiveDate(BaseModel):
    r"""The date on which the trader meets or exceeds the large trader reporting threshold, which is defined by the U.S. Securities and Exchange Commission (SEC) as trades of 2 million shares or $20 million in a single day or 20 million shares or $200 million during a calendar month"""

    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 LegalNaturalPersonLargeTraderTypedDict(TypedDict):
    r"""Indicates if the person is recognized as a \"Large Trader\" by the SEC."""

    effective_date: NotRequired[Nullable[LegalNaturalPersonEffectiveDateTypedDict]]
    r"""The date on which the trader meets or exceeds the large trader reporting threshold, which is defined by the U.S. Securities and Exchange Commission (SEC) as trades of 2 million shares or $20 million in a single day or 20 million shares or $200 million during a calendar month"""
    large_trader_id: NotRequired[str]
    r"""SEC-issued ID signifying the person/entity as a large trader; Required for CAIS regulatory reporting."""


class LegalNaturalPersonLargeTrader(BaseModel):
    r"""Indicates if the person is recognized as a \"Large Trader\" by the SEC."""

    effective_date: OptionalNullable[LegalNaturalPersonEffectiveDate] = UNSET
    r"""The date on which the trader meets or exceeds the large trader reporting threshold, which is defined by the U.S. Securities and Exchange Commission (SEC) as trades of 2 million shares or $20 million in a single day or 20 million shares or $200 million during a calendar month"""

    large_trader_id: Optional[str] = None
    r"""SEC-issued ID signifying the person/entity as a large trader; Required for CAIS regulatory reporting."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["effective_date", "large_trader_id"]
        nullable_fields = ["effective_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 LegalNaturalPersonMaritalStatus(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The legal marital status of an account-holder; Used in combination with state of domicile to determine qualification for account types and beneficiary exclusion rules."""

    MARITAL_STATUS_UNSPECIFIED = "MARITAL_STATUS_UNSPECIFIED"
    SINGLE = "SINGLE"
    MARRIED = "MARRIED"
    DIVORCED = "DIVORCED"
    WIDOWED = "WIDOWED"


class LegalNaturalPersonNameSuffix(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The suffix of a natural person; A suffix in a name is any part of the name that comes after the last name"""

    NAME_SUFFIX_UNSPECIFIED = "NAME_SUFFIX_UNSPECIFIED"
    SR = "SR"
    JR = "JR"
    III = "III"
    IV = "IV"
    V = "V"


class CustomerReferralSourceTypedDict(TypedDict):
    r"""Customer Referral Source"""

    name: NotRequired[str]
    r"""The name of the referrer"""
    relationship_to_applicant: NotRequired[str]
    r"""The relationship of the referrer to the applicant"""
    relationship_years_with_applicant: NotRequired[int]
    r"""The years the referrer has known the applicant If the referrer has known the applicant for less than a year, they must specify 1"""
    relationship_years_with_broker: NotRequired[int]
    r"""The years the referrer has known the broker If the referrer has known the broker for less than a year, they must specify 1"""


class CustomerReferralSource(BaseModel):
    r"""Customer Referral Source"""

    name: Optional[str] = None
    r"""The name of the referrer"""

    relationship_to_applicant: Optional[str] = None
    r"""The relationship of the referrer to the applicant"""

    relationship_years_with_applicant: Optional[int] = None
    r"""The years the referrer has known the applicant If the referrer has known the applicant for less than a year, they must specify 1"""

    relationship_years_with_broker: Optional[int] = None
    r"""The years the referrer has known the broker If the referrer has known the broker for less than a year, they must specify 1"""


class NegativeNewsTypedDict(TypedDict):
    r"""Information about any negative news against the client, or any immediate family members, close associates, or related entities"""

    negative_news_against_related_parties: NotRequired[bool]
    r"""Indicates whether there is negative news against related parties"""
    negative_news_against_related_parties_description: NotRequired[str]
    r"""Description of the negative news against related parties"""


class NegativeNews(BaseModel):
    r"""Information about any negative news against the client, or any immediate family members, close associates, or related entities"""

    negative_news_against_related_parties: Optional[bool] = None
    r"""Indicates whether there is negative news against related parties"""

    negative_news_against_related_parties_description: Optional[str] = None
    r"""Description of the negative news against related parties"""


class OtherSourcesOfWealthTypedDict(TypedDict):
    r"""The applicant's other source of wealth"""

    applicant_has_other_sources_of_wealth: NotRequired[bool]
    r"""Indicates whether the applicant has other sources of wealth."""
    other_sources_of_wealth: NotRequired[str]
    r"""The applicant's other source of wealth description. If the applicant has no other sources of wealth, they must specify \"N/A.\" """
    other_sources_of_wealth_verification: NotRequired[str]
    r"""The applicant's other source of wealth verification. If the applicant has no other sources of wealth, they must specify \"N/A.\" """


class OtherSourcesOfWealth(BaseModel):
    r"""The applicant's other source of wealth"""

    applicant_has_other_sources_of_wealth: Optional[bool] = None
    r"""Indicates whether the applicant has other sources of wealth."""

    other_sources_of_wealth: Optional[str] = None
    r"""The applicant's other source of wealth description. If the applicant has no other sources of wealth, they must specify \"N/A.\" """

    other_sources_of_wealth_verification: Optional[str] = None
    r"""The applicant's other source of wealth verification. If the applicant has no other sources of wealth, they must specify \"N/A.\" """


class NaturalPersonFddTypedDict(TypedDict):
    r"""Foreign Due Diligence (FDD) information for Legal Natural Person"""

    customer_non_referral_source: NotRequired[str]
    r"""Customer Non-referral Source"""
    customer_referral_source: NotRequired[Nullable[CustomerReferralSourceTypedDict]]
    r"""Customer Referral Source"""
    employment_and_employer_description: NotRequired[str]
    r"""The description of the applicant's source of wealth"""
    negative_news: NotRequired[Nullable[NegativeNewsTypedDict]]
    r"""Information about any negative news against the client, or any immediate family members, close associates, or related entities"""
    other_sources_of_wealth: NotRequired[Nullable[OtherSourcesOfWealthTypedDict]]
    r"""The applicant's other source of wealth"""


class NaturalPersonFdd(BaseModel):
    r"""Foreign Due Diligence (FDD) information for Legal Natural Person"""

    customer_non_referral_source: Optional[str] = None
    r"""Customer Non-referral Source"""

    customer_referral_source: OptionalNullable[CustomerReferralSource] = UNSET
    r"""Customer Referral Source"""

    employment_and_employer_description: Optional[str] = None
    r"""The description of the applicant's source of wealth"""

    negative_news: OptionalNullable[NegativeNews] = UNSET
    r"""Information about any negative news against the client, or any immediate family members, close associates, or related entities"""

    other_sources_of_wealth: OptionalNullable[OtherSourcesOfWealth] = UNSET
    r"""The applicant's other source of wealth"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "customer_non_referral_source",
            "customer_referral_source",
            "employment_and_employer_description",
            "negative_news",
            "other_sources_of_wealth",
        ]
        nullable_fields = [
            "customer_referral_source",
            "negative_news",
            "other_sources_of_wealth",
        ]
        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 LegalNaturalPersonResidencyStatus(str, Enum, metaclass=utils.OpenEnumMeta):
    RESIDENCY_STATUS_UNSPECIFIED = "RESIDENCY_STATUS_UNSPECIFIED"
    US_PERMANENT_RESIDENT = "US_PERMANENT_RESIDENT"
    US_TEMPORARY_RESIDENT = "US_TEMPORARY_RESIDENT"
    US_NON_RESIDENT = "US_NON_RESIDENT"


class NonCitizenResidencyTypedDict(TypedDict):
    r"""Facilitates non-citizen lawful US residents to open domestic accounts"""

    residency_status: NotRequired[LegalNaturalPersonResidencyStatus]


class NonCitizenResidency(BaseModel):
    r"""Facilitates non-citizen lawful US residents to open domestic accounts"""

    residency_status: Annotated[
        Optional[LegalNaturalPersonResidencyStatus],
        PlainValidator(validate_open_enum(False)),
    ] = None


class PersonalAddressTypedDict(TypedDict):
    r"""The legal street number and street name for an account Party. Required fields within the `personal_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """

    address_lines: NotRequired[List[str]]
    r"""Unstructured address lines describing the lower levels of an address.

    Because values in address_lines do not have type information and may sometimes contain multiple values in a single field (e.g. \"Austin, TX\"), it is important that the line order is clear. The order of address lines should be \"envelope order\" for the country/region of the address. In places where this can vary (e.g. Japan), address_language is used to make it explicit (e.g. \"ja\" for large-to-small ordering and \"ja-Latn\" or \"en\" for small-to-large). This way, the most specific line of an address can be selected based on the language.

    The minimum permitted structural representation of an address consists of a region_code with all remaining information placed in the address_lines. It would be possible to format such an address very approximately without geocoding, but no semantic reasoning could be made about any of the address components until it was at least partially resolved.

    Creating an address only containing a region_code and address_lines, and then geocoding is the recommended way to handle completely unstructured addresses (as opposed to guessing which parts of the address should be localities or administrative areas).
    """
    administrative_area: NotRequired[str]
    r"""Optional. Highest administrative subdivision which is used for postal addresses of a country or region. For example, this can be a state, a province, an oblast, or a prefecture. Specifically, for Spain this is the province and not the autonomous community (e.g. \"Barcelona\" and not \"Catalonia\"). Many countries don't use an administrative area in postal addresses. E.g. in Switzerland this should be left unpopulated."""
    language_code: NotRequired[str]
    r"""Optional. BCP-47 language code of the contents of this address (if known). This is often the UI language of the input form or is expected to match one of the languages used in the address' country/region, or their transliterated equivalents. This can affect formatting in certain countries, but is not critical to the correctness of the data and will never affect any validation or other non-formatting related operations.

    If this value is not known, it should be omitted (rather than specifying a possibly incorrect default).

    Examples: \"zh-Hant\", \"ja\", \"ja-Latn\", \"en\".
    """
    locality: NotRequired[str]
    r"""Optional. Generally refers to the city/town portion of the address. Examples: US city, IT comune, UK post town. In regions of the world where localities are not well defined or do not fit into this structure well, leave locality empty and use address_lines."""
    organization: NotRequired[str]
    r"""Optional. The name of the organization at the address."""
    postal_code: NotRequired[str]
    r"""Optional. Postal code of the address. Not all countries use or require postal codes to be present, but where they are used, they may trigger additional validation with other parts of the address (e.g. state/zip validation in the U.S.A.)."""
    recipients: NotRequired[List[str]]
    r"""Optional. The recipient at the address. This field may, under certain circumstances, contain multiline information. For example, it might contain \"care of\" information."""
    region_code: NotRequired[str]
    r"""Required. CLDR region code of the country/region of the address. This is never inferred and it is up to the user to ensure the value is correct. See http://cldr.unicode.org/ and http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html for details. Example: \"CH\" for Switzerland."""
    revision: NotRequired[int]
    r"""The schema revision of the `PostalAddress`. This must be set to 0, which is the latest revision.

    All new revisions **must** be backward compatible with old revisions.
    """
    sorting_code: NotRequired[str]
    r"""Optional. Additional, country-specific, sorting code. This is not used in most regions. Where it is used, the value is either a string like \"CEDEX\", optionally followed by a number (e.g. \"CEDEX 7\"), or just a number alone, representing the \"sector code\" (Jamaica), \"delivery area indicator\" (Malawi) or \"post office indicator\" (e.g. Côte d'Ivoire)."""
    sublocality: NotRequired[str]
    r"""Optional. Sublocality of the address. For example, this can be neighborhoods, boroughs, districts."""


class PersonalAddress(BaseModel):
    r"""The legal street number and street name for an account Party. Required fields within the `personal_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """

    address_lines: Optional[List[str]] = None
    r"""Unstructured address lines describing the lower levels of an address.

    Because values in address_lines do not have type information and may sometimes contain multiple values in a single field (e.g. \"Austin, TX\"), it is important that the line order is clear. The order of address lines should be \"envelope order\" for the country/region of the address. In places where this can vary (e.g. Japan), address_language is used to make it explicit (e.g. \"ja\" for large-to-small ordering and \"ja-Latn\" or \"en\" for small-to-large). This way, the most specific line of an address can be selected based on the language.

    The minimum permitted structural representation of an address consists of a region_code with all remaining information placed in the address_lines. It would be possible to format such an address very approximately without geocoding, but no semantic reasoning could be made about any of the address components until it was at least partially resolved.

    Creating an address only containing a region_code and address_lines, and then geocoding is the recommended way to handle completely unstructured addresses (as opposed to guessing which parts of the address should be localities or administrative areas).
    """

    administrative_area: Optional[str] = None
    r"""Optional. Highest administrative subdivision which is used for postal addresses of a country or region. For example, this can be a state, a province, an oblast, or a prefecture. Specifically, for Spain this is the province and not the autonomous community (e.g. \"Barcelona\" and not \"Catalonia\"). Many countries don't use an administrative area in postal addresses. E.g. in Switzerland this should be left unpopulated."""

    language_code: Optional[str] = None
    r"""Optional. BCP-47 language code of the contents of this address (if known). This is often the UI language of the input form or is expected to match one of the languages used in the address' country/region, or their transliterated equivalents. This can affect formatting in certain countries, but is not critical to the correctness of the data and will never affect any validation or other non-formatting related operations.

    If this value is not known, it should be omitted (rather than specifying a possibly incorrect default).

    Examples: \"zh-Hant\", \"ja\", \"ja-Latn\", \"en\".
    """

    locality: Optional[str] = None
    r"""Optional. Generally refers to the city/town portion of the address. Examples: US city, IT comune, UK post town. In regions of the world where localities are not well defined or do not fit into this structure well, leave locality empty and use address_lines."""

    organization: Optional[str] = None
    r"""Optional. The name of the organization at the address."""

    postal_code: Optional[str] = None
    r"""Optional. Postal code of the address. Not all countries use or require postal codes to be present, but where they are used, they may trigger additional validation with other parts of the address (e.g. state/zip validation in the U.S.A.)."""

    recipients: Optional[List[str]] = None
    r"""Optional. The recipient at the address. This field may, under certain circumstances, contain multiline information. For example, it might contain \"care of\" information."""

    region_code: Optional[str] = None
    r"""Required. CLDR region code of the country/region of the address. This is never inferred and it is up to the user to ensure the value is correct. See http://cldr.unicode.org/ and http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html for details. Example: \"CH\" for Switzerland."""

    revision: Optional[int] = None
    r"""The schema revision of the `PostalAddress`. This must be set to 0, which is the latest revision.

    All new revisions **must** be backward compatible with old revisions.
    """

    sorting_code: Optional[str] = None
    r"""Optional. Additional, country-specific, sorting code. This is not used in most regions. Where it is used, the value is either a string like \"CEDEX\", optionally followed by a number (e.g. \"CEDEX 7\"), or just a number alone, representing the \"sector code\" (Jamaica), \"delivery area indicator\" (Malawi) or \"post office indicator\" (e.g. Côte d'Ivoire)."""

    sublocality: Optional[str] = None
    r"""Optional. Sublocality of the address. For example, this can be neighborhoods, boroughs, districts."""


class LegalNaturalPersonTaxIDType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The nature of the U.S. Tax ID indicated in the related tax_id field; Examples include ITIN, SSN, EIN."""

    TAX_ID_TYPE_UNSPECIFIED = "TAX_ID_TYPE_UNSPECIFIED"
    TAX_ID_TYPE_SSN = "TAX_ID_TYPE_SSN"
    TAX_ID_TYPE_ITIN = "TAX_ID_TYPE_ITIN"
    TAX_ID_TYPE_EIN = "TAX_ID_TYPE_EIN"


class CNoticeDateTypedDict(TypedDict):
    r"""C Notice date."""

    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 CNoticeDate(BaseModel):
    r"""C Notice date."""

    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 LegalNaturalPersonFederalTaxClassification(
    str, Enum, metaclass=utils.OpenEnumMeta
):
    r"""Federal tax classification."""

    FEDERAL_TAX_CLASSIFICATION_UNSPECIFIED = "FEDERAL_TAX_CLASSIFICATION_UNSPECIFIED"
    INDIV_SOLEPROP_OR_SINGLEMEMBERLLC = "INDIV_SOLEPROP_OR_SINGLEMEMBERLLC"
    PARTNERSHIP = "PARTNERSHIP"
    C_CORPORATION = "C_CORPORATION"
    S_CORPORATION = "S_CORPORATION"
    TRUST_ESTATE = "TRUST_ESTATE"
    LLC_TAXED_AS_C_CORP = "LLC_TAXED_AS_C_CORP"
    LLC_TAXED_AS_S_CORP = "LLC_TAXED_AS_S_CORP"
    LLC_TAXED_AS_PARTNERSHIP = "LLC_TAXED_AS_PARTNERSHIP"
    OTHER = "OTHER"


class FirstBNoticeDateTypedDict(TypedDict):
    r"""Initial B Notice date."""

    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 FirstBNoticeDate(BaseModel):
    r"""Initial B Notice date."""

    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 LegalNaturalPersonIrsFormType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""IRS form type."""

    IRS_FORM_TYPE_UNSPECIFIED = "IRS_FORM_TYPE_UNSPECIFIED"
    W_9 = "W_9"


class ReportingEligibility(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Tax reporting eligibility."""

    TAX_REPORTING_ELIGIBILITY_UNSPECIFIED = "TAX_REPORTING_ELIGIBILITY_UNSPECIFIED"
    ELIGIBLE = "ELIGIBLE"
    INELIGIBLE = "INELIGIBLE"


class TaxCertificationDateTypedDict(TypedDict):
    r"""Tax Certification date."""

    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 TaxCertificationDate(BaseModel):
    r"""Tax Certification date."""

    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 TaxpayerCertificationState(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Taxpayer certification status."""

    TAXPAYER_CERTIFICATION_STATE_UNSPECIFIED = (
        "TAXPAYER_CERTIFICATION_STATE_UNSPECIFIED"
    )
    CERTIFIED = "CERTIFIED"
    UNCERTIFIED = "UNCERTIFIED"


class LegalNaturalPersonUsTinStatus(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""United States Individual Taxpayer Identification Number (ITIN) status."""

    US_TIN_STATUS_UNSPECIFIED = "US_TIN_STATUS_UNSPECIFIED"
    PASSING = "PASSING"
    FAILING = "FAILING"


class LegalNaturalPersonWithholdingState(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""B/C Notice status."""

    WITHHOLDING_STATE_UNSPECIFIED = "WITHHOLDING_STATE_UNSPECIFIED"
    FIRST_B_NOTICE_RECEIVED = "FIRST_B_NOTICE_RECEIVED"
    SECOND_B_NOTICE_RECEIVED = "SECOND_B_NOTICE_RECEIVED"
    C_NOTICE_RECEIVED = "C_NOTICE_RECEIVED"
    C_NOTICE_INDICATED_BY_CUSTOMER = "C_NOTICE_INDICATED_BY_CUSTOMER"


class TaxProfileTypedDict(TypedDict):
    r"""Tax-related attributes at the for the account; A tax profile with taxpayer attributes is located on the legal_natural_person or legal_entity objects elsewhere on the account record."""

    c_notice_date: NotRequired[Nullable[CNoticeDateTypedDict]]
    r"""C Notice date."""
    federal_tax_classification: NotRequired[LegalNaturalPersonFederalTaxClassification]
    r"""Federal tax classification."""
    first_b_notice_date: NotRequired[Nullable[FirstBNoticeDateTypedDict]]
    r"""Initial B Notice date."""
    irs_form_type: NotRequired[LegalNaturalPersonIrsFormType]
    r"""IRS form type."""
    legal_tax_region_code: NotRequired[str]
    r"""Legal tax region must be \"US\" if provided W-9, otherwise must be a non-US country."""
    reporting_eligibility: NotRequired[ReportingEligibility]
    r"""Tax reporting eligibility."""
    tax_certification_date: NotRequired[Nullable[TaxCertificationDateTypedDict]]
    r"""Tax Certification date."""
    taxpayer_certification_state: NotRequired[TaxpayerCertificationState]
    r"""Taxpayer certification status."""
    us_tin_status: NotRequired[LegalNaturalPersonUsTinStatus]
    r"""United States Individual Taxpayer Identification Number (ITIN) status."""
    withholding_state: NotRequired[LegalNaturalPersonWithholdingState]
    r"""B/C Notice status."""


class TaxProfile(BaseModel):
    r"""Tax-related attributes at the for the account; A tax profile with taxpayer attributes is located on the legal_natural_person or legal_entity objects elsewhere on the account record."""

    c_notice_date: OptionalNullable[CNoticeDate] = UNSET
    r"""C Notice date."""

    federal_tax_classification: Annotated[
        Optional[LegalNaturalPersonFederalTaxClassification],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Federal tax classification."""

    first_b_notice_date: OptionalNullable[FirstBNoticeDate] = UNSET
    r"""Initial B Notice date."""

    irs_form_type: Annotated[
        Optional[LegalNaturalPersonIrsFormType],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""IRS form type."""

    legal_tax_region_code: Optional[str] = None
    r"""Legal tax region must be \"US\" if provided W-9, otherwise must be a non-US country."""

    reporting_eligibility: Annotated[
        Optional[ReportingEligibility], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Tax reporting eligibility."""

    tax_certification_date: OptionalNullable[TaxCertificationDate] = UNSET
    r"""Tax Certification date."""

    taxpayer_certification_state: Annotated[
        Optional[TaxpayerCertificationState], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Taxpayer certification status."""

    us_tin_status: Annotated[
        Optional[LegalNaturalPersonUsTinStatus],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""United States Individual Taxpayer Identification Number (ITIN) status."""

    withholding_state: Annotated[
        Optional[LegalNaturalPersonWithholdingState],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""B/C Notice status."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "c_notice_date",
            "federal_tax_classification",
            "first_b_notice_date",
            "irs_form_type",
            "legal_tax_region_code",
            "reporting_eligibility",
            "tax_certification_date",
            "taxpayer_certification_state",
            "us_tin_status",
            "withholding_state",
        ]
        nullable_fields = [
            "c_notice_date",
            "first_b_notice_date",
            "tax_certification_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 LegalNaturalPersonTypedDict(TypedDict):
    r"""A legal natural person. This represents the full set of data for an individual. A Customer Identification Program (CIP) may be run on legal natural persons."""

    accredited_investor: NotRequired[bool]
    r"""Indicates whether the person is an accredited investor"""
    adviser: NotRequired[bool]
    r"""Indicates whether the person is an adviser"""
    birth_date: NotRequired[Nullable[BirthDateTypedDict]]
    r"""The legal day, month, and year of birth for a natural person."""
    citizenship_countries: NotRequired[List[str]]
    r"""This is used for tax (treaty) and country block list considerations Maximum list of two 2-char CLDR Code citizenship countries, e.g. US, CA"""
    control_person_company_symbols: NotRequired[str]
    r"""A list of ticker symbols in which the underlying person is a control person; control persons are defined as having significant influence over a company’s management and operations, typically through ownership of a large percentage of the company’s voting stock or through positions on the company’s board of directors or executive team"""
    correspondent_employee: NotRequired[bool]
    r"""Indicates the related owner record is an employee of the clearing broker's correspondent customer."""
    correspondent_id: NotRequired[str]
    r"""A unique identifier referencing a Correspondent; A Client may have several operating Correspondents within its purview."""
    custodian_employee: NotRequired[bool]
    r"""A flag to indicate whether this person is an employee of the correspondent."""
    death_date: NotRequired[Nullable[DeathDateTypedDict]]
    r"""The day, month, and year of death of a legal natural person"""
    doing_business_as: NotRequired[List[str]]
    r"""DBA (Doing Business As) names. Can list up to 5 associated with the Legal Natural Person"""
    employment: NotRequired[Nullable[EmploymentTypedDict]]
    r"""Object containing information pertaining to a investor's current employer including the name, address, and duration of employment."""
    family_name: NotRequired[str]
    r"""Family name of a natural person."""
    finra_associated_entity: NotRequired[str]
    r"""The name of the FINRA-associated entity the underlying natural person is affiliated with."""
    foreign_identification: NotRequired[Nullable[ForeignIdentificationTypedDict]]
    r"""Foreign identification. Must be provided if the person does not have a U.S. tax ID"""
    given_name: NotRequired[str]
    r"""The given name of a natural person; Conventionally known as 'first name' in most English-speaking countries."""
    global_person_id: NotRequired[str]
    r"""Globally Unique identifier for a legal natural person"""
    identity_verification_result: NotRequired[
        Nullable[LegalNaturalPersonIdentityVerificationResultTypedDict]
    ]
    r"""Third-party data result used to verify the identity of an introduced investor. If the client identity_verification_model is PROVIDED_BY_CLIENT, this field is required"""
    institutional_customer: NotRequired[bool]
    r"""Indicates whether the person is an institutional customer"""
    investigation_id: NotRequired[str]
    r"""Investigation id relating to the Customer Identification Program (CIP) and Customer Due Diligence (CDD)."""
    large_trader: NotRequired[Nullable[LegalNaturalPersonLargeTraderTypedDict]]
    r"""Indicates if the person is recognized as a \"Large Trader\" by the SEC."""
    legal_natural_person_id: NotRequired[str]
    r"""A system-generated unique identifier referencing a single natural person; Used to access the record after creation."""
    marital_status: NotRequired[LegalNaturalPersonMaritalStatus]
    r"""The legal marital status of an account-holder; Used in combination with state of domicile to determine qualification for account types and beneficiary exclusion rules."""
    middle_names: NotRequired[str]
    r"""Non-primary names representing a natural person; Name attributed to a person other than \"Given\" and \"Family\" names."""
    name: NotRequired[str]
    r"""The name field Format: legalNaturalPersons/{legalNaturalPerson}"""
    name_suffix: NotRequired[LegalNaturalPersonNameSuffix]
    r"""The suffix of a natural person; A suffix in a name is any part of the name that comes after the last name"""
    natural_person_fdd: NotRequired[Nullable[NaturalPersonFddTypedDict]]
    r"""Foreign Due Diligence (FDD) information for Legal Natural Person"""
    non_citizen_residency: NotRequired[Nullable[NonCitizenResidencyTypedDict]]
    r"""Facilitates non-citizen lawful US residents to open domestic accounts"""
    personal_address: NotRequired[Nullable[PersonalAddressTypedDict]]
    r"""The legal street number and street name for an account Party. Required fields within the `personal_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """
    politically_exposed_immediate_family_names: NotRequired[List[str]]
    r"""A Party's self-disclosed list of names representing family members who are politically exposed."""
    politically_exposed_organization: NotRequired[str]
    r"""A Party's self-disclosed list of named politically exposed organizations they are personally associated with."""
    tax_id: NotRequired[str]
    r"""The full U.S. tax ID for a related person; Must be provided with `ITIN` or `SSN` tax ID type"""
    tax_id_last_four: NotRequired[str]
    r"""The last four characters of the related person's tax identifier; Masked/truncated to \"last four\" in most usage contexts to preserve data privacy."""
    tax_id_type: NotRequired[LegalNaturalPersonTaxIDType]
    r"""The nature of the U.S. Tax ID indicated in the related tax_id field; Examples include ITIN, SSN, EIN."""
    tax_profile: NotRequired[Nullable[TaxProfileTypedDict]]
    r"""Tax-related attributes at the for the account; A tax profile with taxpayer attributes is located on the legal_natural_person or legal_entity objects elsewhere on the account record."""


class LegalNaturalPerson(BaseModel):
    r"""A legal natural person. This represents the full set of data for an individual. A Customer Identification Program (CIP) may be run on legal natural persons."""

    accredited_investor: Optional[bool] = None
    r"""Indicates whether the person is an accredited investor"""

    adviser: Optional[bool] = None
    r"""Indicates whether the person is an adviser"""

    birth_date: OptionalNullable[BirthDate] = UNSET
    r"""The legal day, month, and year of birth for a natural person."""

    citizenship_countries: Optional[List[str]] = None
    r"""This is used for tax (treaty) and country block list considerations Maximum list of two 2-char CLDR Code citizenship countries, e.g. US, CA"""

    control_person_company_symbols: Optional[str] = None
    r"""A list of ticker symbols in which the underlying person is a control person; control persons are defined as having significant influence over a company’s management and operations, typically through ownership of a large percentage of the company’s voting stock or through positions on the company’s board of directors or executive team"""

    correspondent_employee: Optional[bool] = None
    r"""Indicates the related owner record is an employee of the clearing broker's correspondent customer."""

    correspondent_id: Optional[str] = None
    r"""A unique identifier referencing a Correspondent; A Client may have several operating Correspondents within its purview."""

    custodian_employee: Optional[bool] = None
    r"""A flag to indicate whether this person is an employee of the correspondent."""

    death_date: OptionalNullable[DeathDate] = UNSET
    r"""The day, month, and year of death of a legal natural person"""

    doing_business_as: Optional[List[str]] = None
    r"""DBA (Doing Business As) names. Can list up to 5 associated with the Legal Natural Person"""

    employment: OptionalNullable[Employment] = UNSET
    r"""Object containing information pertaining to a investor's current employer including the name, address, and duration of employment."""

    family_name: Optional[str] = None
    r"""Family name of a natural person."""

    finra_associated_entity: Optional[str] = None
    r"""The name of the FINRA-associated entity the underlying natural person is affiliated with."""

    foreign_identification: OptionalNullable[ForeignIdentification] = UNSET
    r"""Foreign identification. Must be provided if the person does not have a U.S. tax ID"""

    given_name: Optional[str] = None
    r"""The given name of a natural person; Conventionally known as 'first name' in most English-speaking countries."""

    global_person_id: Optional[str] = None
    r"""Globally Unique identifier for a legal natural person"""

    identity_verification_result: OptionalNullable[
        LegalNaturalPersonIdentityVerificationResult
    ] = UNSET
    r"""Third-party data result used to verify the identity of an introduced investor. If the client identity_verification_model is PROVIDED_BY_CLIENT, this field is required"""

    institutional_customer: Optional[bool] = None
    r"""Indicates whether the person is an institutional customer"""

    investigation_id: Optional[str] = None
    r"""Investigation id relating to the Customer Identification Program (CIP) and Customer Due Diligence (CDD)."""

    large_trader: OptionalNullable[LegalNaturalPersonLargeTrader] = UNSET
    r"""Indicates if the person is recognized as a \"Large Trader\" by the SEC."""

    legal_natural_person_id: Optional[str] = None
    r"""A system-generated unique identifier referencing a single natural person; Used to access the record after creation."""

    marital_status: Annotated[
        Optional[LegalNaturalPersonMaritalStatus],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The legal marital status of an account-holder; Used in combination with state of domicile to determine qualification for account types and beneficiary exclusion rules."""

    middle_names: Optional[str] = None
    r"""Non-primary names representing a natural person; Name attributed to a person other than \"Given\" and \"Family\" names."""

    name: Optional[str] = None
    r"""The name field Format: legalNaturalPersons/{legalNaturalPerson}"""

    name_suffix: Annotated[
        Optional[LegalNaturalPersonNameSuffix],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The suffix of a natural person; A suffix in a name is any part of the name that comes after the last name"""

    natural_person_fdd: OptionalNullable[NaturalPersonFdd] = UNSET
    r"""Foreign Due Diligence (FDD) information for Legal Natural Person"""

    non_citizen_residency: OptionalNullable[NonCitizenResidency] = UNSET
    r"""Facilitates non-citizen lawful US residents to open domestic accounts"""

    personal_address: OptionalNullable[PersonalAddress] = UNSET
    r"""The legal street number and street name for an account Party. Required fields within the `personal_address` object include:
    - `administrative_area`
    - `region_code` - 2 character CLDR Code
    - `postal_code`
    - `locality`
    - `address_lines` - max 5 lines
    """

    politically_exposed_immediate_family_names: Optional[List[str]] = None
    r"""A Party's self-disclosed list of names representing family members who are politically exposed."""

    politically_exposed_organization: Optional[str] = None
    r"""A Party's self-disclosed list of named politically exposed organizations they are personally associated with."""

    tax_id: Optional[str] = None
    r"""The full U.S. tax ID for a related person; Must be provided with `ITIN` or `SSN` tax ID type"""

    tax_id_last_four: Optional[str] = None
    r"""The last four characters of the related person's tax identifier; Masked/truncated to \"last four\" in most usage contexts to preserve data privacy."""

    tax_id_type: Annotated[
        Optional[LegalNaturalPersonTaxIDType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The nature of the U.S. Tax ID indicated in the related tax_id field; Examples include ITIN, SSN, EIN."""

    tax_profile: OptionalNullable[TaxProfile] = UNSET
    r"""Tax-related attributes at the for the account; A tax profile with taxpayer attributes is located on the legal_natural_person or legal_entity objects elsewhere on the account record."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "accredited_investor",
            "adviser",
            "birth_date",
            "citizenship_countries",
            "control_person_company_symbols",
            "correspondent_employee",
            "correspondent_id",
            "custodian_employee",
            "death_date",
            "doing_business_as",
            "employment",
            "family_name",
            "finra_associated_entity",
            "foreign_identification",
            "given_name",
            "global_person_id",
            "identity_verification_result",
            "institutional_customer",
            "investigation_id",
            "large_trader",
            "legal_natural_person_id",
            "marital_status",
            "middle_names",
            "name",
            "name_suffix",
            "natural_person_fdd",
            "non_citizen_residency",
            "personal_address",
            "politically_exposed_immediate_family_names",
            "politically_exposed_organization",
            "tax_id",
            "tax_id_last_four",
            "tax_id_type",
            "tax_profile",
        ]
        nullable_fields = [
            "birth_date",
            "death_date",
            "employment",
            "foreign_identification",
            "identity_verification_result",
            "large_trader",
            "natural_person_fdd",
            "non_citizen_residency",
            "personal_address",
            "tax_profile",
        ]
        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
