diff --git a/README.rst b/README.rst index 595cf01..4c183ce 100644 --- a/README.rst +++ b/README.rst @@ -19,26 +19,64 @@ Example usage List slots from free ranges (dates and times without events, available for scheduling) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. raw:: html + +

+ List slots from free ranges +

+ .. code-block:: python from gcsa_slots.google_calendar import GoogleCalendar calendar = GoogleCalendar("your_email@gmail.com") - for slot in calendar.get_slots(): + for slot in calendar.get_slots(60): # 60 minutes print(slot) + # 2023-03-06 09:00:00-03:00 - 2023-03-06 10:00:00-03:00 + # 2023-03-06 11:00:00-03:00 - 2023-03-06 12:00:00-03:00 + # 2023-03-06 14:00:00-03:00 - 2023-03-06 15:00:00-03:00 + # 2023-03-06 15:00:00-03:00 - 2023-03-06 16:00:00-03:00 + # 2023-03-07 09:00:00-03:00 - 2023-03-07 10:00:00-03:00 + # 2023-03-07 10:00:00-03:00 - 2023-03-07 11:00:00-03:00 + # 2023-03-07 11:00:00-03:00 - 2023-03-07 12:00:00-03:00 + # 2023-03-08 09:00:00-03:00 - 2023-03-08 10:00:00-03:00 + # 2023-03-08 10:00:00-03:00 - 2023-03-08 11:00:00-03:00 + # 2023-03-08 14:00:00-03:00 - 2023-03-08 15:00:00-03:00 + # 2023-03-08 15:00:00-03:00 - 2023-03-08 16:00:00-03:00 + # ... + List slots from slot-event ranges (an event that determines availability for scheduling) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. raw:: html + +

+ List slots from free ranges +

+ .. code-block:: python from gcsa_slots.google_calendar import GoogleCalendar calendar = GoogleCalendar("your_email@gmail.com") - for slot in calendar.get_slots(slot_summary="Free"): + for slot in calendar.get_slots(60, slot_summary="Free"): # 60 minutes print(slot) + # 2023-03-06 09:00:00-03:00 - 2023-03-06 10:00:00-03:00 + # 2023-03-06 11:00:00-03:00 - 2023-03-06 12:00:00-03:00 + # 2023-03-06 14:00:00-03:00 - 2023-03-06 15:00:00-03:00 + # 2023-03-06 15:00:00-03:00 - 2023-03-06 16:00:00-03:00 + # 2023-03-07 09:00:00-03:00 - 2023-03-07 10:00:00-03:00 + # 2023-03-07 10:00:00-03:00 - 2023-03-07 11:00:00-03:00 + # 2023-03-07 11:00:00-03:00 - 2023-03-07 12:00:00-03:00 + # 2023-03-08 09:00:00-03:00 - 2023-03-08 10:00:00-03:00 + # 2023-03-08 10:00:00-03:00 - 2023-03-08 11:00:00-03:00 + # 2023-03-08 14:00:00-03:00 - 2023-03-08 15:00:00-03:00 + # 2023-03-08 15:00:00-03:00 - 2023-03-08 16:00:00-03:00 + # ... + List slots specifying time range, slot interval, max events per slot and calendar ID ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -50,11 +88,11 @@ List slots specifying time range, slot interval, max events per slot and calenda calendar = GoogleCalendar("your_email@gmail.com") calendar_id = "your calendar id" for slot in calendar.get_slots( + 45, slot_summary="fReE", case_sensitive=False, time_min=datetime(2023, 3, 6), time_max=datetime(2023, 3, 7), - slot_duration=90, events_per_slot=3, calendar_id=calendar_id, ): @@ -69,11 +107,17 @@ Create event in first available slot from gcsa_slots.google_calendar import GoogleCalendar calendar = GoogleCalendar("your_email@gmail.com") - slots = calendar.get_slots() + slots = calendar.get_slots(90, slot_summary="Free") slot = next(slots) slot.summary = "This is a test!" calendar.add_event(slot) +.. raw:: html + +

+ List slots from free ranges +

+ .. _`Google Calendar Simple API`: https://github.com/kuzmoyev/google-calendar-simple-api .. _`Getting started page`: https://google-calendar-simple-api.readthedocs.io/en/latest/getting_started.html diff --git a/docs/images/example_1.png b/docs/images/example_1.png new file mode 100644 index 0000000..484865d Binary files /dev/null and b/docs/images/example_1.png differ diff --git a/docs/images/example_2.png b/docs/images/example_2.png new file mode 100644 index 0000000..220a55e Binary files /dev/null and b/docs/images/example_2.png differ diff --git a/docs/images/example_3.png b/docs/images/example_3.png new file mode 100644 index 0000000..548c7d8 Binary files /dev/null and b/docs/images/example_3.png differ diff --git a/gcsa_slots/slots.py b/gcsa_slots/slots.py index 610cb4b..434fa51 100644 --- a/gcsa_slots/slots.py +++ b/gcsa_slots/slots.py @@ -26,10 +26,10 @@ def __init__( super().__init__(summary, start, end, timezone=timezone, **kwargs) def __str__(self): - return '{} - {}'.format(self.start, self.end) + return f"{self.start} - {self.end}" def __repr__(self): - return ''.format(self.__str__()) + return f"" def __eq__(self, other): return ( @@ -46,8 +46,8 @@ class SlotsService(EventsService): def get_slots( self, + slot_duration: int, # in minutes slot_summary: str = None, - slot_duration: Union[int, timedelta] = 60, # in minutes time_min: Union[date, datetime, BeautifulDate] = datetime.utcnow(), time_max: Union[date, datetime, BeautifulDate] = datetime.utcnow() + timedelta(days=7), calendar_id: str = None, @@ -57,8 +57,8 @@ def get_slots( **kwargs, ) -> Iterable[Slot]: kwargs.pop("query", None) - slots = [] + slots = [] if slot_summary: for event in self.get_events( time_min=time_min, diff --git a/setup.py b/setup.py index 4e3c71f..cbc342d 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ author="Leandro César Cassimiro", author_email="ccleandroc@gmail.com", url="https://github.com/leandcesar/google-calendar-simple-api-slots", - version="0.1.0", + version="0.1.1", license="MIT", python_requires=">=3.7", packages=find_packages(include=["gcsa_slots", "gcsa_slots.*"]),