Class: SearchClient
Overview
The SearchClient class allows clients to query 3taps Search API for data, and data about data.
Its methods are used to query API with appropriate requests:
client = SearchClient.new
client.search(search_request) # => returns array of SearchResponse objects
client.range(range_request) # => returns array of RangeResponse objects
client.summary(summary_request) # => returns array of SummaryResponse objects
client.count(search_request) # => returns array of CountResponse objects
client.best_match(keywords) # => returns array of BestMatchResponse objects
Constant Summary
Constants inherited from Client
Client::DEFAULT_API_PORT, Client::DEFAULT_URL, Client::TIMEOUT
Instance Method Summary collapse
-
#best_match(keywords) ⇒ Object
Method
best_match
returns the 3taps category associated with the keywords, along with the number of postings in that category. -
#count(search_request) ⇒ Object
Method
count
returns the total number of postings that match the given Common Search Criteria represented by SearchRequest. -
#range(range_request) ⇒ Object
Method
range
returns the minium and maximum values currently in 3taps for the given fields that match the given Common Search Criteria inside of the RangeResponse object. -
#search(search_request) ⇒ Object
Method
search
searches 3taps for postings. -
#summary(summary_request) ⇒ Object
Method
summary
returns the total number of postings found in 3taps, across the given dimension, that match the given Common Search Criteria parameters inside of the SummaryResponse object.
Methods inherited from Client
#execute_get, #execute_post, #initialize
Constructor Details
This class inherits a constructor from Client
Instance Method Details
#best_match(keywords) ⇒ Object
Method best_match
returns the 3taps category associated with the keywords, along with the number of postings in that category. Example:
keywords = "iPad,Apple,iPhone"
client = SearchClient.new
client.best_match(keywords) # => BestMatchResponse
77 78 79 80 |
# File 'lib/client/search_client.rb', line 77 def best_match(keywords) response = execute_get("/search/best-match", "keywords=#{keywords}") BestMatchResponse.new(decode(response)) end |
#count(search_request) ⇒ Object
Method count
returns the total number of postings that match the given Common Search Criteria represented by SearchRequest. Example:
request = SearchRequest.new
client = SearchClient.new
client.count(request) # => CountResponse
65 66 67 68 |
# File 'lib/client/search_client.rb', line 65 def count(search_request) response = execute_get("/search/count", search_request.query_params) CountResponse.new(decode(response)) end |
#range(range_request) ⇒ Object
Method range
returns the minium and maximum values currently in 3taps for the given fields that match the given Common Search Criteria inside of the RangeResponse object. The purpose of the range method is to provide developers with sensible values for range-based UI filters.
Examples:
request = RangeRequest.new
client = SearchClient.new(request)
client.range(request) # => RangeResponse
35 36 37 38 |
# File 'lib/client/search_client.rb', line 35 def range(range_request) response = execute_get("/search/range", range_request.query_params) RangeResponse.from_array(decode(response)) end |
#search(search_request) ⇒ Object
Method search
searches 3taps for postings. Example:
request = SearchRequest.new
client = SearchClient.new
client.search(request) # => SearchResponse
19 20 21 22 |
# File 'lib/client/search_client.rb', line 19 def search(search_request) response = execute_get("/search", search_request.query_params) SearchResponse.new(decode(response)) end |
#summary(summary_request) ⇒ Object
Method summary
returns the total number of postings found in 3taps, across the given dimension, that match the given Common Search Criteria parameters inside of the SummaryResponse object. Searching for “text=toyota” across “dimension=source” would return a list of all sources in 3taps, along with the number of postings matching the search “text=toyota” in that source. You may currently search across dimensions source, category, and location.
Examples:
request = SummaryRequest.new
client = SearchClient.new
client.summary(request) # => SummaryResponse
53 54 55 56 |
# File 'lib/client/search_client.rb', line 53 def summary(summary_request) response = execute_get("/search/summary", summary_request.query_params) SummaryResponse.from_hash(decode(response)) end |