Method: Mindee::HTTP::WorkflowEndpoint#execute_workflow

Defined in:
lib/mindee/http/workflow_endpoint.rb

#execute_workflow(input_source, opts) ⇒ Array

Sends a document to the workflow.

Parameters:

Returns:

  • (Array)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mindee/http/workflow_endpoint.rb', line 29

def execute_workflow(input_source, opts)
  check_api_key
  response = workflow_execution_req_post(input_source, opts)
  if response.nil?
    raise Mindee::Errors::MindeeHTTPError.new(
      { code: 0, details: 'Server response was nil.', message: 'Unknown error.' }, @url, 0
    )
  end

  hashed_response = JSON.parse(response.body, object_class: Hash)
  return [hashed_response, response.body] if ResponseValidation.valid_async_response?(response)

  ResponseValidation.clean_request!(response)
  error = Mindee::HTTP::ErrorHandler.handle_error(@url_name, response)
  raise error
end