schemas.account_schemas¶
src.schemas.account_schemas
¶
Account request and response schemas.
Pydantic schemas for account API endpoints. Includes: - Request schemas (client → API) - Response schemas (API → client) - DTO-to-schema conversion methods
Reference
- docs/architecture/api-design-patterns.md
Classes¶
AccountResponse
¶
Bases: BaseModel
Single account response.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Account unique identifier. |
connection_id |
UUID
|
Provider connection FK. |
provider_account_id |
str
|
Provider's identifier for this account. |
account_number_masked |
str
|
Masked number for display (e.g., "**1234"). |
name |
str
|
Account name from provider. |
account_type |
str
|
Type as string (e.g., "brokerage", "ira"). |
currency |
str
|
ISO 4217 currency code. |
balance_amount |
Decimal
|
Current balance. |
balance_currency |
str
|
Balance currency code. |
available_balance_amount |
Decimal | None
|
Available balance (if different). |
available_balance_currency |
str | None
|
Available balance currency. |
is_active |
bool
|
Whether account is active on provider. |
is_investment |
bool
|
Whether account is investment type. |
is_bank |
bool
|
Whether account is banking type. |
is_retirement |
bool
|
Whether account is retirement type. |
is_credit |
bool
|
Whether account is credit type. |
last_synced_at |
datetime | None
|
Last successful sync timestamp. |
created_at |
datetime
|
Record creation timestamp. |
updated_at |
datetime
|
Last modification timestamp. |
Source code in src/schemas/account_schemas.py
Functions¶
from_dto
classmethod
¶
Convert application DTO to response schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
AccountResult
|
AccountResult from handler. |
required |
Returns:
| Type | Description |
|---|---|
AccountResponse
|
AccountResponse for API response. |
Source code in src/schemas/account_schemas.py
AccountListResponse
¶
Bases: BaseModel
Account list response with aggregates.
Attributes:
| Name | Type | Description |
|---|---|---|
accounts |
list[AccountResponse]
|
List of accounts. |
total_count |
int
|
Total number of accounts. |
active_count |
int
|
Number of active accounts. |
total_balance_by_currency |
dict[str, str]
|
Aggregated balances by currency. |
Source code in src/schemas/account_schemas.py
Functions¶
from_dto
classmethod
¶
Convert application DTO to response schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
AccountListResult
|
AccountListResult from handler. |
required |
Returns:
| Type | Description |
|---|---|
AccountListResponse
|
AccountListResponse for API response. |
Source code in src/schemas/account_schemas.py
SyncAccountsResponse
¶
Bases: SyncResponse
Response for account sync operation.
Extends SyncResponse with account-specific fields.
Attributes:
| Name | Type | Description |
|---|---|---|
accounts_created |
int
|
Number of new accounts created. |
accounts_updated |
int
|
Number of existing accounts updated. |
Source code in src/schemas/account_schemas.py
SyncAccountsRequest
¶
Bases: BaseModel
Request to sync accounts from provider.
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection to sync from. |
force |
bool
|
Force sync even if recently synced. |