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.StringapiAsyncEndpointAPI async jobs endpointprotected java.lang.StringapiEndpointAPI endpointprotected java.lang.StringapiWebElementsEndpointAPI web elements endpointintAsyncCallsMaxPingsMaximum number of pings for asynchronous calls.intAsyncCallsPingIntervalPing interval in seconds for asynchronous calls.protected java.util.HashMap<java.lang.String,byte[]>binaryDataBinary data that will be sent to the API.static java.lang.StringCLIENT_VERSIONLibrary versionprotected java.util.HashMap<java.lang.String,java.lang.String>filesFiles that will be sent to the API.protected java.util.HashMap<java.lang.String,java.lang.String>headersHTTP Headers that will be sent to the API.protected java.lang.StringjobIdJob ID for asynchronous calls or for calls that require a second request.protected intlastHTTPCodeLast HTTP Codeprotected static java.lang.StringMULTIPART_FORM_DATA_BOUNDARYprotected static java.lang.StringNEW_LINEprotected intnumberOfPagesNumber of pages of the pdf document resulted from the conversion.protected java.util.HashMap<java.lang.String,java.lang.String>parametersParameters that will be sent to the API. -
Constructor Summary
Constructors Constructor Description ApiClient() -
Method Summary
Modifier and Type Method Description intgetNumberOfPages()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.StringserializeDictionary(java.util.HashMap<java.lang.String,java.lang.String> dictionaryToSerialize)Serialize dictionary.protected java.lang.StringserializeParameters()Serialize parameters.voidsetApiAsyncEndpoint(java.lang.String apiAsyncEndpoint)Set a custom SelectPdf API endpoint for async jobs.voidsetApiEndpoint(java.lang.String apiEndpoint)Set a custom SelectPdf API endpoint.voidsetApiWebElementsEndpoint(java.lang.String apiWebElementsEndpoint)Set a custom SelectPdf API endpoint for web elements.java.lang.StringstartAsyncJob()Start an asynchronous job.java.lang.StringstartAsyncJobMultipartFormData()Start an asynchronous job that requires multipart forma data.
-
Field Details
-
apiEndpoint
protected java.lang.String apiEndpointAPI endpoint -
apiAsyncEndpoint
protected java.lang.String apiAsyncEndpointAPI async jobs endpoint -
apiWebElementsEndpoint
protected java.lang.String apiWebElementsEndpointAPI web elements endpoint -
parameters
protected java.util.HashMap<java.lang.String,java.lang.String> parametersParameters that will be sent to the API. -
headers
protected java.util.HashMap<java.lang.String,java.lang.String> headersHTTP Headers that will be sent to the API. -
files
protected java.util.HashMap<java.lang.String,java.lang.String> filesFiles that will be sent to the API. -
binaryData
protected java.util.HashMap<java.lang.String,byte[]> binaryDataBinary data that will be sent to the API. -
numberOfPages
protected int numberOfPagesNumber of pages of the pdf document resulted from the conversion. -
jobId
protected java.lang.String jobIdJob ID for asynchronous calls or for calls that require a second request. -
lastHTTPCode
protected int lastHTTPCodeLast HTTP Code -
CLIENT_VERSION
public static final java.lang.String CLIENT_VERSIONLibrary 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 AsyncCallsPingIntervalPing interval in seconds for asynchronous calls. Default value is 3 seconds. -
AsyncCallsMaxPings
public int AsyncCallsMaxPingsMaximum number of pings for asynchronous calls. Default value is 1,000 pings.
-
-
Constructor Details
-
ApiClient
public ApiClient()
-
-
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.
-