Skip to content

Commit 586f12a

Browse files
Calendar API updates
1 parent 08d94f9 commit 586f12a

File tree

6 files changed

+84
-3
lines changed

6 files changed

+84
-3
lines changed

office365/calendar/event.py

+39-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,47 @@
11
from office365.mail.item import Item
2+
from office365.runtime.resource_path import ResourcePath
23

34

45
class Event(Item):
5-
"""An event in a calendar."""
6+
"""An event in a user calendar, or the default calendar of a Microsoft 365 group."""
67

78
@property
89
def id(self):
910
return self.properties.get("id", None)
11+
12+
@property
13+
def body_preview(self):
14+
"""
15+
The preview of the message associated with the event. It is in text format.
16+
:rtype: str or None
17+
"""
18+
return self.properties.get("bodyPreview", None)
19+
20+
@property
21+
def subject(self):
22+
"""
23+
The text of the event's subject line.
24+
:rtype: str or None
25+
"""
26+
return self.properties.get("subject", None)
27+
28+
@property
29+
def web_link(self):
30+
"""
31+
The URL to open the event in Outlook on the web.
32+
33+
Outlook on the web opens the event in the browser if you are signed in to your mailbox. Otherwise, Outlook
34+
on the web prompts you to sign in.
35+
36+
This URL cannot be accessed from within an iFrame.
37+
38+
:rtype: str or None
39+
"""
40+
return self.properties.get("webLink", None)
41+
42+
@property
43+
def calendar(self):
44+
"""The calendar that contains the event. Navigation property. Read-only."""
45+
from office365.calendar.calendar import Calendar
46+
return self.properties.get('calendar',
47+
Calendar(self.context, ResourcePath("calendar", self.resource_path)))

office365/calendar/reminder.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from office365.runtime.client_value import ClientValue
2+
3+
4+
class Reminder(ClientValue):
5+
"""A reminder for an event in a user calendar."""
6+
7+
def __init__(self, eventId=None):
8+
"""
9+
10+
:param str eventId: The unique ID of the event. Read only.
11+
"""
12+
super().__init__()
13+
self.eventId = eventId

office365/directory/user.py

+23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from office365.calendar.calendar_collection import CalendarCollection
33
from office365.calendar.calendar_group_collection import CalendarGroupCollection
44
from office365.calendar.meeting_time_suggestions_result import MeetingTimeSuggestionsResult
5+
from office365.calendar.reminder import Reminder
56
from office365.directory.directoryObject import DirectoryObject
67
from office365.directory.directoryObjectCollection import DirectoryObjectCollection
78
from office365.directory.objectIdentity import ObjectIdentity
@@ -65,6 +66,28 @@ def _construct_request(request):
6566
self.context.before_execute(_construct_request)
6667
return result
6768

69+
def get_reminder_view(self, start_dt, end_dt):
70+
"""Get the occurrences, exceptions, and single instances of events in a calendar view defined by a time range,
71+
from the user's default calendar, or from some other calendar of the user's.
72+
73+
:param datetime.datetime end_dt: The end date and time of the event for which the reminder is set up.
74+
The value is represented in ISO 8601 format, for example, "2015-11-08T20:00:00.0000000"..
75+
:param datetime.datetime start_dt: The start date and time of the event for which the reminder is set up.
76+
The value is represented in ISO 8601 format, for example, "2015-11-08T19:00:00.0000000".
77+
"""
78+
result = ClientValueCollection(Reminder)
79+
params = {
80+
"startDateTime": start_dt.isoformat(),
81+
"endDateTime": end_dt.isoformat(),
82+
}
83+
qry = ServiceOperationQuery(self, "reminderView", params, None, None, result)
84+
self.context.add_query(qry)
85+
86+
def _construct_request(request):
87+
request.method = HttpMethod.Get
88+
self.context.before_execute(_construct_request)
89+
return result
90+
6891
def delete_object(self, permanent_delete=False):
6992
"""
7093
:param permanent_delete: Permanently deletes the user from directory

tests/calendar_tests/test_calendar.py

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ def test4_list_calendar_view(self):
4343
events = self.client.me.get_calendar_view(start_dt=start_time, end_dt=end_time).execute_query()
4444
self.assertIsNotNone(events.resource_path)
4545

46+
def test4_get_reminder_view(self):
47+
end_time = datetime.utcnow()
48+
start_time = end_time - timedelta(days=14)
49+
reminders = self.client.me.get_reminder_view(start_dt=start_time, end_dt=end_time)
50+
self.client.execute_query()
51+
self.assertIsNotNone(reminders)
52+
4653
def test5_list_events(self):
4754
events = self.client.me.calendar.events.get().execute_query()
4855
self.assertIsNotNone(events.resource_path)

tests/mail/test_event.py renamed to tests/calendar_tests/test_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test1_create_event(self):
3838
self.assertIsNotNone(event.id)
3939
self.__class__.target_event = event
4040

41-
def test2_get_events(self):
41+
def test2_list_my_events(self):
4242
events = self.client.me.events.get().execute_query()
4343
self.assertGreaterEqual(len(events), 1)
4444

tests/sharepoint/test_user_profile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ def test8_get_followers_for(self):
7676
def test9_get_my_followers(self):
7777
people_manager = PeopleManager(self.my_client)
7878
result = people_manager.get_my_followers().execute_query()
79-
self.assertIsInstance(result., PersonPropertiesCollection)
79+
self.assertIsInstance(result, PersonPropertiesCollection)

0 commit comments

Comments
 (0)