Skip to content

Commit

Permalink
🐛 goingtocamp keep booking url the same
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Feb 22, 2024
1 parent f7e1e88 commit 270d051
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
33 changes: 20 additions & 13 deletions camply/providers/going_to_camp/going_to_camp_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 270d051

Please sign in to comment.