class_docstr: Intercom StreamAlert app
class_docstr_tok: ["Intercom","StreamAlert","app"]
code: def _gather_logs(self):
      # Generate headers
      headers = {
          "Authorization": "Bearer %s" % self._config.auth["token"],
          "Accept": "application/json",
      }
  
      # Results are paginated with a page url field provided that is used in subsequent queries.
      # If this field exists, make a a query to the page url, and if not, make a fresh query to
      # the default _INTERCOM_LOGS_URL with the required created_at_before and created_at_after
      # parameters
      if self._next_page:
          params = None
          url = self._next_page
      else:
          params = {
              "created_at_before": int(calendar.timegm(time.gmtime())),
              "created_at_after": self._last_timestamp,
          }
          url = self._INTERCOM_LOGS_URL
  
      LOGGER.info("Requesting events from: %s params: %s", url, params)
  
      try:
          result, response = self._make_get_request(
              url, headers=headers, params=params
          )
      except requests.exceptions.ConnectionError:
          LOGGER.exception("Received bad response from Intercom")
          return False
  
      if not result:
          return False
  
      activities = [
          activity
          for activity in response["activity_logs"]
          if int(activity["created_at"]) > self._last_timestamp
      ]
  
      if not activities:
          return False
  
      # Save next page url if any for paginated results
      if response["pages"]["next"] is not None:
          self._more_to_poll = True
          self._next_page = response["pages"]["next"]
      else:
          self._more_to_poll = False
          self._next_page = None
  
      most_recent_timestamp = max(
          int(activity["created_at"]) for activity in activities
      )
  
      # Save most recent time stamp for the next query
      if most_recent_timestamp > self._last_timestamp:
          self._last_timestamp = most_recent_timestamp
  
      return activities
  
file_path: streamalert/streamalert/apps/_apps/intercom.py
imports: import calendar
  import time
  import re
  import requests
  from .None import AppIntegration, StreamAlertApp, get_logger
label_desc: Use image node_id 6 for calling the IntercomApp obj's underlying member method code with example usage: obj._gather_logs() and returns: activities, False, False, False