Merge pull request 'feat: add Tech Passport API integration for vehicle information retrieval' (#76) from tech-passport into main
All checks were successful
Deploy to Production / build-and-deploy (push) Successful in 2m0s
All checks were successful
Deploy to Production / build-and-deploy (push) Successful in 2m0s
Reviewed-on: #76 Reviewed-by: xoliqberdiyev <behruz@felixits.uz>
This commit is contained in:
@@ -11,3 +11,4 @@ from .report import * # noqa
|
||||
from .request import * # noqa
|
||||
from .valuation import * # noqa
|
||||
from .vehicle import * # noqa
|
||||
from .tech_passport import * # noqa
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from .tech_passport import * # noqa
|
||||
@@ -0,0 +1,6 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
class TechPassportSerializer(serializers.Serializer):
|
||||
autonumber = serializers.CharField(required=True, max_length=20)
|
||||
tech_pass_number = serializers.CharField(required=True, max_length=20)
|
||||
tech_pass_series = serializers.CharField(required=True, max_length=20)
|
||||
@@ -27,7 +27,7 @@ from .views import (
|
||||
AutoEvaluationSetAppraisersView,
|
||||
AutoEvaluationRemoveAppraisersView,
|
||||
DidoxCompanyInfoAPIView,
|
||||
|
||||
TechPassportAPIView,
|
||||
)
|
||||
|
||||
router = DefaultRouter()
|
||||
@@ -66,4 +66,9 @@ urlpatterns = [
|
||||
DidoxCompanyInfoAPIView.as_view(),
|
||||
name="didox-info"
|
||||
),
|
||||
path(
|
||||
"tech-passport/",
|
||||
TechPassportAPIView.as_view(),
|
||||
name="tech-passport"
|
||||
),
|
||||
]
|
||||
|
||||
@@ -12,3 +12,4 @@ from .request import * # noqa
|
||||
from .valuation import * # noqa
|
||||
from .vehicle import * # noqa
|
||||
from .didox import * # noqa
|
||||
from .tech_passport import * # noqa
|
||||
|
||||
50
core/apps/evaluation/views/tech_passport.py
Normal file
50
core/apps/evaluation/views/tech_passport.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.generics import GenericAPIView
|
||||
|
||||
from drf_spectacular.utils import (
|
||||
extend_schema,
|
||||
OpenApiExample,
|
||||
)
|
||||
|
||||
from core.services.tech_passport import TechPassportService
|
||||
from ..serializers import TechPassportSerializer
|
||||
|
||||
|
||||
class TechPassportAPIView(GenericAPIView):
|
||||
authentication_classes = []
|
||||
permission_classes = [AllowAny]
|
||||
|
||||
@extend_schema(
|
||||
tags=["Tech Passport"],
|
||||
summary="Get vehicle information by technical passport",
|
||||
description=(
|
||||
"This endpoint retrieves vehicle information using "
|
||||
"autonumber, technical passport number, and technical passport series "
|
||||
"via Gross Insurance API integration."
|
||||
),
|
||||
request=TechPassportSerializer,
|
||||
responses={
|
||||
200: dict,
|
||||
400: dict,
|
||||
},
|
||||
)
|
||||
def post(self, request, *args, **kwargs):
|
||||
serializer = TechPassportSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
data = serializer.validated_data
|
||||
|
||||
try:
|
||||
result = TechPassportService.get_auto_info(
|
||||
autonumber=data["autonumber"],
|
||||
tech_pass_number=data["tech_pass_number"],
|
||||
tech_pass_series=data["tech_pass_series"],
|
||||
)
|
||||
return Response(result, status=status.HTTP_200_OK)
|
||||
|
||||
except Exception as e:
|
||||
return Response(
|
||||
{"detail": str(e)},
|
||||
status=status.HTTP_400_BAD_REQUEST
|
||||
)
|
||||
Reference in New Issue
Block a user