Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search on Recreation.gov for permits #281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions camply/config/api_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ class RIDBConfig:
CAMPGROUND_FACILITY_FIELD_QUALIFIER: str = "Campground"
TICKET_FACILITY_FIELD_QUALIFIER: str = "Ticket Facility"
TIMED_ENTRY_FACILITY_FIELD_QUALIFIER: str = "Timed Entry"
PERMIT_FACILITY_FIELD_QUALIFIER: str = "Permit"
# RECREATION AREA FIELDS
REC_AREA_API_PATH: str = "recareas"
# CAMPSITE DETAILS
CAMPSITE_API_PATH: str = "campsites"
# TOUR DETAILS
TOUR_API_PATH: str = "tours"
# PERMIT ENTRANCE DETAILS
PERMIT_ENTRANCE_API_PATH: str = "permitentrances"


class RecreationBookingConfig:
Expand Down
72 changes: 71 additions & 1 deletion camply/containers/api_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,78 @@ class RecDotGovSearchResponse(CamplyModel):
Parent Response from Search Results
"""

results: List[RecDotGovSearchResult]
results: Optional[List[RecDotGovSearchResult]]
size: int
spelling_autocorrected: Any
start: int
total: int


class RecDotGovPermitMapping(CamplyModel):
day_use_permit_ids: List[str]
early_access_permit_ids: List[str]
hunting_permit_ids: List[str]
itinerary_permit_ids: List[str]
land_permit_ids: List[str]
lottery_permit_ids: List[str]
vehicle_permit_ids: List[str]
water_permit_ids: List[str]


class RecDotGovPermitMappingResponse(CamplyModel):
payload: RecDotGovPermitMapping


class _PermitEntranceAttribute(CamplyModel):
AttributeID: Optional[int]
AttributeName: str
AttributeValue: str


class _PermitEntranceZone(CamplyModel):
PermitEntranceZoneID: int
Zone: str


class PermitEntranceResponse(CoreRecDotGovResponse):
"""
https://ridb.recreation.gov/api/v1/permitentrances/<PERMIT ENTRANCE ID>
"""

PermitEntranceID: int
FacilityID: int
PermitEntranceName: str
PermitEntranceDescription: str
District: str
Town: str
PermitEntranceAccessible: bool
Longitude: float
Latitude: float
CreatedDate: datetime.date
LastUpdatedDate: datetime.date
ATTRIBUTES: List[_PermitEntranceAttribute]
ZONES: List[_PermitEntranceZone]

def __str__(self) -> str:
"""
String Representation
"""
return f"{self.PermitEntranceName} (#{self.PermitEntranceID})"


class PermitEntranceForFacilityResponse(CoreRecDotGovResponse):
"""
https://ridb.recreation.gov/api/v1/facilities/<FACILITY ID>/permitentrances
"""
RECDATA: List[PermitEntranceResponse]
METADATA: Dict[str, Dict[str, Union[int, str]]]


class PermitAvailability(CamplyModel):
total: int
remaining: int
is_walkup: bool


class PermitMonthlyAvailabilityResponse(CamplyModel):
payload: Dict[datetime.date, Dict[int, PermitAvailability]]
3 changes: 3 additions & 0 deletions camply/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
RecreationDotGovTicket,
RecreationDotGovTimedEntry,
)
from .recreation_dot_gov.recdotgov_permits import RecreationDotGovPermit
from .usedirect.variations import (
AlabamaStateParks,
ArizonaStateParks,
Expand All @@ -36,6 +37,7 @@
RecreationDotGovDailyTimedEntry,
RecreationDotGovTicket,
RecreationDotGovTimedEntry,
RecreationDotGovPermit,
Yellowstone,
ReserveCalifornia,
NorthernTerritory,
Expand All @@ -60,6 +62,7 @@
"RecreationDotGovDailyTimedEntry",
"RecreationDotGovTicket",
"RecreationDotGovTimedEntry",
"RecreationDotGovPermit",
"Yellowstone",
"ReserveCalifornia",
"NorthernTerritory",
Expand Down
Loading