Files
leggen/leggend/api/models/banks.py
Elisiário Couto 91f53b35b1 feat: Transform to web architecture with FastAPI backend
This major update transforms leggen from CLI-only to a web-ready
architecture while maintaining full CLI compatibility.

New Features:
- FastAPI backend service (leggend) with comprehensive REST API
- Background job scheduler with configurable cron (replaces Ofelia)
- All CLI commands refactored to use API endpoints
- Docker configuration updated for new services
- API client with health checks and error handling

API Endpoints:
- /api/v1/banks/* - Bank connections and institutions
- /api/v1/accounts/* - Account management and balances
- /api/v1/transactions/* - Transaction retrieval with filtering
- /api/v1/sync/* - Manual sync and scheduler configuration
- /api/v1/notifications/* - Notification settings management

CLI Enhancements:
- New --api-url option and LEGGEND_API_URL environment variable
- Enhanced sync command with --wait and --force options
- Improved transactions command with --full and --limit options
- Automatic fallback and health checking

Breaking Changes:
- compose.yml structure updated (leggend service added)
- Ofelia scheduler removed (internal scheduler used instead)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 19:39:11 +01:00

52 lines
1.1 KiB
Python

from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel
class BankInstitution(BaseModel):
"""Bank institution model"""
id: str
name: str
bic: Optional[str] = None
transaction_total_days: int
countries: List[str]
logo: Optional[str] = None
class BankConnectionRequest(BaseModel):
"""Request to connect to a bank"""
institution_id: str
redirect_url: Optional[str] = "http://localhost:8000/"
class BankRequisition(BaseModel):
"""Bank requisition/connection model"""
id: str
institution_id: str
status: str
status_display: Optional[str] = None
created: datetime
link: str
accounts: List[str] = []
class Config:
json_encoders = {
datetime: lambda v: v.isoformat()
}
class BankConnectionStatus(BaseModel):
"""Bank connection status response"""
bank_id: str
bank_name: str
status: str
status_display: str
created_at: datetime
requisition_id: str
accounts_count: int
class Config:
json_encoders = {
datetime: lambda v: v.isoformat()
}