multiple resource id support
This commit is contained in:
parent
a62cb344b4
commit
4f4046e4a0
2 changed files with 19 additions and 7 deletions
24
main.py
24
main.py
|
|
@ -7,7 +7,7 @@ from auth.session import AnnySession
|
|||
from booking.client import BookingClient
|
||||
from utils.helpers import get_future_datetime
|
||||
import pytz
|
||||
from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES
|
||||
from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES, RESOURCE_IDS
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -48,15 +48,25 @@ def main():
|
|||
start = get_future_datetime(hour=time_["start"])
|
||||
end = get_future_datetime(hour=time_["end"])
|
||||
|
||||
# maybe add if reservation fails try next id and if everything fails do ^
|
||||
|
||||
for seat_id in RESOURCE_IDS:
|
||||
resource_id = seat_id
|
||||
reservation_success = booking.reserve(resource_id, start, end)
|
||||
if reservation_success:
|
||||
return True
|
||||
|
||||
if RESOURCE_ID:
|
||||
resource_id = RESOURCE_ID
|
||||
reservation_success = booking.reserve(resource_id, start, end)
|
||||
if reservation_success:
|
||||
return True
|
||||
resource_id = booking.find_available_resource(start, end)
|
||||
reservation_success = booking.reserve(resource_id, start, end)
|
||||
if reservation_success:
|
||||
return True
|
||||
else:
|
||||
resource_id = booking.find_available_resource(start, end)
|
||||
|
||||
if resource_id:
|
||||
booking.reserve(resource_id, start, end)
|
||||
else:
|
||||
print("⚠️ No available slots found.")
|
||||
print("⚠️ No available slots found. ( or other error )")
|
||||
except Exception as e:
|
||||
print(f"❌ Error booking slot {time_['start']}-{time_['end']}: {e}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue