Adding a method for fetching a single event's details, which provides more information about an event, such as any notes ('description') about it.
This commit is contained in:
parent
79751fbbd1
commit
16163f4ccb
1 changed files with 15 additions and 0 deletions
|
@ -14,6 +14,7 @@ class CalendarService(object):
|
||||||
self._service_root = service_root
|
self._service_root = service_root
|
||||||
self._calendar_endpoint = '%s/ca' % self._service_root
|
self._calendar_endpoint = '%s/ca' % self._service_root
|
||||||
self._calendar_refresh_url = '%s/events' % self._calendar_endpoint
|
self._calendar_refresh_url = '%s/events' % self._calendar_endpoint
|
||||||
|
self._calendar_event_detail_url = '%s/eventdetail' % self._calendar_endpoint
|
||||||
|
|
||||||
def get_system_tz(self):
|
def get_system_tz(self):
|
||||||
"""
|
"""
|
||||||
|
@ -22,6 +23,20 @@ class CalendarService(object):
|
||||||
"""
|
"""
|
||||||
return '/'.join(os.readlink('/etc/localtime').split('/')[-2:])
|
return '/'.join(os.readlink('/etc/localtime').split('/')[-2:])
|
||||||
|
|
||||||
|
def get_event_detail(self, pguid, guid):
|
||||||
|
"""
|
||||||
|
Fetches a single event's details by specifying a pguid
|
||||||
|
(a calendar) and a guid (an event's ID).
|
||||||
|
"""
|
||||||
|
host = self._service_root.split('//')[1].split(':')[0]
|
||||||
|
self.session.headers.update({'host': host})
|
||||||
|
params = dict(self.params)
|
||||||
|
params.update({'lang': 'en-us', 'usertz': self.get_system_tz()})
|
||||||
|
url = '%s/%s/%s' % (self._calendar_event_detail_url, pguid, guid)
|
||||||
|
req = self.session.get(url, params=params)
|
||||||
|
self.response = req.json()
|
||||||
|
return self.response['Event'][0]
|
||||||
|
|
||||||
def refresh_client(self, from_dt=None, to_dt=None):
|
def refresh_client(self, from_dt=None, to_dt=None):
|
||||||
"""
|
"""
|
||||||
Refreshes the CalendarService endpoint, ensuring that the
|
Refreshes the CalendarService endpoint, ensuring that the
|
||||||
|
|
Loading…
Reference in a new issue