Class: YANAPI::TermQuery

Inherits:
Query
  • Object
show all
Includes:
Common
Defined in:
lib/yanapi/term_query.rb

Constant Summary collapse

VALID_PARAMS =
[:category_id,
:category_name,
:date_range,
:query,
:region,
:results,
:search_in,
:sort,
:start,
:type
]
REQUIRED_PARAMS =
[:query]

Constants inherited from Query

Query::HOST, Query::MULTIVALUED_PARAMS, Query::SERVICE, Query::SERVICE_VERSION, Query::VALID_OUTPUT_FORMATS

Instance Method Summary collapse

Methods included from Common

#basic_check, #check_semantics

Methods inherited from Query

#build_url, #expand_params, #get, #get_response, #prove_xml

Constructor Details

#initialize(params) ⇒ TermQuery

Returns a new instance of TermQuery.



22
23
24
25
# File 'lib/yanapi/term_query.rb', line 22

def initialize(params)
  params[:method] = 'questionSearch'
  super
end

Instance Method Details

#check_params(params) ⇒ Object (private)

validates presense of query validates uniqueness of query



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/yanapi/term_query.rb', line 30

def check_params(params)
  unless params[:query]
    raise UserError, "Query is missing!"
  end

  allowed = %w{query search_in category_id
               category_name region date_range
               sort appid type start results
               output callback method
              }

  # in the module Common
  check_semantics(allowed, params)
  basic_check(params)
  
  super
end