import com.mindee.MindeeClient;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.common.PredictResponse;
import com.mindee.product.invoice.InvoiceV4;
import java.io.File;
import java.io.IOException;
public class SimpleMindeeClient {
public static void main(String[] args) throws IOException {
// Init a new client
MindeeClient mindeeClient = new MindeeClient("my-api-key");
// Load a file from disk
LocalInputSource localInputSource = new LocalInputSource(
"/path/to/the/file.ext"
);
// Parse the file
Document<InvoiceV4> response = mindeeClient.parse(
InvoiceV4.class,
localInputSource
);
// Print a summary of the parsed data
System.out.println(response.getDocument().toString());
}
}
import com.mindee.MindeeClient;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.common.PredictResponse;
import com.mindee.product.custom.CustomV1;
import com.mindee.http.Endpoint;
import java.io.File;
import java.io.IOException;
public class SimpleMindeeClient {
public static void main(String[] args) throws IOException {
// Init a new client
MindeeClient mindeeClient = new MindeeClient("my-api-key");
// Init the endpoint for the custom document
Endpoint endpoint = new Endpoint("my-endpoint", "my-account");
// Load a file from disk
LocalInputSource localInputSource = new LocalInputSource(
"src/main/resources/invoices/invoice1.pdf"
);
// Parse the file
Document<CustomV1> customDocument = mindeeClient.parse(
localInputSource,
endpoint
);
}
}
import com.mindee.MindeeClient;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.common.AsyncPredictResponse;
import com.mindee.product.internationalid.InternationalIdV2;
import java.io.File;
import java.io.IOException;
public class SimpleMindeeClient {
public static void main(String[] args) throws IOException, InterruptedException {
String apiKey = "my-api-key";
String filePath = "/path/to/the/file.ext";
// Init a new client
MindeeClient mindeeClient = new MindeeClient(apiKey);
// Load a file from disk
LocalInputSource inputSource = new LocalInputSource(new File(filePath));
// Parse the file asynchronously
AsyncPredictResponse<InternationalIdV2> response = mindeeClient.enqueueAndParse(
InternationalIdV2.class,
inputSource
);
// Print a summary of the response
System.out.println(response.toString());
}
}
import com.mindee.MindeeClient;
import com.mindee.input.LocalInputSource;
import com.mindee.input.LocalResponse;
import com.mindee.input.WebhookSource;
import com.mindee.product.internationalid.InternationalIdV2;
import java.io.IOException;
public class SimpleMindeeClient {
public static void main(String[] args) throws IOException {
// Init a new client
MindeeClient mindeeClient = new MindeeClient("my-api-key");
// Load a file from disk
LocalInputSource localInputSource = new LocalInputSource(
"/path/to/the/file.ext"
);
// Enqueue the file
String jobId = client.enqueue(InternationalIdV2.class, localInputSource)
.getJob().getId();
// 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.
String jsonData = myHttpServer.getPostBodyAsString();
LocalResponse localResponse = new LocalResponse(jsonData);
// Verify the HMAC signature.
// You'll need to get the "X-Mindee-Hmac-Signature" custom HTTP header.
String hmacSignature = myHttpServer.getHeader("X-Mindee-Hmac-Signature");
boolean isValid = localResponse.isValidHmacSignature(
"obviously-fake-secret-key", hmacSignature
);
if (!isValid) {
throw new MyException("Bad HMAC signature! Is someone trying to do evil?");
}
// You can also use a File object as the input.
//LocalResponse localResponse = new LocalResponse(new File("/path/to/file.json"));
// Deserialize the response into Java objects
AsyncPredictResponse<InternationalIdV2> response = mindeeClient.loadPrediction(
InternationalIdV2.class,
localResponse
);
// Print a summary of the parsed data
System.out.println(response.getDocument().toString());
}
}