Class: TrackerApi::Endpoints::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/tracker_api/endpoints/search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Search

Returns a new instance of Search.



6
7
8
# File 'lib/tracker_api/endpoints/search.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/tracker_api/endpoints/search.rb', line 4

def client
  @client
end

Instance Method Details

#get(project_id, query, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
# File 'lib/tracker_api/endpoints/search.rb', line 10

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

  options[:params] = { 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