Skip to content

Commit

Permalink
added order by option for fetching messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mihalikv committed Apr 8, 2018
1 parent 39bc0bf commit fbab449
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion O365/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, auth, getNow=True, verify=True):
self.messages = []

self.filters = ''
self.order_by = ''
self.verify = verify

if getNow:
Expand All @@ -53,7 +54,7 @@ def getMessages(self, number = 10):
'''

log.debug('fetching messages.')
response = requests.get(self.inbox_url,auth=self.auth,params={'$filter':self.filters, '$top':number},verify=self.verify)
response = requests.get(self.inbox_url,auth=self.auth,params={'$orderby':self.order_by, '$filter':self.filters, '$top':number},verify=self.verify)
log.info('Response from O365: %s', str(response))

#check that there are messages
Expand Down Expand Up @@ -82,6 +83,16 @@ def getMessages(self, number = 10):
log.debug('all messages retrieved and put in to the list.')
return True

def getOrderBy(self):
return self.order_by

def setOrderBy(self, f_string):
'''
For example 'DateTimeReceived desc'
'''
self.order_by = f_string
return True

def getFilter(self):
'''get the value set for a specific filter, if exists, else None'''
return self.filters
Expand Down

0 comments on commit fbab449

Please sign in to comment.