Module: KB::Searchable::ClassMethods

Defined in:
lib/kb/models/concerns/searchable.rb

Instance Method Summary collapse

Instance Method Details

#search(filters) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/kb/models/concerns/searchable.rb', line 10

def search(filters)
  response = kb_client.request('search', filters: filters).symbolize_keys
  elements = response[:elements].map { |contract| from_api(contract) }
  KB::SearchResult.new(**response.merge(elements: elements))
rescue Faraday::Error => e
  raise KB::Error.from_faraday(e)
end