Class BasicResponse
java.lang.Object
com.mypos.myposcheckout.ipc.response.BasicResponse
Direct Known Subclasses: ComplexResponse
public class BasicResponse
extends java.lang.Object
Field Summary
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
basicData
The decoded API response
|
protected Config |
config
Configuration object for the API communication
|
protected java.util.Map<java.lang.String,java.lang.String> |
dataNormalized
The decoded API response in a normal form (all keys converted to lowercase)
|
protected CommunicationFormat |
format
Output format from the API
|
protected java.lang.String |
rawData
The data received from the API in raw form (plain text)
|
protected java.lang.String |
signature
The Base64 encoded signature for the API response
|
Constructor Summary
Constructor and Description |
---|
BasicResponse(Config config, java.lang.String rawData, CommunicationFormat format) |
Method Summary
Modifier and Type | Method and Description |
---|---|
protected void |
decodeRawData()
Decodes the API response into a key => value structure.
|
protected void |
extractSignature()
Extract the Base64 encoded signature from the decoded and normalized API response.
|
java.util.Map<java.lang.String,java.lang.String> |
getBasicData() |
Config |
getConfig() |
java.util.Map<java.lang.String,java.lang.String> |
getDataNormalized() |
CommunicationFormat |
getFormat() |
java.lang.String |
getRawData() |
protected byte[] |
getSignedData()
Concatenates all response parameters, so they can be used to recreate the data, which was signed by the API.
|
StatusCode |
getStatusCode()
Returns the API response status code.
|
java.lang.String |
getStatusMessage()
Returns the API response status message.
|
protected void |
normalizeData()
Transforms the decoded response data into a normal form (all the keys converted to lowercase).
|
void |
processApiResponse()
Decodes and normalizes the API response.
|
protected void |
verifySignature()
|
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
config
protected final Config config
rawData
protected final java.lang.String rawData
format
protected final CommunicationFormat format
signature
protected java.lang.String signature
basicData
protected java.util.Map<java.lang.String,java.lang.String> basicData
dataNormalized
protected java.util.Map<java.lang.String,java.lang.String> dataNormalized
Constructor Detail
BasicResponse
public BasicResponse(Config config, java.lang.String rawData, CommunicationFormat format) throws IPCException
- Throws:
IPCException
Method Detail
processApiResponse
public void processApiResponse() throws IPCException
- Throws:
IPCException
- If the API response could not be decoded. If the response signature could not be verified.
getConfig
public Config getConfig()
getRawData
public java.lang.String getRawData()
getFormat
public CommunicationFormat getFormat()
getBasicData
public java.util.Map<java.lang.String,java.lang.String> getBasicData()
getDataNormalized
public java.util.Map<java.lang.String,java.lang.String> getDataNormalized()
getStatusCode
public StatusCode getStatusCode() throws IPCException
- Returns:
- SUCCESS (0) if the call is successful
- Throws:
IPCException
- If there is no status code in the response data. If the status code in the response is not present in the status code definitions.
getStatusMessage
public java.lang.String getStatusMessage()
- Returns:
- the status message or null if there is no status message present in the response
decodeRawData
protected void decodeRawData() throws IPCException
- Throws:
IPCException
- If the response could not be decoded. If the communication format is not set, or invalid.
getSignedData
protected byte[] getSignedData() throws IPCException
- Returns:
- a Base64 encoded representation of the data, signed by the API
- Throws:
IPCException
- if the response data could not be decoded
normalizeData
protected void normalizeData()
extractSignature
protected void extractSignature()
verifySignature
protected void verifySignature() throws IPCException
- Throws:
IPCException
- If the signature in the response is missing or invalid. If the signed data could not be verified for being signed with the API private key.