Document Loading
Document Loading
Calling the Mindee API using webhooks
# Load a file from disk
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
# Send the file to the server
enqueue_response = mindee_client.enqueue(
input_source,
Mindee::Product::Receipt::ReceiptV5 # ReceiptV5 supports asynchronous polling
)# Load the JSON string sent by the Mindee webhook POST callback.
# Reading the callback data will vary greatly depending on your HTTP server.
# This is therefore beyond the scope of this example.
local_response = Mindee::Input::LocalResponse.new(request.body.string)
# You can also use a File object as the input.
# FILE_PATH = File.join('path', 'to', 'file.json').freeze
# local_response = Mindee::Input::LocalResponse.new(FILE_PATH);
# Optional: verify the HMAC signature.
unless local_response.valid_hmac_signature?(my_secret_key, 'invalid signature')
raise "Invalid HMAC signature!"
end
# Deserialize the response:
result = mindee_client.load_prediction(
Mindee::Product::Receipt::ReceiptV5, # The prediction type must match the initial enqueuing to work properly.
local_response
)
# Print a summary of the parsed data in RST format
puts result.documentParsing operations
Polling options
Page operations
Workflow operations
Enqueueing and polling manually
Loading a Document File
Loading from a Local Path
Loading from a File Object
Loading from a Base64-Encoded String
Loading from Raw Bytes
Loading by URL
Under the Hood - Local Input Source Details
Last updated
Was this helpful?

