<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_all_chats(self):
 """ Fetches all chats :return: List of chats :rtype: list[Chat] """

        chats = self.wapi_functions.getAllChats()
        if chats:
            return [factory_chat(chat, self) for chat in chats]
        else:
            return []