com.mypos.myposcheckout.ipc.request

 

Class Request

java.lang.Object com.mypos.myposcheckout.ipc.request.Request
Direct Known Subclasses:
InAppPurchaseInAppStoreCardInAppStoredCardUpdateMandateManagementPurchaseRefundRequestMoneyReversalTransactionLogTransactionStatus


public abstract class Request
extends java.lang.Object
Base API request class. Contains basic API connection methods.

 

Field Summary

Fields
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 Summary

Constructors
Constructor and Description
Request() 

 

Method Summary

All MethodsInstance MethodsConcrete Methods
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) 

 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

config

protected Config config
Configuration object for the API communication

outputFormat

protected CommunicationFormat outputFormat
Output format from the API (for some requests may be XML or JSON)

Constructor Detail

Request

public Request()

Method Detail

getConfig

public Config getConfig()

setConfig

public void setConfig(Config config)

getOutputFormat

public CommunicationFormat getOutputFormat()

setOutputFormat

public void setOutputFormat(CommunicationFormat outputFormat)

addRequestParam

public void addRequestParam(java.lang.String name,
                            java.math.BigDecimal value)
Adds a parameter to the API request.
Parameters:
name - the parameter name
value - the parameter value

addRequestParam

public void addRequestParam(java.lang.String name,
                            double value)
Adds a parameter to the API request.
Parameters:
name - the parameter name
value - the parameter value

addRequestParam

public void addRequestParam(java.lang.String name,
                            int value)
Adds a parameter to the API request.
Parameters:
name - the parameter name
value - the parameter value

addRequestParam

public void addRequestParam(java.lang.String name,
                            java.lang.String value)
Adds a parameter to the API request.
Parameters:
name - the parameter name
value - the parameter value

addRequestParam

public void addRequestParam(java.lang.String name,
                            java.lang.String[] value)
Adds a parameter to the API request.
Parameters:
name - the parameter name
value - the parameter value

removeRequestParam

public void removeRequestParam(java.lang.String name)
Removes a parameter, if it exists, from the API request.
Parameters:
name - the parameter name

clearRequestParams

public void clearRequestParams()
Clears the request parameters.

addStandardParams

public void addStandardParams()
Add the parameters that should be present in every API call.

createSignature

public java.lang.String createSignature()
                                 throws IPCException
Create a signature for the API request parameters using the store private key.
Returns:
a base64 encoded signature
Throws:
IPCException - If for some reason (invalid private key, invalid signature generation algorithm, etc.) the signature could not be created.

getSignedRequestParams

public java.util.Map<java.lang.String,java.lang.String[]> getSignedRequestParams()
                                                                          throws IPCException
Returns all the API request parameters and generates a signature for them, if one is not present.
Returns:
all the API request parameters with a generated signature for them
Throws:
IPCException - if the signature could not be generated

createApiCallFormHtml

public java.lang.String createApiCallFormHtml(java.lang.String title,
                                              java.lang.String content)
                                       throws IPCException
Creates a minimal HTML document, containing a form with all the request parameters. The form will automatically submit the data when the document is loaded. This is used because the API requires the user to be redirected to the MyPOS site with a POST request.
Parameters:
title - the page title
content - the page content
Returns:
a HTML string containing the form
Throws:
IPCException - If the signature for the request parameters could not be generated.

createApiCallFormHtml

public java.lang.String createApiCallFormHtml(java.lang.String title)
                                       throws IPCException
Creates a minimal HTML document, containing a form with all the request parameters. The form will automatically submit the data when the document is loaded. This is used because the API requires the user to be redirected to the MyPOS site with a POST request.
Parameters:
title - the page title
Returns:
a HTML string containing the form
Throws:
IPCException - If the signature for the request parameters could not be generated.

createApiCallFormHtml

public java.lang.String createApiCallFormHtml()
                                       throws IPCException
Creates a minimal HTML document, containing a form with all the request parameters. The form will automatically submit the data when the document is loaded. This is used because the API requires the user to be redirected to the MyPOS site with a POST request.
Returns:
a HTML string containing the form
Throws:
IPCException - If the signature for the request parameters could not be generated.

processApiCall

protected BasicResponse processApiCall()
                                throws IPCException
Makes a request to the API using and returns the decoded API response.
Returns:
a Response object, containing the API response data
Throws:
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.