class_docstr: To obtain a token:
  
  * Login to web portal
  * Go to Settings
  * Click on "Configure Flex Web Service"
  * Generate token
class_docstr_tok: ["To","obtain","a","token",":","*","Login","to","web","portal","*","Go","to","Settings","*","Click","on","``","Configure","Flex","Web","Service","''","*","Generate","token"]
docstr: Download report for the given ``token`` and ``queryId``.
docstr_tok: ["Download","report","for","the","given","``","token","``","and","``","queryId","``","."]
code: def download(self, token, queryId):
      """Download report for the given ``token`` and ``queryId``."""
      url = (
          "https://gdcdyn.interactivebrokers.com"
          f"/Universal/servlet/FlexStatementService.SendRequest?"
          f"t={token}&q={queryId}&v=3"
      )
      resp = urlopen(url)
      data = resp.read()
  
      root = et.fromstring(data)
      elem = root.find("Status")
      if elem is not None and elem.text == "Success":
          elem = root.find("ReferenceCode")
          assert elem is not None
          code = elem.text
          elem = root.find("Url")
          assert elem is not None
          baseUrl = elem.text
          _logger.info("Statement is being prepared...")
      else:
          elem = root.find("ErrorCode")
          errorCode = elem.text if elem is not None else ""
          elem = root.find("ErrorMessage")
          errorMsg = elem.text if elem is not None else ""
          raise FlexError(f"{errorCode}: {errorMsg}")
  
      while True:
          time.sleep(1)
          url = f"{baseUrl}?q={code}&t={token}"
          resp = urlopen(url)
          self.data = resp.read()
          self.root = et.fromstring(self.data)
          if self.root[0].tag == "code":
              msg = self.root[0].text
              if msg and msg.startswith(
                  "Statement generation in progress"
              ):
                  _logger.info("still working...")
                  continue
              else:
                  raise FlexError(msg)
          break
      _logger.info("Statement retrieved.")
  
file_path: ib_insync/ib_insync/flexreport.py
imports: import logging
  import time
  import xml.etree.ElementTree
  from contextlib import suppress
  from urllib.request import urlopen
  from ib_insync import util
  from ib_insync.objects import DynamicObject
label_desc: Use image node_id 5 for calling the FlexReport obj's underlying member method code with example usage: obj.download(token, queryId) without return types