Method: Mindee::Client#load_prediction

Defined in:
lib/mindee/client.rb

#load_prediction(product_class, local_response) ⇒ Mindee::Parsing::Common::ApiResponse

Load a prediction.

Parameters:

Returns:



326
327
328
329
330
331
332
333
334
335
# File 'lib/mindee/client.rb', line 326

def load_prediction(product_class, local_response)
  raise Errors::MindeeAPIError, 'Expected LocalResponse to not be nil.' if local_response.nil?

  response_hash = local_response.as_hash || {}
  raise Errors::MindeeAPIError, 'Expected LocalResponse#as_hash to return a hash.' if response_hash.nil?

  Mindee::Parsing::Common::ApiResponse.new(product_class, response_hash, response_hash.to_json)
rescue KeyError, Errors::MindeeAPIError
  raise Errors::MindeeInputError, 'No prediction found in local response.'
end