Update booking times and adjust resource ID handling for improved flexibility

This commit is contained in:
b267a 2026-01-23 09:03:20 +01:00
parent c4cef0d9b5
commit fa6e0fd853
3 changed files with 13 additions and 9 deletions

View file

@ -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},

View file

@ -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/)

12
main.py
View file

@ -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'
},
]