From 06d12f1442f8b16fb9808598b08f48ea66e9361d Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Sun, 25 Apr 2021 01:12:11 -0500 Subject: [PATCH] Minor calling/data formatting bugs. Should refactor --- gapi/apis/calendar_api/calendar_api.py | 9 +++++---- gapi/apis/calendar_api/models.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gapi/apis/calendar_api/calendar_api.py b/gapi/apis/calendar_api/calendar_api.py index 5bbf462..c735d26 100644 --- a/gapi/apis/calendar_api/calendar_api.py +++ b/gapi/apis/calendar_api/calendar_api.py @@ -76,8 +76,9 @@ class calendar_api(API): page_token = calendar_list.get("nextPageToken") return cl - def get_events(self, cal_id, **params): + def get_events(self, **params): """Return events with params""" + cal_id = params.pop("cal_id") service = self.service try: cal_id = self.ids[cal_id] @@ -103,11 +104,11 @@ class calendar_api(API): ): """Returns events in between the given time range""" if start_date is not None: - start_date = to_dateTime(start_date) + start_date = start_date.isoformat() if end_date is not None: - end_date = to_dateTime(end_date) + end_date = end_date.isoformat() - self.get_events(self, cal_id=cal_id, timeMin=start_date, timeMax=end_date) + yield from self.get_events(cal_id=cal_id, timeMin=start_date, timeMax=end_date) def get_event_by_id(self, cal_id, event_id): """Retrieves event from cal_id and event_id""" diff --git a/gapi/apis/calendar_api/models.py b/gapi/apis/calendar_api/models.py index 684f623..d62d235 100644 --- a/gapi/apis/calendar_api/models.py +++ b/gapi/apis/calendar_api/models.py @@ -151,7 +151,7 @@ class Calendar: if calendar_id in api.ids.keys(): self.name = calendar_id - self.calendar_id = self.api.ids[self.name] + self.id = self.api.ids[self.name] elif calendar_id in api.ids.values(): self.name = self.api.calendars[calendar_id]["summary"] self.id = calendar_id @@ -168,7 +168,7 @@ class Calendar: return ( Event(event_representation) for event_representation in self.api.get_events_in_range( - self.cal_id, start, end + self.id, start, end ) )