Skip to content

Commit

Permalink
feat(examples): add ClassFilter and ClassType to filter class bookings
Browse files Browse the repository at this point in the history
Add ClassFilter and ClassType imports to enable more specific filtering
of class bookings. Implement filters for day of week, start time, and
class type to enhance the flexibility of class retrieval.
  • Loading branch information
NodeJSmith committed Jan 4, 2025
1 parent 3747783 commit 0baa797
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions examples/class_bookings_examples.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
from datetime import datetime
from datetime import datetime, time
from getpass import getpass

from otf_api import Otf
from otf_api.filters import ClassFilter
from otf_api.models import ClassType
from otf_api.models.classes import DoW

USERNAME = os.getenv("OTF_EMAIL") or input("Enter your OTF email: ")
Expand All @@ -18,11 +20,14 @@ def main():

studio_uuids = [studio.studio_uuid for studio in studios.studios]

# To get upcoming classes you can call the `get_classes` method
# You can pass a list of studio_uuids or, if you want to get classes from your home studio, leave it empty
# this also takes a start date, end date, and limit - these are not sent to the API, they are used in the
# client to filter the results
classes = otf.get_classes(studio_uuids, day_of_week=[DoW.TUESDAY, DoW.THURSDAY, DoW.SATURDAY])
cf = ClassFilter(
day_of_week=[DoW.TUESDAY, DoW.THURSDAY],
start_time=time(9, 45),
class_type=ClassType.get_standard_class_types(),
)
cf2 = ClassFilter(day_of_week=DoW.SATURDAY, start_time=time(10, 30), class_type=ClassType.TREAD_50)

classes = otf.get_classes(studio_uuids=studio_uuids, filters=[cf, cf2])

print(classes.classes[0].model_dump_json(indent=4))

Expand Down

0 comments on commit 0baa797

Please sign in to comment.