Class: NDB::Search
- Inherits:
-
Object
- Object
- NDB::Search
- Defined in:
- lib/ndb/search.rb
Constant Summary collapse
- PERMITTED_PARAMS =
%w(q fg sort max offset api_key)
Class Method Summary collapse
Class Method Details
.base_uri ⇒ Object
15 16 17 |
# File 'lib/ndb/search.rb', line 15 def self.base_uri NDB.base_uri + "/search" end |
.default_options ⇒ Object
19 20 21 22 |
# File 'lib/ndb/search.rb', line 19 def self. { q: "", fg: "", sort: "r", max: 50, offset: 0, format: "JSON", api_key: NDB.api_key } end |
.perform(options = {}) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/ndb/search.rb', line 8 def self.perform( = {}) = NDB.(, PERMITTED_PARAMS) params = NDB.params_from_hash(.merge()) response = Faraday.get("#{base_uri}?#{params}") JSON.parse(response.body) end |