Package veryfi
Class ClientImpl
java.lang.Object
veryfi.ClientImpl
- All Implemented Interfaces:
Client
Veryfi API client for Java.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionClientImpl
(String clientId, String clientSecret, String username, String apiKey, int apiVersion) Creates an instance ofClientImpl
. -
Method Summary
Modifier and TypeMethodDescriptionaddLineItem
(String documentId, AddLineItem payload) Add a new line item on an existing document.addLineItemAsync
(String documentId, AddLineItem payload) Add a new line item on an existing document.deleteDocument
(String documentId) Delete Document from VeryfideleteDocumentAsync
(String documentId) Delete Document from VeryfideleteLineItem
(String documentId, String lineItemId) Delete an existing line item on an existing document.deleteLineItemAsync
(String documentId, String lineItemId) Delete an existing line item on an existing document.deleteLineItems
(String documentId) Delete all line items on an existing document.deleteLineItemsAsync
(String documentId) Delete all line items on an existing document.private String
generateSignature
(Long timeStamp, org.json.JSONObject payloadParams) Generate unique signature for payload params.private String
Returns aString
ApiKey for the headers of the request.getDocument
(String documentId) Returns a json stringString
document informationgetDocumentAsync
(String documentId) Returns a json stringCompletableFuture<String>
document information.Returns a json stringString
with the list of documents.Returns a json stringCompletableFuture<String>
list of documents.getHeaders
(org.json.JSONObject requestArguments) Prepares the headers needed for a request.private HttpRequest
getHttpRequest
(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments) Creates the HTTP request Object.getLineItem
(String documentId, String lineItemId) Retrieve a line item for existing document by ID.getLineItemAsync
(String documentId, String lineItemId) Retrieve a line item for existing document by ID.getLineItems
(String documentId) Retrieve all line items for a document.getLineItemsAsync
(String documentId) Retrieve all line items for a document.org.json.JSONObject
getProcessDocumentArguments
(String filePath, List<String> categories, boolean deleteAfterProcessing, org.json.JSONObject parameters) Creates the JSON Object for the parameters of the requestorg.json.JSONObject
getProcessDocumentUrlArguments
(String fileUrl, List<String> fileUrls, List<String> categories, boolean deleteAfterProcessing, int maxPagesToProcess, boolean boostMode, String externalId, org.json.JSONObject parameters) Creates the JSON object of the parameters of the requestprivate String
getUrl()
Returns aString
API Base URL with API Version.processDocument
(String filePath, List<String> categories, boolean deleteAfterProcessing, org.json.JSONObject parameters) Process a document and extract all the fields from itprocessDocumentAsync
(String filePath, List<String> categories, boolean deleteAfterProcessing, org.json.JSONObject parameters) Process a document and extract all the fields from itprocessDocumentUrl
(String fileUrl, List<String> fileUrls, List<String> categories, boolean deleteAfterProcessing, int maxPagesToProcess, boolean boostMode, String externalId, org.json.JSONObject parameters) Process Document from url and extract all the fields from it.processDocumentUrlAsync
(String fileUrl, List<String> fileUrls, List<String> categories, boolean deleteAfterProcessing, int maxPagesToProcess, boolean boostMode, String externalId, org.json.JSONObject parameters) Process Document from url and extract all the fields from it.private String
request
(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments) Submit the HTTP request.private CompletableFuture<String>
requestAsync
(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments) Submit the HTTP request.void
setBaseUrl
(String baseUrl) By default, the base URL is https://api.veryfi.com/api/;void
setHttpClient
(HttpClient httpClient) By default is https://api.veryfi.com/api/;void
setTimeOut
(int timeOut) Define new time out for the requests in secondsupdateDocument
(String documentId, org.json.JSONObject parameters) Update data for a previously processed document, including almost any field like `vendor`, `date`, `notes` etc.updateDocumentAsync
(String documentId, org.json.JSONObject parameters) Update data for a previously processed document, including almost any field like `vendor`, `date`, `notes` etc.updateLineItem
(String documentId, String lineItemId, UpdateLineItem payload) Update an existing line item on an existing document.updateLineItemAsync
(String documentId, String lineItemId, UpdateLineItem payload) Update an existing line item on an existing document.
-
Field Details
-
logger
-
clientId
-
clientSecret
-
username
-
apiKey
-
apiVersion
private final int apiVersion -
baseUrl
-
timeOut
private int timeOut -
httpClient
-
-
Constructor Details
-
ClientImpl
public ClientImpl(String clientId, String clientSecret, String username, String apiKey, int apiVersion) Creates an instance ofClientImpl
.
-
-
Method Details
-
getUrl
Returns aString
API Base URL with API Version.- Returns:
- the url
String
-
request
private String request(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments) Submit the HTTP request.- Parameters:
httpVerb
- HTTP MethodendpointName
- Endpoint name such as 'documents', 'users', etc.requestArguments
- JSON payload to send to Veryfi- Returns:
- A JSON of the response data.
-
requestAsync
private CompletableFuture<String> requestAsync(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments) Submit the HTTP request.- Parameters:
httpVerb
- HTTP MethodendpointName
- Endpoint name such as 'documents', 'users', etc.requestArguments
- JSON payload to send to Veryfi- Returns:
- A JSON of the response data.
-
getHttpRequest
private HttpRequest getHttpRequest(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments) Creates the HTTP request Object.- Parameters:
httpVerb
- HTTP MethodendpointName
- Endpoint name such as 'documents', 'users', etc.requestArguments
- JSON payload to send to Veryfi- Returns:
- request Object for the HttpClient
HttpRequest
-
getApiKey
Returns aString
ApiKey for the headers of the request.- Returns:
- the ApiKey
String
-
getHeaders
Prepares the headers needed for a request. -
generateSignature
Generate unique signature for payload params.- Parameters:
timeStamp
- Unix Long timestamppayloadParams
- JSON params to be sent to API request- Returns:
- Unique signature generated using the client_secret and the payload
-
getDocuments
Returns a json stringString
with the list of documents.- Specified by:
getDocuments
in interfaceClient
- Returns:
- the url
String
-
getDocumentsAsync
Returns a json stringCompletableFuture<String>
list of documents.- Specified by:
getDocumentsAsync
in interfaceClient
- Returns:
- the list of previously processed documents
String
-
getDocument
Returns a json stringString
document information- Specified by:
getDocument
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to retrieve.- Returns:
- the data extracted from the Document
String
-
getDocumentAsync
Returns a json stringCompletableFuture<String>
document information.- Specified by:
getDocumentAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to retrieve.- Returns:
- the data extracted from the Document
String
-
getProcessDocumentArguments
public org.json.JSONObject getProcessDocumentArguments(String filePath, List<String> categories, boolean deleteAfterProcessing, org.json.JSONObject parameters) Creates the JSON Object for the parameters of the request- Parameters:
filePath
- Path on disk to a file to submit for data extractioncategories
- List of categories Veryfi can use to categorize the documentdeleteAfterProcessing
- Delete this document from Veryfi after data has been extractedparameters
- Additional request parameters- Returns:
- the JSON object of the parameters of the request
-
processDocument
public String processDocument(String filePath, List<String> categories, boolean deleteAfterProcessing, org.json.JSONObject parameters) Process a document and extract all the fields from it- Specified by:
processDocument
in interfaceClient
- Parameters:
filePath
- Path on disk to a file to submit for data extractioncategories
- List of categories Veryfi can use to categorize the documentdeleteAfterProcessing
- Delete this document from Veryfi after data has been extractedparameters
- Additional request parameters- Returns:
- the data extracted from the Document
String
-
processDocumentAsync
public CompletableFuture<String> processDocumentAsync(String filePath, List<String> categories, boolean deleteAfterProcessing, org.json.JSONObject parameters) Process a document and extract all the fields from it- Specified by:
processDocumentAsync
in interfaceClient
- Parameters:
filePath
- Path on disk to a file to submit for data extractioncategories
- List of categories Veryfi can use to categorize the documentdeleteAfterProcessing
- Delete this document from Veryfi after data has been extractedparameters
- Additional request parameters- Returns:
- the data extracted from the Document
CompletableFuture<String>
-
getProcessDocumentUrlArguments
public org.json.JSONObject getProcessDocumentUrlArguments(String fileUrl, List<String> fileUrls, List<String> categories, boolean deleteAfterProcessing, int maxPagesToProcess, boolean boostMode, String externalId, org.json.JSONObject parameters) Creates the JSON object of the parameters of the request- Parameters:
fileUrl
- Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. "https://cdn.example.com/receipt.jpg".fileUrls
- Required if file_url isn't specifies. List of publicly accessible URLs to multiple files, e.g. ["https://cdn.example.com/receipt1.jpg", "https://cdn.example.com/receipt2.jpg"]categories
- List of categories to use when categorizing the documentdeleteAfterProcessing
- Delete this document from Veryfi after data has been extractedmaxPagesToProcess
- When sending a long document to Veryfi for processing, this parameter controls how many pages of the document will be read and processed, starting from page 1.boostMode
- Flag that tells Veryfi whether boost mode should be enabled. When set to 1, Veryfi will skip data enrichment steps, but will process the document faster. Default value for this flag is 0externalId
- Optional custom document identifier. Use this if you would like to assign your own ID to documentsparameters
- Additional request parameters- Returns:
- JSON object of the request arguments
-
processDocumentUrl
public String processDocumentUrl(String fileUrl, List<String> fileUrls, List<String> categories, boolean deleteAfterProcessing, int maxPagesToProcess, boolean boostMode, String externalId, org.json.JSONObject parameters) Process Document from url and extract all the fields from it.- Specified by:
processDocumentUrl
in interfaceClient
- Parameters:
fileUrl
- Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. "https://cdn.example.com/receipt.jpg".fileUrls
- Required if file_url isn't specifies. List of publicly accessible URLs to multiple files, e.g. ["https://cdn.example.com/receipt1.jpg", "https://cdn.example.com/receipt2.jpg"]categories
- List of categories to use when categorizing the documentdeleteAfterProcessing
- Delete this document from Veryfi after data has been extractedmaxPagesToProcess
- When sending a long document to Veryfi for processing, this parameter controls how many pages of the document will be read and processed, starting from page 1.boostMode
- Flag that tells Veryfi whether boost mode should be enabled. When set to 1, Veryfi will skip data enrichment steps, but will process the document faster. Default value for this flag is 0externalId
- Optional custom document identifier. Use this if you would like to assign your own ID to documentsparameters
- Additional request parameters- Returns:
- the data extracted from the Document
String
-
processDocumentUrlAsync
public CompletableFuture<String> processDocumentUrlAsync(String fileUrl, List<String> fileUrls, List<String> categories, boolean deleteAfterProcessing, int maxPagesToProcess, boolean boostMode, String externalId, org.json.JSONObject parameters) Process Document from url and extract all the fields from it.- Specified by:
processDocumentUrlAsync
in interfaceClient
- Parameters:
fileUrl
- Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. "https://cdn.example.com/receipt.jpg".fileUrls
- Required if file_url isn't specifies. List of publicly accessible URLs to multiple files, e.g. ["https://cdn.example.com/receipt1.jpg", "https://cdn.example.com/receipt2.jpg"]categories
- List of categories to use when categorizing the documentdeleteAfterProcessing
- Delete this document from Veryfi after data has been extractedmaxPagesToProcess
- When sending a long document to Veryfi for processing, this parameter controls how many pages of the document will be read and processed, starting from page 1.boostMode
- Flag that tells Veryfi whether boost mode should be enabled. When set to 1, Veryfi will skip data enrichment steps, but will process the document faster. Default value for this flag is 0externalId
- Optional custom document identifier. Use this if you would like to assign your own ID to documentsparameters
- Additional request parameters- Returns:
- the data extracted from the Document
CompletableFuture<String>
-
deleteDocument
Delete Document from Veryfi- Specified by:
deleteDocument
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to delete.- Returns:
- the response data.
String
-
deleteDocumentAsync
Delete Document from Veryfi- Specified by:
deleteDocumentAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to delete.- Returns:
- the response data.
CompletableFuture<String>
-
updateDocument
Update data for a previously processed document, including almost any field like `vendor`, `date`, `notes` etc.- Specified by:
updateDocument
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to update.parameters
- Additional request parameters- Returns:
- A document json with updated fields, if fields are writable. Otherwise, a document with unchanged fields.
String
-
updateDocumentAsync
public CompletableFuture<String> updateDocumentAsync(String documentId, org.json.JSONObject parameters) Update data for a previously processed document, including almost any field like `vendor`, `date`, `notes` etc.- Specified by:
updateDocumentAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to update.parameters
- Additional request parameters- Returns:
- A document json with updated fields, if fields are writable. Otherwise, a document with unchanged fields.
CompletableFuture<String>
-
getLineItems
Retrieve all line items for a document.- Specified by:
getLineItems
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to retrieve.- Returns:
- List of line items extracted from the document.
String
-
getLineItemsAsync
Retrieve all line items for a document.- Specified by:
getLineItemsAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to retrieve.- Returns:
- List of line items extracted from the document.
CompletableFuture<String>
-
getLineItem
Retrieve a line item for existing document by ID.- Specified by:
getLineItem
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to retrieve.lineItemId
- ID of the line item you'd like to retrieve.- Returns:
- Line item extracted from the document.
String
-
getLineItemAsync
Retrieve a line item for existing document by ID.- Specified by:
getLineItemAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to retrieve.lineItemId
- ID of the line item you'd like to retrieve.- Returns:
- Line item extracted from the document.
CompletableFuture<String>
-
addLineItem
Add a new line item on an existing document.- Specified by:
addLineItem
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to update.payload
- line item object to add.- Returns:
- Added line item data.
String
- Throws:
NotValidModelException
- when the model is not valid it throws this exception.
-
addLineItemAsync
public CompletableFuture<String> addLineItemAsync(String documentId, AddLineItem payload) throws NotValidModelException Add a new line item on an existing document.- Specified by:
addLineItemAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to update.payload
- line item object to add.- Returns:
- Added line item data.
CompletableFuture<String>
- Throws:
NotValidModelException
- when the model is not valid it throws this exception.
-
updateLineItem
public String updateLineItem(String documentId, String lineItemId, UpdateLineItem payload) throws NotValidModelException Update an existing line item on an existing document.- Specified by:
updateLineItem
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to update.lineItemId
- ID of the line item you'd like to update.payload
- line item object to update.- Returns:
- Line item data with updated fields, if fields are writable. Otherwise line item data with unchanged fields.
String
- Throws:
NotValidModelException
- when the model is not valid it throws this exception.
-
updateLineItemAsync
public CompletableFuture<String> updateLineItemAsync(String documentId, String lineItemId, UpdateLineItem payload) throws NotValidModelException Update an existing line item on an existing document.- Specified by:
updateLineItemAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to update.lineItemId
- ID of the line item you'd like to update.payload
- line item object to update.- Returns:
- Line item data with updated fields, if fields are writable. Otherwise line item data with unchanged fields.
CompletableFuture<String>
- Throws:
NotValidModelException
- when the model is not valid it throws this exception.
-
deleteLineItems
Delete all line items on an existing document.- Specified by:
deleteLineItems
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to delete.- Returns:
- the response data.
String
-
deleteLineItemsAsync
Delete all line items on an existing document.- Specified by:
deleteLineItemsAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to delete.- Returns:
-
deleteLineItem
Delete an existing line item on an existing document.- Specified by:
deleteLineItem
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to delete.lineItemId
- ID of the line item you'd like to delete.- Returns:
- the response data.
String
-
deleteLineItemAsync
Delete an existing line item on an existing document.- Specified by:
deleteLineItemAsync
in interfaceClient
- Parameters:
documentId
- ID of the document you'd like to delete.lineItemId
- ID of the line item you'd like to delete.- Returns:
- the response data.
CompletableFuture<String>
-
setTimeOut
public void setTimeOut(int timeOut) Define new time out for the requests in seconds- Specified by:
setTimeOut
in interfaceClient
- Parameters:
timeOut
- of the http requests in seconds
-
setBaseUrl
By default, the base URL is https://api.veryfi.com/api/;- Specified by:
setBaseUrl
in interfaceClient
- Parameters:
baseUrl
- for the Veryfi API
-
setHttpClient
Description copied from interface:Client
By default is https://api.veryfi.com/api/;- Specified by:
setHttpClient
in interfaceClient
- Parameters:
httpClient
- for the Veryfi API
-