From 73dbbceb7566c128bb661401bd835a8cb36f38b2 Mon Sep 17 00:00:00 2001 From: Maciej Buchert Date: Tue, 15 May 2018 21:37:12 +0200 Subject: [PATCH 1/5] added new function I added function that return calendars - names, guid, url and more --- pyicloud/services/calendar.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pyicloud/services/calendar.py b/pyicloud/services/calendar.py index 49cf118..4e42a08 100644 --- a/pyicloud/services/calendar.py +++ b/pyicloud/services/calendar.py @@ -19,6 +19,7 @@ class CalendarService(object): self._calendar_event_detail_url = '%s/eventdetail' % ( self._calendar_endpoint, ) + self._calendars = '%s/startup' % self._calendar_endpoint def get_event_detail(self, pguid, guid): """ @@ -60,3 +61,22 @@ class CalendarService(object): """ self.refresh_client(from_dt, to_dt) return self.response['Event'] + + def calendars(self): + """ + Retrieves calendars for this month + """ + today = datetime.today() + first_day, last_day = monthrange(today.year, today.month) + from_dt = datetime(today.year, today.month, first_day) + to_dt = datetime(today.year, today.month, last_day) + params = dict(self.params) + params.update({ + 'lang': 'en-us', + 'usertz': get_localzone().zone, + 'startDate': from_dt.strftime('%Y-%m-%d'), + 'endDate': to_dt.strftime('%Y-%m-%d') + }) + req = self.session.get(self._calendars, params=params) + self.response = req.json() + return self.response['Collection'] From abbe2368125f6ae25b226c555e199c6bcd21889d Mon Sep 17 00:00:00 2001 From: Maciej Buchert Date: Tue, 15 May 2018 22:15:41 +0200 Subject: [PATCH 2/5] Update calendar.py --- pyicloud/services/calendar.py | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pyicloud/services/calendar.py b/pyicloud/services/calendar.py index 4e42a08..f10990a 100644 --- a/pyicloud/services/calendar.py +++ b/pyicloud/services/calendar.py @@ -62,21 +62,21 @@ class CalendarService(object): self.refresh_client(from_dt, to_dt) return self.response['Event'] - def calendars(self): - """ - Retrieves calendars for this month - """ - today = datetime.today() - first_day, last_day = monthrange(today.year, today.month) - from_dt = datetime(today.year, today.month, first_day) - to_dt = datetime(today.year, today.month, last_day) - params = dict(self.params) - params.update({ - 'lang': 'en-us', - 'usertz': get_localzone().zone, - 'startDate': from_dt.strftime('%Y-%m-%d'), - 'endDate': to_dt.strftime('%Y-%m-%d') - }) - req = self.session.get(self._calendars, params=params) - self.response = req.json() - return self.response['Collection'] + def calendars(self): + """ + Retrieves calendars for this month + """ + today = datetime.today() + first_day, last_day = monthrange(today.year, today.month) + from_dt = datetime(today.year, today.month, first_day) + to_dt = datetime(today.year, today.month, last_day) + params = dict(self.params) + params.update({ + 'lang': 'en-us', + 'usertz': get_localzone().zone, + 'startDate': from_dt.strftime('%Y-%m-%d'), + 'endDate': to_dt.strftime('%Y-%m-%d') + }) + req = self.session.get(self._calendars, params=params) + self.response = req.json() + return self.response['Collection'] From bbee61f566e22a20370dccdfd6433f6f56ce2b82 Mon Sep 17 00:00:00 2001 From: Maciej Buchert Date: Wed, 16 May 2018 06:10:06 +0200 Subject: [PATCH 3/5] Update calendar.py From 3e912d8ccb0f0c4b25ae49bea5b4f5dc49be6886 Mon Sep 17 00:00:00 2001 From: Maciej Buchert Date: Sun, 20 May 2018 17:22:50 +0200 Subject: [PATCH 4/5] Update calendar.py --- pyicloud/services/calendar.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pyicloud/services/calendar.py b/pyicloud/services/calendar.py index f10990a..774eea1 100644 --- a/pyicloud/services/calendar.py +++ b/pyicloud/services/calendar.py @@ -63,20 +63,20 @@ class CalendarService(object): return self.response['Event'] def calendars(self): - """ - Retrieves calendars for this month - """ - today = datetime.today() - first_day, last_day = monthrange(today.year, today.month) - from_dt = datetime(today.year, today.month, first_day) - to_dt = datetime(today.year, today.month, last_day) - params = dict(self.params) - params.update({ - 'lang': 'en-us', - 'usertz': get_localzone().zone, - 'startDate': from_dt.strftime('%Y-%m-%d'), - 'endDate': to_dt.strftime('%Y-%m-%d') - }) - req = self.session.get(self._calendars, params=params) - self.response = req.json() - return self.response['Collection'] + """ + Retrieves calendars for this month + """ + today = datetime.today() + first_day, last_day = monthrange(today.year, today.month) + from_dt = datetime(today.year, today.month, first_day) + to_dt = datetime(today.year, today.month, last_day) + params = dict(self.params) + params.update({ + 'lang': 'en-us', + 'usertz': get_localzone().zone, + 'startDate': from_dt.strftime('%Y-%m-%d'), + 'endDate': to_dt.strftime('%Y-%m-%d') + }) + req = self.session.get(self._calendars, params=params) + self.response = req.json() + return self.response['Collection'] From b7401940c7bfe9ccc869bd92d6639d468d7429d3 Mon Sep 17 00:00:00 2001 From: Maciej Buchert Date: Sun, 20 May 2018 17:27:38 +0200 Subject: [PATCH 5/5] Update calendar.py --- pyicloud/services/calendar.py | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pyicloud/services/calendar.py b/pyicloud/services/calendar.py index 774eea1..08cdd76 100644 --- a/pyicloud/services/calendar.py +++ b/pyicloud/services/calendar.py @@ -19,7 +19,7 @@ class CalendarService(object): self._calendar_event_detail_url = '%s/eventdetail' % ( self._calendar_endpoint, ) - self._calendars = '%s/startup' % self._calendar_endpoint + self._calendars = '%s/startup' % self._calendar_endpoint def get_event_detail(self, pguid, guid): """ @@ -63,20 +63,20 @@ class CalendarService(object): return self.response['Event'] def calendars(self): - """ - Retrieves calendars for this month - """ - today = datetime.today() - first_day, last_day = monthrange(today.year, today.month) - from_dt = datetime(today.year, today.month, first_day) - to_dt = datetime(today.year, today.month, last_day) - params = dict(self.params) - params.update({ - 'lang': 'en-us', - 'usertz': get_localzone().zone, - 'startDate': from_dt.strftime('%Y-%m-%d'), - 'endDate': to_dt.strftime('%Y-%m-%d') - }) - req = self.session.get(self._calendars, params=params) - self.response = req.json() - return self.response['Collection'] + """ + Retrieves calendars for this month + """ + today = datetime.today() + first_day, last_day = monthrange(today.year, today.month) + from_dt = datetime(today.year, today.month, first_day) + to_dt = datetime(today.year, today.month, last_day) + params = dict(self.params) + params.update({ + 'lang': 'en-us', + 'usertz': get_localzone().zone, + 'startDate': from_dt.strftime('%Y-%m-%d'), + 'endDate': to_dt.strftime('%Y-%m-%d') + }) + req = self.session.get(self._calendars, params=params) + self.response = req.json() + return self.response['Collection']