Skip to content

Commit 6dca602

Browse files
author
Alejandro Casanovas
authored
Merge pull request O365#600 from qsollet/master
Added cancel_event method to calendar.py
2 parents efacbf9 + e138c12 commit 6dca602

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

O365/calendar.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,31 @@ def decline_event(self, comment=None, *, send_response=True):
15071507

15081508
return bool(response)
15091509

1510+
def cancel_event(self, comment=None, *, send_response=True):
1511+
""" Cancel the event
1512+
1513+
:param str comment: comment to add
1514+
:param bool send_response: whether or not to send response back
1515+
:return: Success / Failure
1516+
:rtype: bool
1517+
"""
1518+
if not self.object_id:
1519+
raise RuntimeError("Can't accept event that doesn't exist")
1520+
1521+
url = self.build_url(
1522+
self._endpoints.get('event').format(id=self.object_id))
1523+
url = url + '/cancel'
1524+
1525+
data = {}
1526+
if comment and isinstance(comment, str):
1527+
data[self._cc('comment')] = comment
1528+
if send_response is False:
1529+
data[self._cc('sendResponse')] = send_response
1530+
1531+
response = self.con.post(url, data=data or None)
1532+
1533+
return bool(response)
1534+
15101535
def get_body_text(self):
15111536
""" Parse the body html and returns the body text using bs4
15121537

0 commit comments

Comments
 (0)