Skip to content

Commit

Permalink
docs: add images
Browse files Browse the repository at this point in the history
  • Loading branch information
leandcesar committed Mar 4, 2023
1 parent c31a54d commit 518ed50
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 9 deletions.
52 changes: 48 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,64 @@ Example usage
List slots from free ranges (dates and times without events, available for scheduling)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. raw:: html

<h1 align="center">
<img src="https://github.com/leandcesar/google-calendar-simple-api-slots/blob/main/docs/images/example_1.png?raw=true" alt="List slots from free ranges"/>
</h1>

.. code-block:: python
from gcsa_slots.google_calendar import GoogleCalendar
calendar = GoogleCalendar("[email protected]")
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

<h1 align="center">
<img src="https://github.com/leandcesar/google-calendar-simple-api-slots/blob/main/docs/images/example_2.png?raw=true" alt="List slots from free ranges"/>
</h1>

.. code-block:: python
from gcsa_slots.google_calendar import GoogleCalendar
calendar = GoogleCalendar("[email protected]")
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -50,11 +88,11 @@ List slots specifying time range, slot interval, max events per slot and calenda
calendar = GoogleCalendar("[email protected]")
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,
):
Expand All @@ -69,11 +107,17 @@ Create event in first available slot
from gcsa_slots.google_calendar import GoogleCalendar
calendar = GoogleCalendar("[email protected]")
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

<h1 align="center">
<img src="https://github.com/leandcesar/google-calendar-simple-api-slots/blob/main/docs/images/example_3.png?raw=true" alt="List slots from free ranges"/>
</h1>


.. _`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
Binary file added docs/images/example_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/example_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/example_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions gcsa_slots/slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<Slot {}>'.format(self.__str__())
return f"<Slot {self.__str__()}>"

def __eq__(self, other):
return (
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
author="Leandro César Cassimiro",
author_email="[email protected]",
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.*"]),
Expand Down

0 comments on commit 518ed50

Please sign in to comment.