Sha256: 3a7d5c37f0c9031840d4e393eab3d912d3412ac9f1d1b0c46ae43a027d9a5c79

Contents?: true

Size: 635 Bytes

Versions: 4

Compression:

Stored size: 635 Bytes

Contents

module TrackerApi
  module Endpoints
    class Search
      attr_accessor :client

      def initialize(client)
        @client = client
      end

      def get(project_id, query, options={})
        raise ArgumentError, 'Valid query string required to search' unless query.is_a?(String)

        options.key?(:body) ? options[:body][:query] = query : options[:body] = { query: query }
        data = client.get("/projects/#{project_id}/search", options).body

        raise Errors::UnexpectedData, 'Hash of search results expect' unless data.is_a? Hash

        Resources::SearchResultContainer.new(data)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tracker_api-1.9.0 lib/tracker_api/endpoints/search.rb
tracker_api-1.8.0 lib/tracker_api/endpoints/search.rb
tracker_api-1.7.1 lib/tracker_api/endpoints/search.rb
tracker_api-1.7.0 lib/tracker_api/endpoints/search.rb