public abstract class Request
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Config |
config
Configuration object for the API communication
|
protected CommunicationFormat |
outputFormat
Output format from the API (for some requests may be XML or JSON)
|
Constructor and Description |
---|
Request() |
Modifier and Type | Method and Description |
---|---|
void |
addRequestParam(java.lang.String name,
java.math.BigDecimal value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name,
double value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name,
int value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name,
java.lang.String value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name,
java.lang.String[] value)
Adds a parameter to the API request.
|
void |
addStandardParams()
Add the parameters that should be present in every API call.
|
void |
clearRequestParams()
Clears the request parameters.
|
java.lang.String |
createApiCallFormHtml()
Creates a minimal HTML document, containing a form with all the request
parameters.
|
java.lang.String |
createApiCallFormHtml(java.lang.String title)
Creates a minimal HTML document, containing a form with all the request
parameters.
|
java.lang.String |
createApiCallFormHtml(java.lang.String title,
java.lang.String content)
Creates a minimal HTML document, containing a form with all the request
parameters.
|
java.lang.String |
createSignature()
Create a signature for the API request parameters using the store private key.
|
Config |
getConfig() |
CommunicationFormat |
getOutputFormat() |
java.util.Map<java.lang.String,java.lang.String[]> |
getSignedRequestParams()
Returns all the API request parameters and generates a signature for them,
if one is not present.
|
protected BasicResponse |
processApiCall()
Makes a request to the API using and returns the decoded API response.
|
void |
removeRequestParam(java.lang.String name)
Removes a parameter, if it exists, from the API request.
|
void |
setConfig(Config config) |
void |
setOutputFormat(CommunicationFormat outputFormat) |
protected Config config
protected CommunicationFormat outputFormat
public Config getConfig()
public void setConfig(Config config)
public CommunicationFormat getOutputFormat()
public void setOutputFormat(CommunicationFormat outputFormat)
public void addRequestParam(java.lang.String name, java.math.BigDecimal value)
name
- the parameter namevalue
- the parameter valuepublic void addRequestParam(java.lang.String name, double value)
name
- the parameter namevalue
- the parameter valuepublic void addRequestParam(java.lang.String name, int value)
name
- the parameter namevalue
- the parameter valuepublic void addRequestParam(java.lang.String name, java.lang.String value)
name
- the parameter namevalue
- the parameter valuepublic void addRequestParam(java.lang.String name, java.lang.String[] value)
name
- the parameter namevalue
- the parameter valuepublic void removeRequestParam(java.lang.String name)
name
- the parameter namepublic void clearRequestParams()
public void addStandardParams()
public java.lang.String createSignature() throws IPCException
IPCException
- If for some reason (invalid private key, invalid signature generation
algorithm, etc.) the signature could not be created.public java.util.Map<java.lang.String,java.lang.String[]> getSignedRequestParams() throws IPCException
IPCException
- if the signature could not be generatedpublic java.lang.String createApiCallFormHtml(java.lang.String title, java.lang.String content) throws IPCException
title
- the page titlecontent
- the page contentIPCException
- If the signature for the request parameters could not be generated.public java.lang.String createApiCallFormHtml(java.lang.String title) throws IPCException
title
- the page titleIPCException
- If the signature for the request parameters could not be generated.public java.lang.String createApiCallFormHtml() throws IPCException
IPCException
- If the signature for the request parameters could not be generated.protected BasicResponse processApiCall() throws IPCException
IPCException
- If the signature for the request parameters could not be generated.
If the API endpoint URL is invalid.
If a connection with the API could not be established.
If the API endpoint responds with an status code different
than java.​net.​HttpURLConnection.HTTP_OK.
If the data returned by the API contains an invalid signature.