Module: Taxa::OpenTreeOfLife::Taxonomy::Subtree

Included in:
Taxa::OpenTreeOfLife::Taxonomy
Defined in:
lib/taxa/open_tree_of_life/taxonomy/subtree.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#subtree(**parameters) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/taxa/open_tree_of_life/taxonomy/subtree.rb', line 10

def subtree(**parameters)
  ott_id = parameters[:ott_id]
  raise ArgumentError, 'ott_id required' if ott_id.nil?

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

  url = 'https://api.opentreeoflife.org/v3/taxonomy/subtree'
  response = @http_client.post(url, JSON.generate({ ott_id: ott_id, label_format: label_format }),
                               'Content-Type' => 'application/json')
  JSON.parse(response.body)
end