This commit is contained in:
2025-12-11 21:27:37 -06:00
parent ae5fa9ca1c
commit 4b3b5d5671
2 changed files with 75 additions and 3 deletions

View File

@@ -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:

View File

@@ -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"