From 270d05195b851d4eb5e42f62838083e3a429f2f4 Mon Sep 17 00:00:00 2001 From: juftin Date: Fri, 1 Sep 2023 17:30:00 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20goingtocamp=20keep=20booking=20u?= =?UTF-8?q?rl=20the=20same?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{gtc_api_responses.py => goingtocamp.py} | 24 +++++++++++--- .../going_to_camp/going_to_camp_provider.py | 33 +++++++++++-------- 2 files changed, 40 insertions(+), 17 deletions(-) rename camply/containers/{gtc_api_responses.py => goingtocamp.py} (81%) diff --git a/camply/containers/gtc_api_responses.py b/camply/containers/goingtocamp.py similarity index 81% rename from camply/containers/gtc_api_responses.py rename to camply/containers/goingtocamp.py index e03649b9..12233245 100644 --- a/camply/containers/gtc_api_responses.py +++ b/camply/containers/goingtocamp.py @@ -40,9 +40,9 @@ class AvailabilityResponse(CamplyModel): mapLinkAvailabilities: Dict[str, Any] = {} -class SearchFilter(CamplyModel): +class ParamsBaseModel(CamplyModel): """ - /api/availability/map: API Filter + API and Booking URL Params """ mapId: int @@ -51,9 +51,25 @@ class SearchFilter(CamplyModel): startDate: str endDate: str isReserving: bool - getDailyAvailability: bool partySize: int - numEquipment: int + + +class SearchFilter(ParamsBaseModel): + """ + /api/availability/map: API Filter + """ + equipmentCategoryId: Optional[int] = None filterData: List[Any] = [] subEquipmentCategoryId: Optional[int] = None + numEquipment: int + getDailyAvailability: bool + + +class BookingUrlParams(ParamsBaseModel): + """ + Booking URL Params + """ + + equipmentId: Optional[int] = None + subEquipmentId: Optional[int] = None diff --git a/camply/providers/going_to_camp/going_to_camp_provider.py b/camply/providers/going_to_camp/going_to_camp_provider.py index 155e690f..7222b5ff 100644 --- a/camply/providers/going_to_camp/going_to_camp_provider.py +++ b/camply/providers/going_to_camp/going_to_camp_provider.py @@ -15,8 +15,9 @@ from camply.containers import AvailableResource, CampgroundFacility, RecreationArea from camply.containers.base_container import GoingToCampEquipment -from camply.containers.gtc_api_responses import ( +from camply.containers.goingtocamp import ( AvailabilityResponse, + BookingUrlParams, ResourceAvailabilityUnit, ResourceLocation, SearchFilter, @@ -242,18 +243,24 @@ def get_reservation_link( if not sub_equipment_id: sub_equipment_id = "" url = f"https://{rec_area_domain_name}/create-booking/results" - query_params = { - "mapId": map_id, - "bookingCategoryId": 0, - "startDate": start_date.isoformat(), - "endDate": end_date.isoformat(), - "isReserving": True, - "equipmentId": equipment_id, - "subEquipmentId": sub_equipment_id, - "partySize": party_size, - "resourceLocationId": resource_location_id, - } - booking_url = url + "?" + urlencode(query_params) + if sub_equipment_id in (None, ""): + sub_equipment_id = NON_GROUP_EQUIPMENT + query_params = BookingUrlParams( + mapId=map_id, + bookingCategoryId=0, + startDate=start_date.isoformat(), + endDate=end_date.isoformat(), + isReserving=True, + equipmentId=equipment_id, + subEquipmentId=sub_equipment_id, + partySize=party_size, + resourceLocationId=resource_location_id, + ) + booking_url = ( + url + + "?" + + urlencode(query_params.dict(exclude_unset=True, exclude_none=True)) + ) return booking_url def find_facilities_per_recreation_area(