application.queries.handlers.get_account_handler¶
src.application.queries.handlers.get_account_handler
¶
GetAccount query handler.
Handles requests to retrieve a single account. Returns DTO (not domain entity) to prevent leaking domain to presentation.
Architecture: - Application layer handler (orchestrates data retrieval) - Returns Result[DTO, str] (explicit error handling) - NO domain events (queries are side-effect free)
Reference
- docs/architecture/cqrs-pattern.md
- docs/architecture/account-domain-model.md
Classes¶
AccountResult
dataclass
¶
Single account result DTO.
Represents an account for API response. Does NOT include sensitive data. Money value objects converted to separate amount+currency fields.
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 as Decimal. |
balance_currency |
str
|
Balance currency code (matches currency). |
available_balance_amount |
Decimal | None
|
Available balance (if different from balance). |
available_balance_currency |
str | None
|
Available balance currency (if present). |
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/application/queries/handlers/get_account_handler.py
GetAccountError
¶
GetAccount-specific errors.
Source code in src/application/queries/handlers/get_account_handler.py
GetAccountHandler
¶
Handler for GetAccount query.
Retrieves a single account by ID with ownership verification. Uses OwnershipVerifier to verify the user owns the account via connection.
Dependencies (injected via constructor): - OwnershipVerifier: For account retrieval with ownership verification
Source code in src/application/queries/handlers/get_account_handler.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
Functions¶
__init__
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ownership_verifier
|
OwnershipVerifier
|
Service for ownership verification. |
required |
Source code in src/application/queries/handlers/get_account_handler.py
handle
async
¶
Handle GetAccount query.
Retrieves account, verifies ownership via connection, and maps to DTO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
GetAccount
|
GetAccount query with account and user IDs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Success |
AccountResult
|
Account found and owned by user. |
Failure |
error
|
Account not found or not owned by user. |