def search(query, delegate)
      validate_delegate(delegate)

      delegate.inspector_started_query(query, inspector)
      url = url_for_request query

      begin
        results = get_api_results(url)
      rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
        delegate.inspector_could_not_create_report(e, query, inspector)
        return
      end

      report = parse_results query, results

      # TODO: progress callback

      if report.issues.any?
        if self.using_deprecated_method
          delegate.inspector_successfully_recieved_report(report, inspector)
        else
          delegate.inspector_successfully_received_report(report, inspector)
        end
      else
        # rubocop:disable Style/IfInsideElse
        if self.using_deprecated_method
          delegate.inspector_recieved_empty_report(report, inspector)
        else
          delegate.inspector_received_empty_report(report, inspector)
        end
        # rubocop:enable Style/IfInsideElse
      end

      report
    end
def search(query, delegate)
      validate_delegate(delegate)

      delegate.inspector_started_query(query, inspector)
      url = url_for_request query

      begin
        results = get_api_results(url)
      rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
        delegate.inspector_could_not_create_report(e, query, inspector)
        return
      end

      report = parse_results query, results

      # TODO: progress callback

      if report.issues.any?
        if self.using_deprecated_method
          delegate.inspector_successfully_recieved_report(report, inspector)
        else
          delegate.inspector_successfully_received_report(report, inspector)
        end
      else
        # rubocop:disable Style/IfInsideElse
        if self.using_deprecated_method
          delegate.inspector_recieved_empty_report(report, inspector)
        else
          delegate.inspector_received_empty_report(report, inspector)
        end
        # rubocop:enable Style/IfInsideElse
      end

      report
    end
Searches for a query, with a UI delegate