com.sixestates.example.FAASExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of idp-sdk Show documentation
Show all versions of idp-sdk Show documentation
A Java SDK for communicating with the 6Estates Intelligent Document Processing(IDP) Platform
package com.sixestates.example;
import com.sixestates.Idp;
import com.sixestates.exception.ApiConnectionException;
import com.sixestates.exception.ApiException;
import com.sixestates.rest.v1.FAASSubmitter;
import com.sixestates.rest.v1.ResultExtractor;
import com.sixestates.type.FAASTaskInfo;
import com.sixestates.type.TaskDTO;
import com.sixestates.utils.Lists;
import java.io.File;
public class FAASExample {
public static final String TOKEN = "XXXXXXX";
public static final String FILE_PATH = "/Users/6e/Downloads/CBKS.pdf" ;
/**
* Example FAAS usage.
*
* @param args command line args
* @throws Exception if unable to generate InterruptedException or ApiException
*/
public static void main(String[] args) throws Exception {
Idp.init(TOKEN);
// Submit a task
TaskDTO taskDto = null;
try {
FAASTaskInfo taskInfo = FAASTaskInfo.builder()
.files(Lists.newArrayList(new File(FILE_PATH)))
.customerType("2")
.informationType(0)
.build();
taskDto = FAASSubmitter.submitFAASTask(taskInfo);
System.out.println("taskId: " + taskDto.getData());
}catch (final ApiException | ApiConnectionException e) {
System.err.println(e);
}
// Extract the result
if(taskDto != null && taskDto.getStatus() == 200) {
try {
System.out.println(ResultExtractor.extractResultByTaskid(taskDto.getData()));
}catch (ApiException e) {
System.err.println(e);
}
}
}
}