Feature: Tilføjet /api/v1/system/test-economic endpoint til at teste e-conomic API forbindelse
This commit is contained in:
parent
35447cbd4f
commit
7fd596612c
@ -46,6 +46,53 @@ async def get_config():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/system/test-economic")
|
||||||
|
async def test_economic_connection():
|
||||||
|
"""Test e-conomic API connection and fetch sample data"""
|
||||||
|
try:
|
||||||
|
from app.services.economic_service import EconomicService
|
||||||
|
economic = EconomicService()
|
||||||
|
|
||||||
|
# Test 1: Fetch first page of customers
|
||||||
|
customers = await economic.get_customers(page=0, page_size=5)
|
||||||
|
|
||||||
|
# Test 2: Get self info
|
||||||
|
self_info = await economic.get_self()
|
||||||
|
|
||||||
|
return {
|
||||||
|
"status": "success",
|
||||||
|
"connection": "healthy",
|
||||||
|
"api_url": settings.ECONOMIC_API_URL,
|
||||||
|
"has_app_secret": bool(settings.ECONOMIC_APP_SECRET_TOKEN),
|
||||||
|
"has_agreement_token": bool(settings.ECONOMIC_AGREEMENT_GRANT_TOKEN),
|
||||||
|
"read_only_mode": settings.ECONOMIC_READ_ONLY,
|
||||||
|
"dry_run_mode": settings.ECONOMIC_DRY_RUN,
|
||||||
|
"self_info": {
|
||||||
|
"agreement": self_info.get("agreementNumber") if self_info else None,
|
||||||
|
"company": self_info.get("company", {}).get("name") if self_info else None
|
||||||
|
},
|
||||||
|
"sample_customers": {
|
||||||
|
"count": len(customers) if customers else 0,
|
||||||
|
"first_3": [
|
||||||
|
{
|
||||||
|
"number": c.get("customerNumber"),
|
||||||
|
"name": c.get("name"),
|
||||||
|
"cvr": c.get("corporateIdentificationNumber")
|
||||||
|
} for c in (customers[:3] if customers else [])
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
return {
|
||||||
|
"status": "error",
|
||||||
|
"connection": "failed",
|
||||||
|
"error": str(e),
|
||||||
|
"api_url": settings.ECONOMIC_API_URL,
|
||||||
|
"has_app_secret": bool(settings.ECONOMIC_APP_SECRET_TOKEN),
|
||||||
|
"has_agreement_token": bool(settings.ECONOMIC_AGREEMENT_GRANT_TOKEN)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.get("/system/maintenance")
|
@router.get("/system/maintenance")
|
||||||
async def get_maintenance_status():
|
async def get_maintenance_status():
|
||||||
"""Get maintenance mode status"""
|
"""Get maintenance mode status"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user