Skip to content

Commit

Permalink
🐛 Fix deleted 'rootmaps' endpoint (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
acaloiaro authored Apr 17, 2023
1 parent 3a1c10a commit adeffa2
Show file tree
Hide file tree
Showing 5 changed files with 5,707 additions and 7,094 deletions.
3 changes: 2 additions & 1 deletion camply/containers/gtc_api_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ResourceLocation(CamplyModel):
"""
/api/resourcelocation/rootmaps
/api/maps
"""

id: Optional[int]
Expand All @@ -17,3 +17,4 @@ class ResourceLocation(CamplyModel):
resource_categories: Optional[List[int]]
resource_location_id: Optional[int]
resource_location_name: str
region_name: str
37 changes: 20 additions & 17 deletions camply/providers/going_to_camp/going_to_camp_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
GROUP_SITE = -2147483643

ENDPOINTS = {
"CAMP_DETAILS": "https://{}/api/resourcelocation",
"CAMP_DETAILS": "https://{}/api/maps",
"DAILY_AVAILABILITY": "https://{}/api/availability/resourcedailyavailability",
"LIST_CAMPGROUNDS": "https://{}/api/resourcelocation/rootmaps",
"LIST_CAMPGROUNDS": "https://{}/api/resourceLocation",
"LIST_EQUIPMENT": "https://{}/api/equipment",
"LIST_RESOURCE_CATEGORY": "https://{}/api/resourcecategory",
"LIST_RESOURCE_STATUS": "https://{}/api/availability/resourcestatus",
Expand Down Expand Up @@ -437,21 +437,21 @@ def _filter_facilities_responses(
for facil in facilities:
try:
location_name = _fetch_nested_key(
facil, "resourceLocationLocalizedValues", "en-US"
facil, "localizedValues", 0, "fullName"
)
if not location_name:
location_name = _fetch_nested_key(
facil, "resourceLocationLocalizedValues", "en-CA"
)

park_alerts = _fetch_nested_key(
facil, "park_alerts", "en-US", 0, "messageTitle"
)
if not park_alerts:
_fetch_nested_key(facil, "park_alerts", "en-CA", 0, "messageTitle")
park_alerts = _fetch_nested_key(
facil, "park_alerts", "en-CA", 0, "messageTitle"
)

region_name = _fetch_nested_key(facil, "region")

facility = ResourceLocation(
id=facil.get("mapId"),
id=None,
region_name=region_name if region_name else "",
park_alerts=park_alerts,
rec_area_id=rec_area_id,
resource_categories=facil.get("resourceCategoryIds"),
Expand Down Expand Up @@ -494,16 +494,19 @@ def _process_facilities_responses(
-------
Tuple[dict, CampgroundFacility]
"""
details = self.campground_details[facility.resource_location_id]
region = _fetch_nested_key(details, "region")
facility_name = _fetch_nested_key(details, "localizedValues", 0, "fullName")
if region:
formatted_recreation_area = f"{rec_area.recreation_area}, {region}"
self.campground_details[facility.resource_location_id]
facility.id = _fetch_nested_key(
self.campground_details, facility.resource_location_id, "mapId"
)
if facility.region_name:
formatted_recreation_area = (
f"{rec_area.recreation_area}, {facility.region_name}"
)
else:
formatted_recreation_area = f"{rec_area.recreation_area}"

campground_facility = CampgroundFacility(
facility_name=facility_name,
facility_name=facility.resource_location_name,
recreation_area=formatted_recreation_area,
facility_id=facility.resource_location_id,
recreation_area_id=facility.rec_area_id,
Expand All @@ -513,7 +516,6 @@ def _process_facilities_responses(

def _find_matching_resources(self, rec_area_id: int, search_filter: Dict[str, any]):
results = self._api_request(rec_area_id, "MAPDATA", search_filter)

availability_details = {
search_filter["mapId"]: results["resourceAvailabilities"]
}
Expand Down Expand Up @@ -580,6 +582,7 @@ def list_site_availability(
"isReserving": True,
"getDailyAvailability": False,
"partySize": 1,
"numEquipment": 1,
"equipmentCategoryId": NON_GROUP_EQUIPMENT,
"filterData": [],
}
Expand Down
Loading

0 comments on commit adeffa2

Please sign in to comment.