docs: def gen_rule_payload(pt_rule, results_per_call=None,
                       from_date=None, to_date=None, count_bucket=None,
                       tag=None,
                       stringify=True):
  
      """
      Generates the dict or json payload for a PowerTrack rule.
  
      Args:
          pt_rule (str): The string version of a powertrack rule,
              e.g., "beyonce has:geo". Accepts multi-line strings
              for ease of entry.
          results_per_call (int): number of tweets or counts returned per API
          call. This maps to the ``maxResults`` search API parameter.
              Defaults to 500 to reduce API call usage.
          from_date (str or None): Date format as specified by
              `convert_utc_time` for the starting time of your search.
          to_date (str or None): date format as specified by `convert_utc_time`
              for the end time of your search.
          count_bucket (str or None): If using the counts api endpoint,
              will define the count bucket for which tweets are aggregated.
          stringify (bool): specifies the return type, `dict`
              or json-formatted `str`.
  
      Example:
  
          >>> from searchtweets.utils import gen_rule_payload
          >>> gen_rule_payload("beyonce has:geo",
              ...              from_date="2017-08-21",
              ...              to_date="2017-08-22")
          '{"query":"beyonce has:geo","maxResults":100,"toDate":"201708220000","fromDate":"201708210000"}'
      """
  
      pt_rule = ' '.join(pt_rule.split())  # allows multi-line strings
      payload = {"query": pt_rule}
      if results_per_call is not None and isinstance(results_per_call, int) is True:
          payload["maxResults"] = results_per_call
      if to_date:
          payload["toDate"] = convert_utc_time(to_date)
      if from_date:
          payload["fromDate"] = convert_utc_time(from_date)
      if count_bucket:
          if set(["day", "hour", "minute"]) & set([count_bucket]):
              payload["bucket"] = count_bucket
              del payload["maxResults"]
          else:
              logger.error("invalid count bucket: provided {}"
                           .format(count_bucket))
              raise ValueError
      if tag:
          payload["tag"] = tag
  
      return json.dumps(payload) if stringify else payload