diff --git a/dta_service/core/views/property.py b/dta_service/core/views/property.py index feb3732..b73b95b 100644 --- a/dta_service/core/views/property.py +++ b/dta_service/core/views/property.py @@ -206,7 +206,7 @@ class PropertySaveViewSet( API_KEY = "AIMLOPERATIONSLLC-a7ce-7525-b38f-cf8b4d52ca70" -class PropertDetailProxyView(APIView): +class PropertyDetailProxyView(APIView): def post(self, request, *args, **kwargs): if not API_KEY: return Response( @@ -239,6 +239,66 @@ class PropertDetailProxyView(APIView): ) +class PropertyCompsProxyView(APIView): + def post(self, request, *args, **kwargs): + if not API_KEY: + return Response( + {"detail": "API KEY is missing"}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR, + ) + + external_headers = { + "accept": "application/json", + "Content-Type": "application/json", + "X-API-Key": API_KEY, # SENSITIVE KEY: Used on server-side only + "X-User-Id": "UniqueUserIdentifier", + } + payload = request.data + try: + response = requests.post( + "https://api.realestateapi.com/v3/PropertyComps", + headers=external_headers, + json=payload, + ) + response.raise_for_status() + return Response(response.json(), status=response.status_code) + except Exception as e: + return Response( + {"detail": f"External API Error: {e.response.text}"}, + status=e.response.status_code, + ) + + +class MLSDetailProxyView(APIView): + def post(self, request, *args, **kwargs): + if not API_KEY: + return Response( + {"detail": "API KEY is missing"}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR, + ) + + external_headers = { + "accept": "application/json", + "Content-Type": "application/json", + "X-API-Key": API_KEY, # SENSITIVE KEY: Used on server-side only + "X-User-Id": "UniqueUserIdentifier", + } + payload = request.data + try: + response = requests.post( + "https://api.realestateapi.com/v2/MLSDetail", + headers=external_headers, + json=payload, + ) + response.raise_for_status() + return Response(response.json(), status=response.status_code) + except Exception as e: + return Response( + {"detail": f"External API Error: {e.response.text}"}, + status=e.response.status_code, + ) + + class AutoCompleteProxyView(APIView): def post(self, request, *args, **kwargs): if not API_KEY: diff --git a/dta_service/dta_service/urls.py b/dta_service/dta_service/urls.py index 1ce0ada..f97a5c4 100644 --- a/dta_service/dta_service/urls.py +++ b/dta_service/dta_service/urls.py @@ -32,7 +32,9 @@ from core.views import ( CreateDocumentView, RetrieveDocumentView, AutoCompleteProxyView, - PropertDetailProxyView, + PropertyDetailProxyView, + PropertyCompsProxyView, + MLSDetailProxyView, ) from django.conf import settings from django.conf.urls.static import static @@ -50,9 +52,19 @@ urlpatterns = [ ), path( "api/property-details-proxy/", - PropertDetailProxyView.as_view(), + PropertyDetailProxyView.as_view(), name="property-details-proxy", ), + path( + "api/property-comps-proxy/", + PropertyCompsProxyView.as_view(), + name="property-comps-proxy", + ), + path( + "api/mls-detail-proxy/", + MLSDetailProxyView.as_view(), + name="mls-detail-proxy", + ), path("api/register/", UserRegisterView.as_view(), name="register"), path( "api/password-reset/", PasswordResetRequestView.as_view(), name="password_reset"