endpoint setup

This commit is contained in:
exolonConfidental
2026-02-08 11:18:47 +05:30
parent 8fb3b7cf67
commit a77788fc47
33 changed files with 932 additions and 352 deletions

View File

@@ -0,0 +1,10 @@
from pydantic import BaseModel
from app.schemas.location_create_schema import LocationCreate
from app.schemas.owner_create_schema import OwnerCreate
from app.schemas.property_create_schema import PropertyCreate
class FullEntryCreateRequest(BaseModel):
location: LocationCreate
owner: OwnerCreate
property: PropertyCreate

View File

@@ -0,0 +1,26 @@
from pydantic import BaseModel
class LocationCreate(BaseModel):
place_id: int
osm_id: int
osm_type: str
latitude: float
longitude: float
house_number: str | None = None
road: str
city: str
county: str
state: str
postcode: str
country: str
country_code: str
display_name: str
bbox_lat_min: float
bbox_lat_max: float
bbox_lon_min: float
bbox_lon_max: float

View File

@@ -1,6 +0,0 @@
from pydantic import BaseModel, Field
class NearestAssetRequest(BaseModel):
lat: float = Field(..., ge=-90, le=90, example=34.01544)
lng: float = Field(..., ge=-180, le=180, example=-118.2201)

49
app/schemas/map_schema.py Normal file
View File

@@ -0,0 +1,49 @@
from pydantic import BaseModel, Field
class MapQueryParams(BaseModel):
lat: float = Field(..., ge=-90, le=90, description="Latitude")
lon: float = Field(..., ge=-180, le=180, description="Longitude")
radius: int = Field(2000, gt=0, le=50000, description="Search radius in meters")
class LocationResponse(BaseModel):
id: int
# OSM identifiers
place_id: int
osm_id: int
osm_type: str
# Coordinates
latitude: float
longitude: float
# Address info
house_number: str | None = None
road: str
city: str
county: str
state: str
postcode: str
country: str
country_code: str
# Display name
display_name: str
# Bounding box
bbox_lat_min: float
bbox_lat_max: float
bbox_lon_min: float
bbox_lon_max: float
class Config:
from_attributes = True
class MapQueryResponse(BaseModel):
total: int
locations: list[LocationResponse]

View File

@@ -0,0 +1,15 @@
from pydantic import BaseModel
class OwnerCreate(BaseModel):
full_name: str
phone_number: str
email: str
occupation: str
annual_income_range: str
willing_to_rent: bool = False
desired_rent_price: int | None = None
willing_to_sell: bool = False
desired_sell_price: int | None = None

View File

@@ -0,0 +1,17 @@
from pydantic import BaseModel
class OwnerResponse(BaseModel):
id: int
full_name: str
phone_number: str
email: str
occupation: str
annual_income_range: str
willing_to_rent: bool
desired_rent_price: int | None
willing_to_sell: bool
desired_sell_price: int | None
class Config:
from_attributes = True

View File

@@ -0,0 +1,15 @@
from pydantic import BaseModel
class OwnerUpdate(BaseModel):
full_name: str | None = None
phone_number: str | None = None
email: str | None = None
occupation: str | None = None
annual_income_range: str | None = None
willing_to_rent: bool | None = None
desired_rent_price: int | None = None
willing_to_sell: bool | None = None
desired_sell_price: int | None = None

View File

@@ -0,0 +1,26 @@
from pydantic import BaseModel
from datetime import date
class PropertyCreate(BaseModel):
property_type: str
built_up_area: float
bedrooms: int
bathrooms: int
purchase_date: date
purchase_price: float
sale_listing_date: date | None = None
sale_asking_price: float | None = None
last_renovation_date: date | None = None
renovation_description: str | None = None
roof_repair_date: date | None = None
roof_condition: str
available_for_rent: bool = False
expected_rent: float | None = None
rental_available_date: date | None = None

View File

@@ -1,172 +0,0 @@
from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
# -----------------------------
# Owner Response Schema
# -----------------------------
class OwnerResponse(BaseModel):
owner_id: str = Field(..., example="OWN_9001")
full_name: str = Field(..., example="Michael Anderson")
email: Optional[str] = Field(None, example="michael.anderson@email.com")
phone: Optional[str] = Field(None, example="+14155552671")
entity_type: str = Field(..., example="Individual")
mailing_address: Optional[str] = Field(
None,
example="742 Evergreen Terrace, San Diego, CA 92101"
)
credit_score_est: Optional[int] = Field(None, ge=300, le=850, example=780)
income_bracket: Optional[str] = Field(None, example="$100k+")
net_worth_est: Optional[int] = Field(None, example=1250000)
portfolio_size: Optional[int] = Field(None, example=3)
min_price_expectation: Optional[int] = Field(None, example=650000)
preferred_close_days: Optional[int] = Field(None, example=30)
urgency_score: Optional[int] = Field(None, ge=0, le=100, example=72)
is_absentee: Optional[bool] = Field(None, example=True)
willing_to_sell: Optional[bool] = Field(None, example=True)
willing_to_partner: Optional[bool] = Field(None, example=False)
# ⚠ Recommended: Do not expose in public APIs
tax_id_hash: Optional[str] = Field(
None,
example="HASHX9921",
description="Hashed tax identifier (masked)"
)
class Config:
from_attributes = True
# -----------------------------
# Property Response Schema
# -----------------------------
class PropertyResponse(BaseModel):
property_id: str = Field(..., example="PROP_1001")
internal_asset_code: str = Field(..., example="ASSET-LA-7782")
structure_type: str = Field(..., example="SingleFamily")
listing_status: str = Field(..., example="ForSale")
occupancy_status: str = Field(..., example="OwnerOccupied")
property_grade: str = Field(..., example="A")
energy_rating: Optional[str] = Field(None, example="B+")
year_built: int = Field(..., example=2006)
floors_count: int = Field(..., example=2)
bedrooms: int = Field(..., example=4)
bathrooms: int = Field(..., example=3)
total_built_sqft: int = Field(..., example=2480)
lot_size_sqft: Optional[int] = Field(None, example=6200)
garage_spaces: Optional[int] = Field(None, example=2)
purchase_price: Optional[int] = Field(None, example=590000)
expected_sale_price: Optional[int] = Field(None, example=740000)
market_value_est: Optional[int] = Field(None, example=685000)
current_rent: Optional[int] = Field(None, example=0)
rental_yield_percent: Optional[float] = Field(None, example=6.2)
vacancy_days: Optional[int] = Field(None, example=0)
tenant_present: Optional[bool] = Field(None, example=False)
# Structural / Condition
exterior_condition: Optional[str] = Field(None, example="Good")
foundation_type: Optional[str] = Field(None, example="Slab")
roof_type: Optional[str] = Field(None, example="Gable")
roof_material: Optional[str] = Field(None, example="Asphalt Shingle")
roof_condition: Optional[str] = Field(None, example="Good")
roof_pitch: Optional[str] = Field(None, example="Medium")
roof_age_years: Optional[int] = Field(None, example=7)
siding_material: Optional[str] = Field(None, example="Hardie Board")
gutter_status: Optional[str] = Field(None, example="Functional")
hvac_type: Optional[str] = Field(None, example="Central")
electric_type: Optional[str] = Field(None, example="Copper")
plumbing_type: Optional[str] = Field(None, example="PEX")
solar_installed: Optional[bool] = Field(None, example=False)
# Risk Indicators
mold_risk_level: Optional[str] = Field(None, example="Low")
termite_risk_level: Optional[str] = Field(None, example="Low")
structural_risk_level: Optional[str] = Field(None, example="Low")
fire_damage_flag: Optional[bool] = Field(None, example=False)
water_damage_flag: Optional[bool] = Field(None, example=False)
# Timestamps
created_at: Optional[datetime] = Field(
None,
example="2026-01-29T16:43:44.285Z"
)
updated_at: Optional[datetime] = Field(
None,
example="2026-01-29T16:43:44.285Z"
)
class Config:
from_attributes = True
# -----------------------------
# Final Nearest Asset Response
# -----------------------------
class NearestAssetResponse(BaseModel):
owner: OwnerResponse
property: PropertyResponse
distanceMeters: float = Field(..., example=342.55)

View File

@@ -0,0 +1,33 @@
from pydantic import BaseModel
from datetime import date
from app.schemas.owner_schema import OwnerResponse
class PropertyResponse(BaseModel):
id: int
property_type: str
built_up_area: float
bedrooms: int
bathrooms: int
purchase_date: date
purchase_price: float
sale_listing_date: date | None
sale_asking_price: float | None
last_renovation_date: date | None
renovation_description: str | None
roof_repair_date: date | None
roof_condition: str
available_for_rent: bool
expected_rent: float | None
rental_available_date: date | None
owner: OwnerResponse
class Config:
from_attributes = True

View File

@@ -0,0 +1,8 @@
from pydantic import BaseModel
from app.schemas.owner_update_schema import OwnerUpdate
from app.schemas.property_update_schema import PropertyUpdate
class PropertyOwnerUpdateRequest(BaseModel):
owner: OwnerUpdate | None = None
property: PropertyUpdate | None = None

View File

@@ -0,0 +1,26 @@
from pydantic import BaseModel
from datetime import date
class PropertyUpdate(BaseModel):
property_type: str | None = None
built_up_area: float | None = None
bedrooms: int | None = None
bathrooms: int | None = None
purchase_date: date | None = None
purchase_price: float | None = None
sale_listing_date: date | None = None
sale_asking_price: float | None = None
last_renovation_date: date | None = None
renovation_description: str | None = None
roof_repair_date: date | None = None
roof_condition: str | None = None
available_for_rent: bool | None = None
expected_rent: float | None = None
rental_available_date: date | None = None