HomeHarvest/homeharvest/core/scrapers/models.py

181 lines
4.0 KiB
Python
Raw Normal View History

from __future__ import annotations
2023-09-15 15:17:37 -07:00
from dataclasses import dataclass
from enum import Enum
2023-10-03 22:21:16 -07:00
from typing import Optional
2023-09-15 15:17:37 -07:00
2023-09-17 16:30:37 -07:00
class SiteName(Enum):
ZILLOW = "zillow"
REDFIN = "redfin"
REALTOR = "realtor.com"
@classmethod
def get_by_value(cls, value):
for item in cls:
if item.value == value:
return item
raise ValueError(f"{value} not found in {cls}")
2023-09-17 16:30:37 -07:00
2024-11-03 15:23:07 -08:00
class SearchPropertyType(Enum):
SINGLE_FAMILY = "single_family"
CONDOS = "condos"
CONDO_TOWNHOME_ROWHOME_COOP = "condo_townhome_rowhome_coop"
CONDO_TOWNHOME = "condo_townhome"
TOWNHOMES = "townhomes"
DUPLEX_TRIPLEX = "duplex_triplex"
FARM = "farm"
LAND = "land"
MULTI_FAMILY = "multi_family"
MOBILE = "mobile"
2023-09-15 15:17:37 -07:00
class ListingType(Enum):
2023-09-18 11:38:17 -07:00
FOR_SALE = "FOR_SALE"
FOR_RENT = "FOR_RENT"
PENDING = "PENDING"
2023-09-18 11:38:17 -07:00
SOLD = "SOLD"
2023-09-15 15:17:37 -07:00
2024-04-16 18:01:20 -07:00
@dataclass
class Agent:
name: str | None = None
phone: str | None = None
class PropertyType(Enum):
APARTMENT = "APARTMENT"
BUILDING = "BUILDING"
COMMERCIAL = "COMMERCIAL"
2024-06-12 15:34:34 -07:00
GOVERNMENT = "GOVERNMENT"
INDUSTRIAL = "INDUSTRIAL"
CONDO_TOWNHOME = "CONDO_TOWNHOME"
CONDO_TOWNHOME_ROWHOME_COOP = "CONDO_TOWNHOME_ROWHOME_COOP"
CONDO = "CONDO"
2024-05-12 21:12:12 -07:00
CONDOP = "CONDOP"
CONDOS = "CONDOS"
COOP = "COOP"
DUPLEX_TRIPLEX = "DUPLEX_TRIPLEX"
FARM = "FARM"
INVESTMENT = "INVESTMENT"
LAND = "LAND"
MOBILE = "MOBILE"
MULTI_FAMILY = "MULTI_FAMILY"
RENTAL = "RENTAL"
SINGLE_FAMILY = "SINGLE_FAMILY"
TOWNHOMES = "TOWNHOMES"
OTHER = "OTHER"
2023-09-15 15:17:37 -07:00
@dataclass
class Address:
full_line: str | None = None
2023-10-03 22:21:16 -07:00
street: str | None = None
unit: str | None = None
2023-09-19 19:13:20 -07:00
city: str | None = None
state: str | None = None
2023-10-03 22:21:16 -07:00
zip: str | None = None
2023-09-15 15:17:37 -07:00
@dataclass
2023-10-04 06:58:55 -07:00
class Description:
2023-11-24 11:41:46 -08:00
primary_photo: str | None = None
alt_photos: list[str] | None = None
style: PropertyType | None = None
2023-10-04 06:58:55 -07:00
beds: int | None = None
baths_full: int | None = None
baths_half: int | None = None
sqft: int | None = None
lot_sqft: int | None = None
sold_price: int | None = None
year_built: int | None = None
garage: float | None = None
stories: int | None = None
text: str | None = None
@dataclass
class AgentPhone: #: For documentation purposes only (at the moment)
number: str | None = None
type: str | None = None
primary: bool | None = None
ext: str | None = None
2024-04-16 12:55:44 -07:00
@dataclass
class Entity:
name: str
uuid: str | None = None
@dataclass
class Agent(Entity):
2024-08-23 10:47:45 -07:00
mls_set: str | None = None
nrds_id: str | None = None
phones: list[dict] | AgentPhone | None = None
email: str | None = None
href: str | None = None
@dataclass
class Office(Entity):
2024-08-23 10:54:43 -07:00
mls_set: str | None = None
email: str | None = None
href: str | None = None
phones: list[dict] | AgentPhone | None = None
@dataclass
class Broker(Entity):
pass
@dataclass
class Builder(Entity):
pass
@dataclass
class Advertisers:
agent: Agent | None = None
broker: Broker | None = None
builder: Builder | None = None
office: Office | None = None
2024-04-16 12:55:44 -07:00
2023-09-18 11:38:17 -07:00
@dataclass
class Property:
2023-10-04 06:58:55 -07:00
property_url: str
property_id: str
listing_id: str | None = None
2023-10-03 22:21:16 -07:00
mls: str | None = None
2023-09-15 16:03:17 -07:00
mls_id: str | None = None
2023-10-03 22:21:16 -07:00
status: str | None = None
2023-10-04 06:58:55 -07:00
address: Address | None = None
2023-10-03 22:21:16 -07:00
list_price: int | None = None
list_price_min: int | None = None
list_price_max: int | None = None
2023-10-03 22:21:16 -07:00
list_date: str | None = None
pending_date: str | None = None
2023-10-03 22:21:16 -07:00
last_sold_date: str | None = None
2023-10-04 06:58:55 -07:00
prc_sqft: int | None = None
new_construction: bool | None = None
2023-10-03 22:21:16 -07:00
hoa_fee: int | None = None
2023-10-09 09:00:36 -07:00
days_on_mls: int | None = None
2023-10-04 06:58:55 -07:00
description: Description | None = None
2023-10-03 22:21:16 -07:00
2023-09-19 19:13:20 -07:00
latitude: float | None = None
longitude: float | None = None
2023-10-03 22:21:16 -07:00
neighborhoods: Optional[str] = None
county: Optional[str] = None
fips_code: Optional[str] = None
2024-04-16 18:01:20 -07:00
nearby_schools: list[str] = None
2024-04-30 13:29:54 -07:00
assessed_value: int | None = None
estimated_value: int | None = None
advertisers: Advertisers | None = None