Skip to content

Commit dad5769

Browse files
author
root
committed
2 parents 0b08f13 + 4c3cf09 commit dad5769

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

microsoftgraph/client.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def authorization_url(self, redirect_uri, scope, state=None, office365=False):
4242
about the user's state in the app before the authentication request occurred, such as the page or view
4343
they were on.
4444
45+
office365: Get authorization url for office 365 instead graph.
46+
4547
Returns:
48+
A string.
4649
4750
"""
4851
params = {
@@ -70,6 +73,8 @@ def exchange_code(self, redirect_uri, code, office365=False):
7073
7174
code: The authorization_code that you acquired in the first leg of the flow.
7275
76+
office365: Exchange code for office 365 instead graph.
77+
7378
Returns:
7479
A dict.
7580
@@ -98,7 +103,10 @@ def refresh_token(self, redirect_uri, refresh_token, office365=False):
98103
after the current access token expires. Refresh tokens are long-lived, and can be used to retain access
99104
to resources for extended periods of time.
100105
106+
office365: Refresh token for office 365 instead graph.
107+
101108
Returns:
109+
A dict.
102110
103111
"""
104112
data = {
@@ -120,6 +128,8 @@ def set_token(self, token, office365=False):
120128
Args:
121129
token: A string with the Token.
122130
131+
office365: Set token for office 365 instead graph.
132+
123133
"""
124134
if office365:
125135
self.office365_token = token
@@ -138,7 +148,7 @@ def get_me(self, params=None):
138148
params: A dict.
139149
140150
Returns:
141-
151+
A dict.
142152
143153
"""
144154
return self._get(self.base_url + 'me', params=params)
@@ -149,9 +159,10 @@ def get_message(self, message_id, params=None):
149159
150160
Args:
151161
message_id: A dict.
162+
params:
152163
153164
Returns:
154-
165+
A dict.
155166
156167
"""
157168
return self._get(self.base_url + 'me/messages/' + message_id, params=params)
@@ -161,13 +172,15 @@ def create_subscription(self, change_type, notification_url, resource, expiratio
161172
"""Creating a subscription is the first step to start receiving notifications for a resource.
162173
163174
Args:
164-
change_type: The event type that caused the notification. For example, created on mail receive, or updated on marking a message read.
175+
change_type: The event type that caused the notification. For example, created on mail receive, or updated
176+
on marking a message read.
165177
notification_url:
166178
resource: The URI of the resource relative to https://graph.microsoft.com.
167179
expiration_datetime: The expiration time for the subscription.
168180
client_state: The clientState property specified in the subscription request.
169181
170182
Returns:
183+
A dict.
171184
172185
"""
173186
data = {
@@ -187,8 +200,10 @@ def renew_subscription(self, subscription_id, expiration_datetime):
187200
188201
Args:
189202
subscription_id:
203+
expiration_datetime:
190204
191205
Returns:
206+
A dict.
192207
193208
"""
194209
data = {
@@ -204,6 +219,7 @@ def delete_subscription(self, subscription_id):
204219
subscription_id:
205220
206221
Returns:
222+
None.
207223
208224
"""
209225
return self._delete('https://graph.microsoft.com/beta/' + 'subscriptions/{}'.format(subscription_id))
@@ -250,7 +266,7 @@ def create_page(self, section_id, files):
250266
251267
Args:
252268
section_id:
253-
content:
269+
files:
254270
255271
Returns:
256272
A dict.
@@ -272,13 +288,9 @@ def get_me_events(self):
272288
return self._get(self.base_url + 'me/events')
273289

274290
@token_required
275-
def create_calendar_event(
276-
self, subject, content,
277-
start_datetime, start_timezone, end_datetime,
278-
end_timezone, recurrence_type, recurrence_interval,
279-
recurrence_days_of_week, recurrence_range_type,
280-
recurrence_range_startdate, recurrence_range_enddate,
281-
location, attendees, calendar=None):
291+
def create_calendar_event(self, subject, content, start_datetime, start_timezone, end_datetime, end_timezone,
292+
recurrence_type, recurrence_interval, recurrence_days_of_week, recurrence_range_type,
293+
recurrence_range_startdate, recurrence_range_enddate, location, attendees, calendar=None):
282294
"""
283295
Create a new calendar event.
284296
@@ -304,8 +316,10 @@ def create_calendar_event(
304316
location: string
305317
attendees: list of dicts of the form:
306318
{"emailAddress": {"address": a['attendees_email'],"name": a['attendees_name']}
319+
calendar:
307320
308321
Returns:
322+
A dict.
309323
310324
"""
311325
attendees_list = [{
@@ -362,32 +376,21 @@ def create_calendar(self, name):
362376
name:
363377
364378
Returns:
379+
A dict.
365380
366381
"""
367382
body = {
368383
'name': '{}'.format(name)
369384
}
370385
return self._post(self.base_url + 'me/calendars', json=body)
371386

372-
@token_required
373-
def get_me_calendar(self, calendar_id=None):
374-
"""Get the properties and relationships of a calendar object. The calendar can be one for a user,
375-
or the default calendar of an Office 365 group.
376-
377-
Args:
378-
calendar_id:
379-
380-
Returns:
381-
382-
"""
383-
url = 'me/calendar/{}'.format(calendar_id) if calendar_id is not None else 'me/calendar'
384-
return self._get(self.base_url + url)
385-
386387
@token_required
387388
def get_me_calendars(self):
388-
"""
389+
"""Get all the user's calendars (/calendars navigation property), get the calendars from the default
390+
calendar group or from a specific calendar group.
389391
390392
Returns:
393+
A dict.
391394
392395
"""
393396
return self._get(self.base_url + 'me/calendars')

microsoftgraph/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from microsoftgraph.exceptions import AccessTokenRequired
1+
from microsoftgraph.exceptions import TokenRequired
22
from functools import wraps
33

44

@@ -7,7 +7,7 @@ def token_required(func):
77
def helper(*args, **kwargs):
88
client = args[0]
99
if not client.token:
10-
raise AccessTokenRequired('You must set the Token.')
10+
raise TokenRequired('You must set the Token.')
1111
return func(*args, **kwargs)
1212

1313
return helper

microsoftgraph/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class UnknownError(BaseError):
66
pass
77

88

9-
class AccessTokenRequired(BaseError):
9+
class TokenRequired(BaseError):
1010
pass
1111

1212

0 commit comments

Comments
 (0)