Class: Rospatent::Search
- Inherits:
-
Object
- Object
- Rospatent::Search
- Includes:
- InputValidator
- Defined in:
- lib/rospatent/search.rb
Overview
Search class to handle search queries to the API
Instance Method Summary collapse
-
#execute(q: nil, qn: nil, limit: nil, offset: nil, pre_tag: nil, post_tag: nil, sort: nil, group_by: nil, include_facets: nil, filter: nil, datasets: nil, highlight: nil) ⇒ Rospatent::SearchResult
Execute a search against the API.
-
#initialize(client) ⇒ Search
constructor
Initialize a new search instance.
Methods included from InputValidator
#validate_array, #validate_date, #validate_enum, #validate_hash, #validate_params, #validate_patent_id, #validate_positive_integer, #validate_required_date, #validate_required_string, #validate_string, #validate_string_enum, #validate_string_or_array, #validate_text_with_word_count
Constructor Details
#initialize(client) ⇒ Search
Initialize a new search instance
34 35 36 |
# File 'lib/rospatent/search.rb', line 34 def initialize(client) @client = client end |
Instance Method Details
#execute(q: nil, qn: nil, limit: nil, offset: nil, pre_tag: nil, post_tag: nil, sort: nil, group_by: nil, include_facets: nil, filter: nil, datasets: nil, highlight: nil) ⇒ Rospatent::SearchResult
Execute a search against the API
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rospatent/search.rb', line 54 def execute( q: nil, qn: nil, limit: nil, offset: nil, pre_tag: nil, post_tag: nil, sort: nil, group_by: nil, include_facets: nil, filter: nil, datasets: nil, highlight: nil ) # Filter out nil parameters to only validate explicitly provided ones params = { q: q, qn: qn, limit: limit, offset: offset, pre_tag: pre_tag, post_tag: post_tag, sort: sort, group_by: group_by, include_facets: include_facets, filter: filter, datasets: datasets, highlight: highlight }.compact # Validate and normalize parameters validated_params = validate_and_normalize_params(**params) payload = build_payload(**validated_params) response = @client.post("/patsearch/v0.2/search", payload) SearchResult.new(response) end |