Package com.selectpdf

Class ApiClient

java.lang.Object
com.selectpdf.ApiClient
Direct Known Subclasses:
AsyncJobClient, HtmlToPdfClient, PdfMergeClient, PdfToTextClient, UsageClient, WebElementsClient

public class ApiClient
extends java.lang.Object
Base class for API clients. Do not use this directly.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.lang.String apiAsyncEndpoint
    API async jobs endpoint
    protected java.lang.String apiEndpoint
    API endpoint
    protected java.lang.String apiWebElementsEndpoint
    API web elements endpoint
    int AsyncCallsMaxPings
    Maximum number of pings for asynchronous calls.
    int AsyncCallsPingInterval
    Ping interval in seconds for asynchronous calls.
    protected java.util.HashMap<java.lang.String,​byte[]> binaryData
    Binary data that will be sent to the API.
    static java.lang.String CLIENT_VERSION
    Library version
    protected java.util.HashMap<java.lang.String,​java.lang.String> files
    Files that will be sent to the API.
    protected java.util.HashMap<java.lang.String,​java.lang.String> headers
    HTTP Headers that will be sent to the API.
    protected java.lang.String jobId
    Job ID for asynchronous calls or for calls that require a second request.
    protected int lastHTTPCode
    Last HTTP Code
    protected static java.lang.String MULTIPART_FORM_DATA_BOUNDARY  
    protected static java.lang.String NEW_LINE  
    protected int numberOfPages
    Number of pages of the pdf document resulted from the conversion.
    protected java.util.HashMap<java.lang.String,​java.lang.String> parameters
    Parameters that will be sent to the API.
  • Constructor Summary

    Constructors 
    Constructor Description
    ApiClient()  
  • Method Summary

    Modifier and Type Method Description
    int getNumberOfPages()
    Get the number of pages processed from the PDF document.
    protected byte[] performPost​(java.io.OutputStream outStream)
    Create a POST request.
    protected byte[] performPostAsMultipartFormData​(java.io.OutputStream outStream)
    Create a multipart/form-data POST request (that can handle file uploads).
    protected java.lang.String serializeDictionary​(java.util.HashMap<java.lang.String,​java.lang.String> dictionaryToSerialize)
    Serialize dictionary.
    protected java.lang.String serializeParameters()
    Serialize parameters.
    void setApiAsyncEndpoint​(java.lang.String apiAsyncEndpoint)
    Set a custom SelectPdf API endpoint for async jobs.
    void setApiEndpoint​(java.lang.String apiEndpoint)
    Set a custom SelectPdf API endpoint.
    void setApiWebElementsEndpoint​(java.lang.String apiWebElementsEndpoint)
    Set a custom SelectPdf API endpoint for web elements.
    java.lang.String startAsyncJob()
    Start an asynchronous job.
    java.lang.String startAsyncJobMultipartFormData()
    Start an asynchronous job that requires multipart forma data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • apiEndpoint

      protected java.lang.String apiEndpoint
      API endpoint
    • apiAsyncEndpoint

      protected java.lang.String apiAsyncEndpoint
      API async jobs endpoint
    • apiWebElementsEndpoint

      protected java.lang.String apiWebElementsEndpoint
      API web elements endpoint
    • parameters

      protected java.util.HashMap<java.lang.String,​java.lang.String> parameters
      Parameters that will be sent to the API.
    • headers

      protected java.util.HashMap<java.lang.String,​java.lang.String> headers
      HTTP Headers that will be sent to the API.
    • files

      protected java.util.HashMap<java.lang.String,​java.lang.String> files
      Files that will be sent to the API.
    • binaryData

      protected java.util.HashMap<java.lang.String,​byte[]> binaryData
      Binary data that will be sent to the API.
    • numberOfPages

      protected int numberOfPages
      Number of pages of the pdf document resulted from the conversion.
    • jobId

      protected java.lang.String jobId
      Job ID for asynchronous calls or for calls that require a second request.
    • lastHTTPCode

      protected int lastHTTPCode
      Last HTTP Code
    • CLIENT_VERSION

      public static final java.lang.String CLIENT_VERSION
      Library version
      See Also:
      Constant Field Values
    • MULTIPART_FORM_DATA_BOUNDARY

      protected static final java.lang.String MULTIPART_FORM_DATA_BOUNDARY
      See Also:
      Constant Field Values
    • NEW_LINE

      protected static final java.lang.String NEW_LINE
      See Also:
      Constant Field Values
    • AsyncCallsPingInterval

      public int AsyncCallsPingInterval
      Ping interval in seconds for asynchronous calls. Default value is 3 seconds.
    • AsyncCallsMaxPings

      public int AsyncCallsMaxPings
      Maximum number of pings for asynchronous calls. Default value is 1,000 pings.
  • Constructor Details

  • Method Details

    • setApiEndpoint

      public void setApiEndpoint​(java.lang.String apiEndpoint)
      Set a custom SelectPdf API endpoint. Do not use this method unless advised by SelectPdf.
      Parameters:
      apiEndpoint - API endpoint.
    • setApiAsyncEndpoint

      public void setApiAsyncEndpoint​(java.lang.String apiAsyncEndpoint)
      Set a custom SelectPdf API endpoint for async jobs. Do not use this method unless advised by SelectPdf.
      Parameters:
      apiAsyncEndpoint - API endpoint.
    • setApiWebElementsEndpoint

      public void setApiWebElementsEndpoint​(java.lang.String apiWebElementsEndpoint)
      Set a custom SelectPdf API endpoint for web elements. Do not use this method unless advised by SelectPdf.
      Parameters:
      apiWebElementsEndpoint - API endpoint.
    • getNumberOfPages

      public int getNumberOfPages()
      Get the number of pages processed from the PDF document.
      Returns:
      Number of pages processed from the PDF document.
    • serializeParameters

      protected java.lang.String serializeParameters()
      Serialize parameters.
      Returns:
      Serialized parameters.
    • serializeDictionary

      protected java.lang.String serializeDictionary​(java.util.HashMap<java.lang.String,​java.lang.String> dictionaryToSerialize)
      Serialize dictionary.
      Parameters:
      dictionaryToSerialize - Dictionary to serialize.
      Returns:
      Serialized dictionary.
    • performPost

      protected byte[] performPost​(java.io.OutputStream outStream)
      Create a POST request.
      Parameters:
      outStream - Output response to this stream, if specified.
      Returns:
      If output stream is not specified, return response as byte array.
    • performPostAsMultipartFormData

      protected byte[] performPostAsMultipartFormData​(java.io.OutputStream outStream)
      Create a multipart/form-data POST request (that can handle file uploads).
      Parameters:
      outStream - Output response to this stream, if specified.
      Returns:
      If output stream is not specified, return response as byte array.
    • startAsyncJob

      public java.lang.String startAsyncJob()
      Start an asynchronous job.
      Returns:
      Asynchronous job ID.
    • startAsyncJobMultipartFormData

      public java.lang.String startAsyncJobMultipartFormData()
      Start an asynchronous job that requires multipart forma data.
      Returns:
      Asynchronous job ID.