Module: Taxa::OpenTreeOfLife::TNRS::InferContext

Included in:
Taxa::OpenTreeOfLife::TNRS
Defined in:
lib/taxa/open_tree_of_life/tnrs/infer_context.rb

Overview

tnrs contexts api endpoint

Instance Method Summary collapse

Instance Method Details

#infer_context(**parameters) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
# File 'lib/taxa/open_tree_of_life/tnrs/infer_context.rb', line 10

def infer_context(**parameters)
  names = parameters[:names]
  raise ArgumentError if names.nil?

  payload = { names: names }
  url = 'https://api.opentreeoflife.org/v3/tnrs/infer_context'
  response = @http_client.post(url, JSON.generate(payload), 'Content-Type' => 'application/json')
  JSON.parse(response.body)
end