feat: add Tech Passport API integration for vehicle information retrieval
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .otp import * # noqa
|
||||
from .sms import * # noqa
|
||||
from .user import * # noqa
|
||||
from .didox import * # noqa
|
||||
from .didox import * # noqa
|
||||
from .tech_passport import * # noqa
|
||||
64
core/services/tech_passport.py
Normal file
64
core/services/tech_passport.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import requests
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TechPassportService:
|
||||
BASE_URL = "https://api-test.gross.uz/api/v1/osago/check-tech-data"
|
||||
|
||||
@classmethod
|
||||
def get_auto_info(
|
||||
cls,
|
||||
autonumber: str,
|
||||
tech_pass_number: str,
|
||||
tech_pass_series: str
|
||||
):
|
||||
payload = {
|
||||
"tech_data": {
|
||||
"autonumber": autonumber,
|
||||
"tech_pass_number": tech_pass_number,
|
||||
"tech_pass_series": tech_pass_series,
|
||||
},
|
||||
"payload": {
|
||||
"promo": "",
|
||||
"autotype": 1,
|
||||
"citizen": 1,
|
||||
"number": 1,
|
||||
"period": 1,
|
||||
"region": 1,
|
||||
"coeff": 1
|
||||
}
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post(
|
||||
cls.BASE_URL,
|
||||
json=payload,
|
||||
headers=headers,
|
||||
timeout=30,
|
||||
verify=False
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
logger.info(
|
||||
f"Tech passport info fetched successfully: {response.status_code}"
|
||||
)
|
||||
|
||||
response_data = response.json()
|
||||
|
||||
return response_data.get("data", {})
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(
|
||||
f"Error while fetching tech passport info: {str(e)}"
|
||||
)
|
||||
return {
|
||||
"success": False,
|
||||
"message": str(e)
|
||||
}
|
||||
Reference in New Issue
Block a user