Sha256: f1b951e504e1223a05a6a42d460b494bacac7f2b87120a8dd032606c609b3186

Contents?: true

Size: 722 Bytes

Versions: 2

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true
module DiscourseApi
  module API
    module Search
      # Returns search results that match the specified term.
      #
      # @param term [String] a search term
      # @param options [Hash] A customizable set of options
      # @option options [String] :type_filter Returns results of the specified type.
      # @return [Array] Return results as an array of Hashes.
      def search(term, options = {})
        raise ArgumentError.new("#{term} is required but not specified") unless term
        raise ArgumentError.new("#{term} is required but not specified") if term.empty?

        response = get("/search", options.merge(q: term))
        response[:body]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse_api-2.0.1 lib/discourse_api/api/search.rb
discourse_api-2.0.0 lib/discourse_api/api/search.rb