com.mypos.myposcheckout.ipc.response

 

Class BasicResponse

java.lang.Object

 

com.mypos.myposcheckout.ipc.response.BasicResponse

 

Direct Known Subclasses: ComplexResponse


 

public class BasicResponse
extends java.lang.Object
IPC Response class. Parse and validate income data into a key => value structure.

 

Field Summary

Fields
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

Constructors
Constructor and Description
BasicResponse(Config config, java.lang.String rawData, CommunicationFormat format) 

 

Method Summary

All MethodsInstance MethodsConcrete Methods
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()
Verifies if the signature in the response is valid for the returned data.


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
Configuration object for the API communication

 

 

rawData

protected final java.lang.String rawData
The data received from the API in raw form (plain text)

 

 

format

protected final CommunicationFormat format
Output format from the API

 

 

signature

protected java.lang.String signature
The Base64 encoded signature for the API response

 

 

basicData

protected java.util.Map<java.lang.String,java.lang.String> basicData
The decoded API response

 

 

dataNormalized

protected java.util.Map<java.lang.String,java.lang.String> dataNormalized
The decoded API response in a normal form (all keys converted to lowercase)

 

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
Decodes and normalizes the API response. Extracts and validates the response signature.
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 the API response status code.
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 API response status message.
Returns:
the status message or null if there is no status message present in the response

 

decodeRawData

protected void decodeRawData()
                      throws IPCException
Decodes the API response into a key => value structure.
Throws:
IPCException - If the response could not be decoded. If the communication format is not set, or invalid.

 

getSignedData

protected byte[] getSignedData()
                        throws IPCException
Concatenates all response parameters, so they can be used to recreate the data, which was signed by the API.
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()
Transforms the decoded response data into a normal form (all the keys converted to lowercase).

 

extractSignature

protected void extractSignature()
Extract the Base64 encoded signature from the decoded and normalized API response.

 

verifySignature

protected void verifySignature()
                        throws IPCException
Verifies if the signature in the response is valid for the returned data.
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.