Skip to content
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
1 change: 1 addition & 0 deletions camply/containers/gtc_api_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ class ResourceLocation(CamplyModel):
resource_location_id: Optional[int]
resource_location_name: str
region_name: str
root_map_id: Optional[int] = None
10 changes: 2 additions & 8 deletions camply/providers/going_to_camp/going_to_camp_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,13 @@
logger.error(f"Recreation area '{rec_area_id}' does not exist.")
sys.exit(1)

self.campground_details = {}
api_response = self._api_request(rec_area_id, "LIST_CAMPGROUNDS")

filtered_facilities = self._filter_facilities_responses(
rec_area_id, facilities=api_response
)

campgrounds = []
# Fetch campgrounds details for all facilities
for camp_details in self._api_request(rec_area_id, "CAMP_DETAILS"):
self.campground_details[camp_details["resourceLocationId"]] = camp_details

# If a search string is provided, make sure every facility name contains
# the search string
Expand Down Expand Up @@ -338,7 +334,7 @@
"User-Agent": UserAgent(browsers=["chrome"]).random,
"Accept-Language": "en-US,en;q=0.9",
}
response = self.session.get(url=url, headers=headers, params=params, timeout=30)

Check failure on line 337 in camply/providers/going_to_camp/going_to_camp_provider.py

View workflow job for this annotation

GitHub Actions / test (Python 3.12, 3.12)

in _api_request
if response.ok is False:
error_message = f"Receiving bad data from GoingToCamp API: status_code: {response.status_code}: {response.text}"
logger.error(error_message)
Expand Down Expand Up @@ -387,6 +383,7 @@
resource_categories=facil.get("resourceCategoryIds"),
resource_location_id=facil.get("resourceLocationId"),
resource_location_name=location_name,
root_map_id=facil.get("rootMapId"),
)
except ValidationError as ve:
logger.error("That doesn't look like a valid Campground Facility")
Expand Down Expand Up @@ -424,10 +421,7 @@
-------
Tuple[dict, CampgroundFacility]
"""
self.campground_details[facility.resource_location_id]
facility.id = _fetch_nested_key(
self.campground_details, facility.resource_location_id, "mapId"
)
facility.id = facility.root_map_id
if facility.region_name:
formatted_recreation_area = (
f"{rec_area.recreation_area}, {facility.region_name}"
Expand All @@ -445,7 +439,7 @@
return facility, campground_facility

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

Check failure on line 442 in camply/providers/going_to_camp/going_to_camp_provider.py

View workflow job for this annotation

GitHub Actions / test (Python 3.12, 3.12)

in _find_matching_resources
availability_details = {
search_filter["mapId"]: results["resourceAvailabilities"]
}
Expand Down Expand Up @@ -519,7 +513,7 @@
if equipment_type_id:
search_filter["subEquipmentCategoryId"] = equipment_type_id

resources, additional_resources = self._find_matching_resources(

Check failure on line 516 in camply/providers/going_to_camp/going_to_camp_provider.py

View workflow job for this annotation

GitHub Actions / test (Python 3.12, 3.12)

in list_site_availability
campground.recreation_area_id, search_filter
)

Expand Down
Loading