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

from __future__ import annotations
from ascend_sdk.models.components import (
    httpmetadata as components_httpmetadata,
    listaccountsresponse as components_listaccountsresponse,
    status as components_status,
)
from ascend_sdk.types import BaseModel
from ascend_sdk.utils import FieldMetadata, QueryParamMetadata
from enum import Enum
import pydantic
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class View(str, Enum):
    r"""The view to return. Defaults to `BASIC`."""

    ACCOUNT_VIEW_UNSPECIFIED = "ACCOUNT_VIEW_UNSPECIFIED"
    BASIC = "BASIC"
    FULL = "FULL"


class AccountsListAccountsRequestTypedDict(TypedDict):
    page_size: NotRequired[int]
    r"""The maximum number of accounts to return. The service may return fewer than this value. If unspecified, at most 25 accounts will be returned. The maximum value is 100; values above 100 will be coerced to 100."""
    page_token: NotRequired[str]
    r"""A page token, received from a previous `ListAccounts` call. Provide this to retrieve the subsequent page.

    When paginating, all other parameters provided to `ListAccounts` must match the call that provided the page token.
    """
    order_by: NotRequired[str]
    r"""The order in which accounts are listed. Can order by:
    `account_id`
    `account_number`
    `title`
    `state`
    `account_group_id`
    """
    filter_: NotRequired[str]
    r"""A CEL string to filter results; Use `upperAscii()` for case-insensitive searches; E.g. `parties.exists(parties,parties.legal_natural_person.family_name.upperAscii()==\"dOuGh\".upperAscii())`; See the [CEL Search](https://developer.apexclearing.com/apex-fintech-solutions/docs/cel-search) page in Guides for more information; Filter options include:
    `account_id`
    `account_number`
    `correspondent_id`
    `title`
    `state`
    `margin_group_id`
    `account_group_id`
    `registration_type`
    `parties.legal_natural_person.legal_natural_person_id`
    `parties.legal_natural_person.given_name`
    `parties.legal_natural_person.family_name`
    `parties.legal_natural_person.tax_id_type`
    `parties.legal_natural_person.tax_id`
    `parties.legal_entity.legal_entity_id`
    `parties.legal_entity.entity_name`
    `parties.legal_entity.tax_id_type`
    `parties.legal_entity.tax_id`
    `parties.legal_natural_person.foreign_identification.identification_number`
    `parties.legal_natural_person.foreign_identification.type`
    `enrollments.enrollment_id`
    `enrollments.type`
    `enrollments.state`
    `identifiers.type`
    `identifiers.value`
    """
    view: NotRequired[View]
    r"""The view to return. Defaults to `BASIC`."""


class AccountsListAccountsRequest(BaseModel):
    page_size: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The maximum number of accounts to return. The service may return fewer than this value. If unspecified, at most 25 accounts will be returned. The maximum value is 100; values above 100 will be coerced to 100."""

    page_token: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""A page token, received from a previous `ListAccounts` call. Provide this to retrieve the subsequent page.

    When paginating, all other parameters provided to `ListAccounts` must match the call that provided the page token.
    """

    order_by: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The order in which accounts are listed. Can order by:
    `account_id`
    `account_number`
    `title`
    `state`
    `account_group_id`
    """

    filter_: Annotated[
        Optional[str],
        pydantic.Field(alias="filter"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""A CEL string to filter results; Use `upperAscii()` for case-insensitive searches; E.g. `parties.exists(parties,parties.legal_natural_person.family_name.upperAscii()==\"dOuGh\".upperAscii())`; See the [CEL Search](https://developer.apexclearing.com/apex-fintech-solutions/docs/cel-search) page in Guides for more information; Filter options include:
    `account_id`
    `account_number`
    `correspondent_id`
    `title`
    `state`
    `margin_group_id`
    `account_group_id`
    `registration_type`
    `parties.legal_natural_person.legal_natural_person_id`
    `parties.legal_natural_person.given_name`
    `parties.legal_natural_person.family_name`
    `parties.legal_natural_person.tax_id_type`
    `parties.legal_natural_person.tax_id`
    `parties.legal_entity.legal_entity_id`
    `parties.legal_entity.entity_name`
    `parties.legal_entity.tax_id_type`
    `parties.legal_entity.tax_id`
    `parties.legal_natural_person.foreign_identification.identification_number`
    `parties.legal_natural_person.foreign_identification.type`
    `enrollments.enrollment_id`
    `enrollments.type`
    `enrollments.state`
    `identifiers.type`
    `identifiers.value`
    """

    view: Annotated[
        Optional[View],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The view to return. Defaults to `BASIC`."""


class AccountsListAccountsResponseTypedDict(TypedDict):
    http_meta: components_httpmetadata.HTTPMetadataTypedDict
    list_accounts_response: NotRequired[
        components_listaccountsresponse.ListAccountsResponseTypedDict
    ]
    r"""OK"""
    status: NotRequired[components_status.StatusTypedDict]
    r"""INVALID_ARGUMENT: The request is not valid, additional information may be present in the BadRequest details."""


class AccountsListAccountsResponse(BaseModel):
    http_meta: Annotated[
        Optional[components_httpmetadata.HTTPMetadata], pydantic.Field(exclude=True)
    ] = None

    list_accounts_response: Optional[
        components_listaccountsresponse.ListAccountsResponse
    ] = None
    r"""OK"""

    status: Optional[components_status.Status] = None
    r"""INVALID_ARGUMENT: The request is not valid, additional information may be present in the BadRequest details."""
