diff --git a/src/otf_api/api.py b/src/otf_api/api.py index 116df4d..b76d924 100644 --- a/src/otf_api/api.py +++ b/src/otf_api/api.py @@ -408,7 +408,7 @@ def _check_for_booking_conflicts(self, otf_class: models.OtfClass) -> None: booking_uuid=booking.booking_uuid, ) - def cancel_booking(self, booking: str | models.Booking): + def cancel_booking(self, booking: str | models.Booking) -> None: """Cancel a booking by providing either the booking_uuid or the Booking object. Args: @@ -434,8 +434,6 @@ def cancel_booking(self, booking: str | models.Booking): f"Booking {booking_uuid} is already cancelled.", booking_uuid=booking_uuid ) - return - def get_bookings( self, start_date: date | str | None = None, @@ -494,17 +492,17 @@ def get_bookings( params = {"startDate": start_date, "endDate": end_date, "statuses": status_value} - bookings = self._default_request("GET", f"/member/members/{self.member_uuid}/bookings", params=params)["data"] + resp = self._default_request("GET", f"/member/members/{self.member_uuid}/bookings", params=params)["data"] # add studio details for each booking, instead of using the different studio model returned by this endpoint - studio_uuids = {b["class"]["studio"]["studioUUId"] for b in bookings} + studio_uuids = {b["class"]["studio"]["studioUUId"] for b in resp} studios = {studio_uuid: self.get_studio_detail(studio_uuid) for studio_uuid in studio_uuids} - for b in bookings: + for b in resp: b["class"]["studio"] = studios[b["class"]["studio"]["studioUUId"]] b["is_home_studio"] = b["class"]["studio"].studio_uuid == self.home_studio_uuid - bookings = [models.Booking(**b) for b in bookings] + bookings = [models.Booking(**b) for b in resp] bookings = sorted(bookings, key=lambda x: x.otf_class.starts_at) if exclude_cancelled: @@ -721,15 +719,10 @@ def get_studio_detail(self, studio_uuid: str | None = None) -> models.StudioDeta studio_uuid = studio_uuid or self.home_studio_uuid path = f"/mobile/v1/studios/{studio_uuid}" - # params = {"include": "locations"} - params = {} - - no_location_res = self._default_request("GET", path, params=params) - location_res = self._default_request("GET", path, params={"include": "locations"}) - assert no_location_res["data"] == location_res["data"] + res = self._default_request("GET", path) - return models.StudioDetail(**location_res["data"]) + return models.StudioDetail(**res["data"]) def get_studios_by_geo( self, latitude: float | None = None, longitude: float | None = None