class_docstr: The Microsoft Teams Chats Table implementation.
class_docstr_tok: ["The","Microsoft","Teams","Chats","Table","implementation","."]
docstr: Calls the API client to get the chats from the Microsoft Graph API.
  
  Parameters
  ----------
  chat_id: Text
      The chat id to get the chat from.
  
  Returns
  -------
  List[Dict[Text, Any]]
      The chats from the Microsoft Graph API.
docstr_tok: ["Calls","the","API","client","to","get","the","chats","from","the","Microsoft","Graph","API",".","Parameters","--","--","--","--","--","chat_id",":","Text","The","chat","id","to","get","the","chat","from",".","Returns","--","--","--","-","List","[","Dict","[","Text",",","Any","]","]","The","chats","from","the","Microsoft","Graph","API","."]
code: def get_chats(self, chat_id: Text = None) -> List[Dict[Text, Any]]:
      """
      Calls the API client to get the chats from the Microsoft Graph API.
  
      Parameters
      ----------
      chat_id: Text
          The chat id to get the chat from.
  
      Returns
      -------
      List[Dict[Text, Any]]
          The chats from the Microsoft Graph API.
      """
  
      api_client = self.handler.connect()
  
      # if the chat_id is given, get the chat with that id from the API
      if chat_id:
          chats = [api_client.get_chat(chat_id)]
      # if the chat_id is not given, get all the chats
      else:
          chats = api_client.get_chats()
  
      for chat in chats:
          last_message_preview = chat.get("lastMessagePreview")
  
          # keep only the lastMessagePreview_id and lastMessagePreview_createdDateTime columns
          if last_message_preview:
              chat["lastMessagePreview_id"] = last_message_preview.get(
                  "id"
              )
              chat[
                  "lastMessagePreview_createdDateTime"
              ] = last_message_preview.get("createdDateTime")
              del chat["lastMessagePreview"]
              del chat["lastMessagePreview@odata.context"]
  
      return chats
  
imports: import pandas
  from typing import Text, List, Dict, Any
  from mindsdb.utilities import log
  from mindsdb_sql.parser import ast
  from mindsdb.integrations.libs.api_handler import APITable
  from mindsdb.integrations.handlers.ms_teams_handler.settings import ms_teams_handler_config
  from mindsdb.integrations.handlers.utilities.query_utilities.insert_query_utilities import INSERTQueryParser
  from mindsdb.integrations.handlers.utilities.query_utilities.select_query_utilities import SELECTQueryParser, SELECTQueryExecutor
label_desc: Use image node_id 2 for calling the ChatsTable obj's underlying member method code with example usage: obj.get_chats(chat_id) and returns: chats