Package com.akraml.satim.reply
Class AbstractReply
java.lang.Object
com.akraml.satim.reply.AbstractReply
- Direct Known Subclasses:
OrderConfirmationReply,OrderStatusReply,PaymentReply,RefundReply
Base class for all API response types.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractReply(boolean success, int errorCode, @Nullable String errorMessage, @NotNull com.google.gson.JsonObject rawResponse) Constructs a new AbstractReply. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the error code from the response.@Nullable StringReturns the error message from the response.@NotNull com.google.gson.JsonObjectReturns the raw JSON response.@NotNull StringReturns the full response as a JSON string.booleanReturns whether the API call was successful.toString()
-
Constructor Details
-
AbstractReply
protected AbstractReply(boolean success, int errorCode, @Nullable @Nullable String errorMessage, @NotNull @NotNull com.google.gson.JsonObject rawResponse) Constructs a new AbstractReply.- Parameters:
success- whether the API call was successfulerrorCode- the error code (0 if successful)errorMessage- the error message (null if successful)rawResponse- the raw JSON response
-
-
Method Details
-
isSuccessful
public boolean isSuccessful()Returns whether the API call was successful.- Returns:
trueif successful,falseotherwise
-
getErrorCode
public int getErrorCode()Returns the error code from the response.- Returns:
- the error code, or 0 if successful
-
getErrorMessage
Returns the error message from the response.- Returns:
- the error message, or
nullif successful
-
getRawResponse
@NotNull public @NotNull com.google.gson.JsonObject getRawResponse()Returns the raw JSON response.This can be used to access fields not directly exposed by the reply class.
- Returns:
- the raw JSON response object
-
getResponse
Returns the full response as a JSON string.- Returns:
- JSON string representation of the response
-
toString
-