Class: Bark::Request::GraphOfLife

Inherits:
Bark::Request show all
Defined in:
lib/bark/request/graph_of_life.rb

Constant Summary collapse

API_VERSION =
'v2'
SEARCH_BASE =
[Bark::Request::BASE_URL, API_VERSION, 'graph'].join("/")
METHODS =

Method: parameters

{ 
  gol_about: %i{},
  gol_source_tree: %i{},
  gol_node_info: %i{}, #  tree_id "is superflous and can be ignored"
}
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

BASE_URL

Instance Attribute Summary

Attributes inherited from Bark::Request

#method, #params, #payload, #uri

Instance Method Summary collapse

Methods inherited from Bark::Request

#params_are_supported?, #response

Constructor Details

#initialize(method: :tol_about, params: {}) ⇒ GraphOfLife

Returns a new instance of GraphOfLife.



29
30
31
32
# File 'lib/bark/request/graph_of_life.rb', line 29

def initialize(method: :tol_about, params: {})
  assign_options(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/graph_of_life.rb', line 34

def assign_options(method: method, params: params)
  @method = method
  @params = params
  @params ||= {}
end

#has_required_params?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
# File 'lib/bark/request/graph_of_life.rb', line 45

def has_required_params?
  case @method
  when :gol_of_life
  end
 return true
end

#json_payloadObject



52
53
54
# File 'lib/bark/request/graph_of_life.rb', line 52

def json_payload
  JSON.generate(@params)
end

#valid?Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/bark/request/graph_of_life.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