Skip to content

Commit

Permalink
Merge pull request googleapis#47 from lbrictson/master
Browse files Browse the repository at this point in the history
Ability to pull more than 10 events
  • Loading branch information
Narcolapser authored Jan 11, 2017
2 parents febcb5f + a99677d commit 63087a4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions O365/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Calendar( object ):
events_url - the url that is actually called to fetch events. takes an ID, start, and end date.
time_string - used for converting between struct_time and json's time format.
'''
events_url = 'https://outlook.office365.com/api/v1.0/me/calendars/{0}/calendarview?startDateTime={1}&endDateTime={2}'
events_url = 'https://outlook.office365.com/api/v1.0/me/calendars/{0}/calendarview?startDateTime={1}&endDateTime={2}&$top={3}'
time_string = '%Y-%m-%dT%H:%M:%SZ'

def __init__(self, json=None, auth=None):
Expand Down Expand Up @@ -60,7 +60,7 @@ def fetchEvents(self,start=None,end=None):
return self.getEvents(start,end)


def getEvents(self,start=None,end=None):
def getEvents(self,start=None,end=None, eventCount=10):
'''
Pulls events in for this calendar. default range is today to a year now.
Expand All @@ -84,7 +84,7 @@ def getEvents(self,start=None,end=None):
end = time.strftime(self.time_string,end)

# This is where the actual call to Office365 happens.
response = requests.get(self.events_url.format(self.json['Id'],start,end),auth=self.auth)
response = requests.get(self.events_url.format(self.json['Id'],start,end,eventCount) ,auth=self.auth)
log.info('Response from O365: %s', str(response))

#This takes that response and then parses it into individual calendar events.
Expand Down

0 comments on commit 63087a4

Please sign in to comment.