diff --git a/O365/inbox.py b/O365/inbox.py index 0da8381239a2f..cef97028d0a74 100644 --- a/O365/inbox.py +++ b/O365/inbox.py @@ -30,6 +30,7 @@ def __init__(self, auth, getNow=True, verify=True): self.messages = [] self.filters = '' + self.order_by = '' self.verify = verify if getNow: @@ -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 @@ -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