changing code structure
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
# rest framework
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.generics import GenericAPIView
|
||||
|
||||
|
||||
# swagger
|
||||
from drf_spectacular.utils import extend_schema, OpenApiParameter
|
||||
|
||||
# local apps
|
||||
from core.services.didox import DidoxService
|
||||
|
||||
|
||||
@@ -38,7 +40,6 @@ class DidoxCompanyInfoAPIView(GenericAPIView):
|
||||
{"detail": "TIN must be a valid integer"},
|
||||
status=status.HTTP_400_BAD_REQUEST
|
||||
)
|
||||
|
||||
data = DidoxService.get_company_info(tin)
|
||||
|
||||
if not data:
|
||||
@@ -47,14 +48,11 @@ class DidoxCompanyInfoAPIView(GenericAPIView):
|
||||
status=status.HTTP_502_BAD_GATEWAY
|
||||
)
|
||||
|
||||
# if both name and personalNum are null/empty -> 404
|
||||
name = data.get("name")
|
||||
personal_num = data.get("personalNum")
|
||||
|
||||
if not name and not personal_num:
|
||||
return Response(
|
||||
{"detail": "Company or person not found"},
|
||||
status=status.HTTP_404_NOT_FOUND
|
||||
)
|
||||
|
||||
return Response(data, status=status.HTTP_200_OK)
|
||||
return Response(data, status=status.HTTP_200_OK)
|
||||
|
||||
Reference in New Issue
Block a user