Package veryfi

Class NetworkClient

java.lang.Object
veryfi.NetworkClient

public abstract class NetworkClient extends Object
  • Field Details

    • logger

      protected final Logger logger
  • Constructor Details

    • NetworkClient

      public NetworkClient(Credentials credentials, int apiVersion)
      Creates an instance of NetworkClient.
      Parameters:
      credentials - the Credentials provided by Veryfi.
      apiVersion - the int api version to use Veryfi.
    • NetworkClient

      public NetworkClient(Credentials credentials, int apiVersion, HttpClient httpClient)
      Creates an instance of NetworkClient.
      Parameters:
      credentials - the Credentials provided by Veryfi.
      apiVersion - the int api version to use Veryfi.
      httpClient - HttpClient for the Veryfi API
  • Method Details

    • request

      protected String request(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments)
      Submit the HTTP request.
      Parameters:
      httpVerb - HTTP Method
      endpointName - Endpoint name such as 'documents', 'users', etc.
      requestArguments - JSON payload to send to Veryfi
      Returns:
      A JSON of the response data.
    • requestAsync

      protected CompletableFuture<String> requestAsync(HttpMethod httpVerb, String endpointName, org.json.JSONObject requestArguments)
      Submit the HTTP request.
      Parameters:
      httpVerb - HTTP Method
      endpointName - Endpoint name such as 'documents', 'users', etc.
      requestArguments - JSON payload to send to Veryfi
      Returns:
      A JSON of the response data.
    • setTimeOut

      public void setTimeOut(int timeOut)
      Define new time out for the requests in seconds
      Parameters:
      timeOut - of the http requests in seconds
    • setBaseUrl

      public void setBaseUrl(String baseUrl)
      By default, the base URL is https://api.veryfi.com/api/;
      Parameters:
      baseUrl - for the Veryfi API
    • setHttpClient

      public void setHttpClient(HttpClient httpClient)
      By default is https://api.veryfi.com/api/;
      Parameters:
      httpClient - HttpClient for the Veryfi API
    • addFileToParameters

      protected org.json.JSONObject addFileToParameters(String filePath, 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 extraction
      parameters - Additional request parameters
      Returns:
      the JSON object of the parameters of the request
    • addUrlToParameters

      protected org.json.JSONObject addUrlToParameters(String fileUrl, List<String> fileUrls, 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"]
      parameters - Additional request parameters
      Returns:
      JSON object of the request arguments