Module: Taxa::OpenTreeOfLife::TreeOfLife::InducedSubtree

Included in:
Taxa::OpenTreeOfLife::TreeOfLife
Defined in:
lib/taxa/open_tree_of_life/tree_of_life/induced_subtree.rb

Overview

wrapper around the node_info tree of life endpoint for Open Tree of Life

Instance Method Summary collapse

Instance Method Details

#induced_subtree(**parameters) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/taxa/open_tree_of_life/tree_of_life/induced_subtree.rb', line 10

def induced_subtree(**parameters)
  ott_ids = parameters[:ott_ids]
  node_ids = parameters[:node_ids]

  validate_ott_and_node_ids(ott_ids, node_ids)

  label_format = get_label_format('newick', **parameters)

  payload = { node_ids: node_ids, ott_ids: ott_ids, label_format: label_format }.compact
  url = 'https://api.opentreeoflife.org/v3/tree_of_life/induced_subtree'
  response = @http_client.post(url, JSON.generate(payload), 'Content-Type' => 'application/json')
  JSON.parse(response.body)
end