diff --git a/booking/client.py b/booking/client.py index f0dcc7d..da2f84f 100644 --- a/booking/client.py +++ b/booking/client.py @@ -38,11 +38,15 @@ class BookingClient: except (ValueError, JSONDecodeError): print(f"❌ Invalid JSON response when fetching resources: {response.text[:200]}") return None - return resources[0]['id'] if resources else None + return resources[-1]['id'] if resources else None def reserve(self, resource_id, start, end): booking = self.session.post( - f"{BOOKING_API_BASE}/order/bookings?include=customer&stateless=1", + f"{BOOKING_API_BASE}/order/bookings", + params={ + 'stateless': '1', + 'include': 'customer,voucher,bookings.booking_add_ons.add_on.cover_image,bookings.sub_bookings.resource,bookings.sub_bookings.service,bookings.customer,bookings.service.custom_forms.custom_fields,bookings.service.add_ons.cover_image,bookings.service.add_ons.group,bookings.cancellation_policy,bookings.resource.cover_image,bookings.resource.parent,bookings.resource.location,bookings.resource.category,bookings.reminders,bookings.booking_series,bookings.sequenced_bookings.resource,bookings.sequenced_bookings.service,bookings.sequenced_bookings.service.add_ons.cover_image,bookings.sequenced_bookings.service.add_ons.group,bookings.booking_participants,sub_orders.bookings,sub_orders.organization.legal_documents' + }, json={ "resource_id": [resource_id], "service_id": {SERVICE_ID: 1}, diff --git a/config/constants.py b/config/constants.py index 106d817..b43c6ee 100644 --- a/config/constants.py +++ b/config/constants.py @@ -4,7 +4,7 @@ BOOKING_API_BASE = "https://b.anny.eu/api/v1" CHECKOUT_FORM_API = "https://b.anny.eu/api/ui/checkout-form" RESOURCE_URL = f"{BOOKING_API_BASE}/resources/1-lehrbuchsammlung-eg-und-1-og/children" SERVICE_ID = "449" -RESOURCE_ID = "5960" # Will be set dynamically if None, else use the given ID +RESOURCE_ID = None # "5957" # Will be set dynamically if None, else use the given ID TIMEZONE = "Europe/Berlin" SSO_PROVIDER = "kit" # Available: kit (add more in auth/providers/) diff --git a/main.py b/main.py index 0d21451..ca2a4a4 100644 --- a/main.py +++ b/main.py @@ -42,16 +42,16 @@ def main(): times = [ { - 'start': '13:00:00', - 'end': '18:00:00' + 'start': '14:00:00', + 'end': '19:00:00' }, { - 'start': '08:00:00', - 'end': '12:00:00' + 'start': '09:00:00', + 'end': '13:00:00' }, { - 'start': '19:00:00', - 'end': '21:00:00' + 'start': '20:00:00', + 'end': '24:00:00' }, ]