Cleanup: MB 2.0 Gap Analysis előtti állapot (adatok kizárva)
This commit is contained in:
27
backend/app/services/dvla_service.py
Normal file
27
backend/app/services/dvla_service.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import httpx
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("DVLA-Service")
|
||||
|
||||
class DVLAService:
|
||||
API_URL = "https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles"
|
||||
API_KEY = "IDE_MÁSOLD_BE_AZ_API_KULCSOT"
|
||||
|
||||
@classmethod
|
||||
async def get_vehicle_details(cls, vrm: str):
|
||||
"""VRM az angol rendszám (pl. AB12 CDE)"""
|
||||
headers = {
|
||||
"x-api-key": cls.API_KEY,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
payload = {"registrationNumber": vrm}
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
response = await client.post(cls.API_URL, json=payload, headers=headers)
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"❌ DVLA hiba: {e}")
|
||||
return None
|
||||
Reference in New Issue
Block a user