feat: add 404 response for missing company or person in Didox API #86

Merged
husanjon merged 1 commits from didox-api into main 2026-04-22 09:19:30 +00:00

View File

@@ -31,7 +31,6 @@ class DidoxCompanyInfoAPIView(GenericAPIView):
def get(self, request, *args, **kwargs):
tin = kwargs.get("tin")
# 🔥 TYPE CHECK
try:
tin = int(tin)
except (TypeError, ValueError):
@@ -48,4 +47,14 @@ 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)