Class: Dina::BaseSearch
- Inherits:
-
Object
- Object
- Dina::BaseSearch
- Defined in:
- lib/dina/search/base_search.rb
Direct Known Subclasses
Class Method Summary collapse
- .endpoint ⇒ Object
- .endpoint_path ⇒ Object
-
.execute(params, method: :get, payload: {}) ⇒ Hash
Executes a search.
-
.index_name(index:) ⇒ String
Sets the search index name.
Class Method Details
.endpoint ⇒ Object
4 5 6 |
# File 'lib/dina/search/base_search.rb', line 4 def self.endpoint Dina::Authentication.endpoint_url end |
.endpoint_path ⇒ Object
8 9 10 |
# File 'lib/dina/search/base_search.rb', line 8 def self.endpoint_path "search-api/search-ws/" end |
.execute(params, method: :get, payload: {}) ⇒ Hash
Executes a search
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dina/search/base_search.rb', line 29 def self.execute(params, method: :get, payload: {}) begin response = RestClient::Request.execute( method: method, url: endpoint + endpoint_path + "?" + params.to_query, payload: payload.to_json, headers: { accept: 'application/json', content_type: 'application/json', authorization: Dina::Authentication.header } ) JSON.parse(response, symbolize_names: true) rescue RestClient::ExceptionWithResponse => e e.response end end |
.index_name(index:) ⇒ String
Sets the search index name
17 18 19 20 |
# File 'lib/dina/search/base_search.rb', line 17 def self.index_name(index:) return nil if !index "dina_#{index}_index" end |