|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sponsorpay.sdk.android.publisher.currency.CurrencyServerAbstractResponse
public abstract class CurrencyServerAbstractResponse
Encloses a basic response received from the SponsorPay's Virtual Currency Server and methods to perform parsing of the returned JSON-encoded data.
Nested Class Summary | |
---|---|
static class |
CurrencyServerAbstractResponse.RequestErrorType
Types of error condition which a request / response might result in. |
Field Summary | |
---|---|
private static java.lang.String |
ERROR_CODE_KEY
|
private static java.lang.String |
ERROR_MESSAGE_KEY
|
protected java.lang.String |
mErrorCode
Error code provided by the server. |
protected java.lang.String |
mErrorMessage
Error message provided by the server. |
protected CurrencyServerAbstractResponse.RequestErrorType |
mErrorType
Type of error condition in which the request / response has resulted. |
protected SPCurrencyServerListener |
mListener
Listener which will be notified after parsing the response. |
protected java.lang.String |
mResponseBody
Body of the HTTP response. |
protected java.lang.String |
mResponseSignature
Server-provided signature of the response. |
protected int |
mResponseStatusCode
Status code of the HTTP response. |
Constructor Summary | |
---|---|
CurrencyServerAbstractResponse()
|
Method Summary | |
---|---|
java.lang.String |
getErrorCode()
Gets the error code returned by the server. |
java.lang.String |
getErrorMessage()
Gets the error message returned by the server. |
CurrencyServerAbstractResponse.RequestErrorType |
getErrorType()
Gets the error condition in which this request / response has resulted. |
static CurrencyServerAbstractResponse |
getParsingInstance(VirtualCurrencyConnector.RequestType requestType)
Returns the appropriate subclass to enclose and parse the response to a request of the passed type. |
boolean |
hasErrorStatusCode()
Returns true if the response contains an HTTP status code out of the 200s. |
void |
invokeOnErrorCallback()
Invokes the SPCurrencyServerListener.onSPCurrencyServerError(CurrencyServerAbstractResponse) of the
registered callback. |
abstract void |
invokeOnSuccessCallback()
Implement to invoke the response-type-specific on success callback notification. |
void |
parseAndCallListener(java.lang.String securityToken)
Performs a second-stage error checking, parses the response and invokes the relevant method of the listener registered with setResponseListener(SPCurrencyServerListener) . |
void |
parseErrorResponse()
Parses a response containing a non-successful HTTP status code. |
abstract void |
parseSuccessfulResponse()
Implement to parse a successful-HTTP-status-code containing response. |
void |
setResponseData(int responseStatusCode,
java.lang.String responseBody,
java.lang.String responseSignature)
Sets the raw response data. |
void |
setResponseListener(SPCurrencyServerListener listener)
Set the response listener which will be notified when the parsing is complete. |
boolean |
verifySignature(java.lang.String securityToken)
Verify calculate the signature of the response with the provided security token and compare it against the server-provided response signature. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String ERROR_CODE_KEY
private static final java.lang.String ERROR_MESSAGE_KEY
protected int mResponseStatusCode
protected java.lang.String mResponseBody
protected java.lang.String mResponseSignature
protected SPCurrencyServerListener mListener
protected CurrencyServerAbstractResponse.RequestErrorType mErrorType
protected java.lang.String mErrorCode
protected java.lang.String mErrorMessage
Constructor Detail |
---|
public CurrencyServerAbstractResponse()
Method Detail |
---|
public abstract void parseSuccessfulResponse()
public abstract void invokeOnSuccessCallback()
public void setResponseData(int responseStatusCode, java.lang.String responseBody, java.lang.String responseSignature)
responseStatusCode
- HTTP status code returned by the server.responseBody
- Body of the HTTP response.responseSignature
- Signature of the response extracted from the response headers.public void setResponseListener(SPCurrencyServerListener listener)
listener
- public boolean verifySignature(java.lang.String securityToken)
securityToken
- Security token which will be used to calculate the signature.
public void parseAndCallListener(java.lang.String securityToken)
setResponseListener(SPCurrencyServerListener)
.
securityToken
- Security token used to verify the authenticity of the response.public boolean hasErrorStatusCode()
public void parseErrorResponse()
public void invokeOnErrorCallback()
SPCurrencyServerListener.onSPCurrencyServerError(CurrencyServerAbstractResponse)
of the
registered callback.
public CurrencyServerAbstractResponse.RequestErrorType getErrorType()
CurrencyServerAbstractResponse.RequestErrorType
.public java.lang.String getErrorCode()
public java.lang.String getErrorMessage()
public static CurrencyServerAbstractResponse getParsingInstance(VirtualCurrencyConnector.RequestType requestType)
requestType
- The type of the request whose response can be parsed by the returned instance.
CurrencyServerAbstractResponse
, or null if no subclass is known for
parsing the provided VirtualCurrencyConnector.RequestType
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |