Package pro.mypvit.responses
Class AbstractResponse
java.lang.Object
pro.mypvit.responses.AbstractResponse
- Direct Known Subclasses:
BalanceResponse,KycResponse,StatusResponse,TokenResponse,TransactionLinkResponse,TransactionRestResponse
Abstract base class for response objects in the MyPVit SDK.
This class provides a shared functionality to deserialize JSON strings into
response objects. It ensures consistent deserialization by using a pre-configured
Gson instance with a specific field naming policy.
- Generic deserialization method for converting JSON strings into specific response types.
- Uses
FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORESto handle API responses that use snake_case field naming. - Designed to be extended by specific response classes in the SDK.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends AbstractResponse>
TConverts a JSON string into an instance of a specified subclass ofAbstractResponse.
-
Constructor Details
-
AbstractResponse
public AbstractResponse()Default constructor
-
-
Method Details
-
fromJson
Converts a JSON string into an instance of a specified subclass ofAbstractResponse.This method uses a generic type to allow deserialization into any class that extends
AbstractResponse.- Type Parameters:
T- The type of the subclass.- Parameters:
json- The JSON string to deserialize.clazz- The class type of the subclass to deserialize into.- Returns:
- An instance of the specified subclass populated with data from the JSON string.
- Throws:
com.google.gson.JsonSyntaxException- if the JSON string is not a valid representation for the specified class.
-