Class: TocDoc::Search
- Inherits:
-
Object
- Object
- TocDoc::Search
- Defined in:
- lib/toc_doc/models/search.rb,
lib/toc_doc/models/search/result.rb
Overview
Entry point for the autocomplete / search endpoint.
Unlike Availability, +Search+ is not itself a resource — it is a plain service class that wraps the API call and returns a typed result.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- PATH =
API path for the autocomplete / searchbar endpoint.
'/api/searchbar/autocomplete.json'- VALID_TYPES =
Accepted values for the +type:+ keyword in where.
%w[profile practitioner organization speciality].freeze
Class Method Summary collapse
-
.where(query:, type: nil, **options) ⇒ Search::Result, ...
Queries the autocomplete endpoint and returns a Result or a filtered array.
Class Method Details
.where(query:, type: nil, **options) ⇒ Search::Result, ...
Queries the autocomplete endpoint and returns a Result or a filtered array.
The +type:+ keyword is handled client-side only — it is never forwarded to the API. The full response is always fetched; narrowing happens after.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/toc_doc/models/search.rb', line 48 def where(query:, type: nil, **) if !type.nil? && !VALID_TYPES.include?(type) raise ArgumentError, "Invalid type #{type.inspect}. Must be one of: #{VALID_TYPES.join(', ')}" end data = TocDoc.client.get(PATH, query: { search: query, ** }) result = Result.new(data) type.nil? ? result : result.filter_by_type(type) end |