def get_messages(self, limit=<NUM_LIT>, *, query=None, order_by=None, batch=None,<EOL>download_attachments=False):
if self.root:<EOL><INDENT>url = self.build_url(self._endpoints.get('<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>url = self.build_url(self._endpoints.get('<STR_LIT>').format(<EOL>id=self.folder_id))<EOL><DEDENT>if limit is None or limit > self.protocol.max_top_value:<EOL><INDENT>batch = self.protocol.max_top_value<EOL><DEDENT>params = {'<STR_LIT>': batch if batch else limit}<EOL>if order_by:<EOL><INDENT>params['<STR_LIT>'] = order_by<EOL><DEDENT>if query:<EOL><INDENT>if isinstance(query, str):<EOL><INDENT>params['<STR_LIT>'] = query<EOL><DEDENT>else:<EOL><INDENT>params.update(query.as_params())<EOL><DEDENT><DEDENT>response = self.con.get(url, params=params)<EOL>if not response:<EOL><INDENT>return iter(())<EOL><DEDENT>data = response.json()<EOL>messages = (self.message_constructor(<EOL>parent=self,<EOL>download_attachments=download_attachments,<EOL>**{self._cloud_data_key: message})<EOL>for message in data.get('<STR_LIT:value>', []))<EOL>next_link = data.get(NEXT_LINK_KEYWORD, None)<EOL>if batch and next_link:<EOL><INDENT>return Pagination(parent=self, data=messages,<EOL>constructor=self.message_constructor,<EOL>next_link=next_link, limit=limit,<EOL>download_attachments=download_attachments)<EOL><DEDENT>else:<EOL><INDENT>return messages<EOL><DEDENT>
Downloads messages from this folder

:param int limit: limits the result set. Over 999 uses batch.
:param query: applies a filter to the request such as
 "displayName eq 'HelloFolder'"
:type query: Query or str
:param order_by: orders the result set based on this condition
:type order_by: Query or str
:param int batch: batch size, retrieves items in
 batches allowing to retrieve more items than the limit.
:param bool download_attachments: whether or not to download attachments
:return: list of messages
:rtype: list[Message] or Pagination