@@ -183,16 +183,67 @@ def delete_subscription(self, subscription_id):
183183 """
184184 return self ._delete ('https://graph.microsoft.com/beta/' + 'subscriptions/{}' .format (subscription_id ))
185185
186- def get_me_events (self ):
186+ def list_notebooks (self ):
187+ """Retrieve a list of notebook objects.
188+
189+ Returns:
190+ A dict.
191+
192+ """
193+ return self ._get (self .base_url + 'me/onenote/notebooks' )
194+
195+ def get_notebook (self , notebook_id ):
196+ """Retrieve the properties and relationships of a notebook object.
197+
198+ Args:
199+ notebook_id:
200+
201+ Returns:
202+ A dict.
203+
204+ """
205+ return self ._get (self .base_url + 'me/onenote/notebooks/' + notebook_id )
206+
207+ def get_notebook_sections (self , notebook_id ):
208+ """Retrieve the properties and relationships of a notebook object.
209+
210+ Args:
211+ notebook_id:
212+
213+ Returns:
214+ A dict.
215+
216+ """
217+ return self ._get (self .base_url + 'me/onenote/notebooks/{}/sections' .format (notebook_id ))
218+
219+ def create_page (self , section_id , files ):
220+ """Create a new page in the specified section.
221+
222+ Args:
223+ section_id:
224+ content:
225+
226+ Returns:
227+ A dict.
228+
187229 """
188- Obtiene los eventos del usuario
189- :return: dictionary of events.
230+ # headers = {
231+ # 'Content-Type': 'text/html'
232+ # }
233+ headers = None
234+ return self ._post (self .base_url + '/me/onenote/sections/{}/pages' .format (section_id ), headers = headers , files = files )
235+
236+ def get_me_events (self ):
237+ """Get a list of event objects in the user's mailbox. The list contains single instance meetings and
238+ series masters.
239+
240+ Currently, this operation returns event bodies in only HTML format.
241+
242+ Returns:
243+ A dict.
244+
190245 """
191- try :
192- response = self ._get ('me/events' )
193- return response
194- except Exception as e :
195- return False
246+ return self ._get (self .base_url + 'me/events' )
196247
197248 def create_calendar_event (
198249 self , subject , content ,
@@ -202,8 +253,8 @@ def create_calendar_event(
202253 recurrence_range_startdate , recurrence_range_enddate ,
203254 location , attendees , calendar = None ):
204255 """
205- TODO: manual testing
206256 Create a new calendar event.
257+
207258 Args:
208259 subject: subject of event, string
209260 content: content of event, string
@@ -269,53 +320,47 @@ def create_calendar_event(
269320 "attendees" : attendees_list
270321 }
271322 url = 'me/calendars/{}/events' .format (calendar ) if calendar is not None else 'me/events'
272- try :
273- response = self ._post (url , json = body )
274- return response
275- except Exception as e :
276- return False
323+ return self ._post (self .base_url + url , json = body )
277324
278325 def create_calendar (self , name ):
279- """
280- Created a new calendar.
326+ """Create an event in the user's default calendar or specified calendar.
327+
328+ You can specify the time zone for each of the start and end times of the event as part of these values,
329+ as the start and end properties are of dateTimeTimeZone type.
330+
331+ When an event is sent, the server sends invitations to all the attendees.
332+
281333 Args:
282- name: name of new calendar to be created, string.
334+ name:
283335
284336 Returns:
285337
286338 """
287339 body = {
288340 'name' : '{}' .format (name )
289341 }
290- try :
291- response = self ._post ('me/calendars' , json = body )
292- return response
293- except Exception as e :
294- return False
342+ return self ._post (self .base_url + 'me/calendars' , json = body )
343+
344+ def get_me_calendar (self , calendar_id = None ):
345+ """Get the properties and relationships of a calendar object. The calendar can be one for a user,
346+ or the default calendar of an Office 365 group.
347+
348+ Args:
349+ calendar_id:
350+
351+ Returns:
295352
296- def get_me_calendar (self , id_cal = None ):
297- """
298- TODO: manual test.
299- Specific calendar.
300- :return:
301353 """
302- url = 'me/calendar/{}' .format (id_cal ) if id_cal is not None else 'me/calendar'
303- try :
304- response = self ._get (url )
305- return response
306- except Exception as e :
307- return False
354+ url = 'me/calendar/{}' .format (calendar_id ) if calendar_id is not None else 'me/calendar'
355+ return self ._get (self .base_url + url )
308356
309357 def get_me_calendars (self ):
310358 """
311- All the calendars of user.
312- :return:
359+
360+ Returns:
361+
313362 """
314- try :
315- response = self ._get ('me/calendars' )
316- return response
317- except Exception as e :
318- return False
363+ return self ._get (self .base_url + 'me/calendars' )
319364
320365 def send_mail (self , subject = None , recipients = None , body = '' , content_type = 'HTML' , attachments = None ):
321366 """Helper to send email from current user.
@@ -409,6 +454,7 @@ def _request(self, method, url, headers=None, **kwargs):
409454 return self ._parse (requests .request (method , url , headers = _headers , ** kwargs ))
410455
411456 def _parse (self , response ):
457+ print (response .text )
412458 status_code = response .status_code
413459 if 'application/json' in response .headers ['Content-Type' ]:
414460 r = response .json ()
0 commit comments