Class: Bark::Request::Tnrs
- Inherits:
-
Bark::Request
- Object
- Bark::Request
- Bark::Request::Tnrs
- Defined in:
- lib/bark/request/tnrs.rb
Constant Summary collapse
- API_VERSION =
'v2'
- SEARCH_BASE =
[Bark::Request::BASE_URL, API_VERSION, 'tnrs'].join("/")
- METHODS =
Method: parameters
{ tnrs_match_names: %i{}, tnrs_contexts: %i{}, tnrs_infer_context: %i{}, }
- REQUIRED_PARAMS =
node_ids or ott_ids are required in some cases, so this will have to be cased
{ }
- METHODS_REQUIRED_PARAMS =
mrp
Constants inherited from Bark::Request
Instance Attribute Summary
Attributes inherited from Bark::Request
#method, #params, #payload, #uri
Instance Method Summary collapse
- #assign_options(method: method, params: params) ⇒ Object
- #has_required_params? ⇒ Boolean
-
#initialize(method: :tol_about, params: {}) ⇒ Tnrs
constructor
A new instance of Tnrs.
- #json_payload ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Bark::Request
#params_are_supported?, #response
Constructor Details
#initialize(method: :tol_about, params: {}) ⇒ Tnrs
Returns a new instance of Tnrs.
29 30 31 32 |
# File 'lib/bark/request/tnrs.rb', line 29 def initialize(method: :tol_about, params: {}) (method: method, params: params) build_uri if valid? end |
Instance Method Details
#assign_options(method: method, params: params) ⇒ Object
34 35 36 37 38 |
# File 'lib/bark/request/tnrs.rb', line 34 def (method: method, params: params) @method = method @params = params @params ||= {} end |
#has_required_params? ⇒ Boolean
45 46 47 48 49 50 |
# File 'lib/bark/request/tnrs.rb', line 45 def has_required_params? #case @method #when :foo #end return true end |
#json_payload ⇒ Object
52 53 54 |
# File 'lib/bark/request/tnrs.rb', line 52 def json_payload JSON.generate(@params) end |
#valid? ⇒ Boolean
40 41 42 43 |
# File 'lib/bark/request/tnrs.rb', line 40 def valid? raise "Method #{@method} not recognized." if @method && !self.class::METHODS.keys.include?(@method) !@method.nil? && params_are_supported? && has_required_params? end |