Spaces:
Sleeping
Sleeping
Download integrations/mock_core_banking.py from anil988/SentinelFin-AI-Backend: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/spaces/anil988/SentinelFin-AI-Backend/resolve/main/integrations/mock_core_banking.py
- Command line
-
hf download hf://spaces/anil988/SentinelFin-AI-Backend/integrations/mock_core_banking.py
-
curl -L -o mock_core_banking.py https://huggingface.co/spaces/anil988/SentinelFin-AI-Backend/resolve/main/integrations/mock_core_banking.py
1.75 kB
| import json | |
| import os | |
| from typing import Dict, Any | |
| MOCK_DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "mock_data") | |
| class CoreBankingAPI: | |
| """Mock Core Banking System API for retrieving KYC and transaction history.""" | |
| def get_customer_profile(account_id: str) -> Dict[str, Any]: | |
| """Fetch the KYC profile and risk rating for an account.""" | |
| # In a real system, this would query the core banking database. | |
| # For the hackathon, we pull from the mock scenarios to ensure consistency. | |
| for filename in os.listdir(MOCK_DATA_DIR): | |
| if filename.endswith(".json"): | |
| with open(os.path.join(MOCK_DATA_DIR, filename), 'r') as f: | |
| data = json.load(f) | |
| if data.get("primary_subject", {}).get("account_id") == account_id: | |
| return data.get("primary_subject", {}) | |
| return {"error": "Account not found"} | |
| def get_transaction_history(account_id: str, days: int = 90) -> list: | |
| """Fetch transaction history for the last X days.""" | |
| # Find transactions in the mock scenarios related to this account | |
| transactions = [] | |
| for filename in os.listdir(MOCK_DATA_DIR): | |
| if filename.endswith(".json"): | |
| with open(os.path.join(MOCK_DATA_DIR, filename), 'r') as f: | |
| data = json.load(f) | |
| if data.get("primary_subject", {}).get("account_id") == account_id: | |
| transactions.extend(data.get("transactions", [])) | |
| if not transactions: | |
| return [{"error": "No transactions found for account"}] | |
| return transactions | |