Interface JsonDeserializationService
public interface JsonDeserializationService
Utility interface that allow us to deserialize coinbase api responses from json to java objects
-
Method Summary
Static Methods Modifier and Type Method Description static <T> CallResult<io.vavr.collection.Seq<CoinbaseError>,DataDto<T>>
deserialize(java.net.http.HttpResponse<java.lang.String> response, com.fasterxml.jackson.databind.ObjectMapper jsonSerDes, com.fasterxml.jackson.core.type.TypeReference<DataDto<T>> typeReference)
Generic method to centralized the deserialization process of coinbase api responses and wrap the results in aCallResult
objectstatic <T> CallResult<io.vavr.collection.Seq<CoinbaseError>,PaginatedResponseDto<T>>
paginatedDeserialize(java.net.http.HttpResponse<java.lang.String> response, com.fasterxml.jackson.databind.ObjectMapper jsonSerDes, com.fasterxml.jackson.core.type.TypeReference<PaginatedResponseDto<T>> typeReference)
static <T> CallResult<io.vavr.collection.Seq<CoinbaseError>,DataDto<T>>
singleFailureDeserialize(java.net.http.HttpResponse<java.lang.String> response, com.fasterxml.jackson.databind.ObjectMapper jsonSerDes, com.fasterxml.jackson.core.type.TypeReference<DataDto<T>> typeReference)
Generic method to centralized the deserialization process of coinbase api responses and wrap the results in aCallResult
object
-
Method Details
-
deserialize
static <T> CallResult<io.vavr.collection.Seq<CoinbaseError>,DataDto<T>> deserialize(java.net.http.HttpResponse<java.lang.String> response, com.fasterxml.jackson.databind.ObjectMapper jsonSerDes, com.fasterxml.jackson.core.type.TypeReference<DataDto<T>> typeReference) throws com.fasterxml.jackson.core.JsonProcessingExceptionGeneric method to centralized the deserialization process of coinbase api responses and wrap the results in aCallResult
objectThis method is different of
singleFailureDeserialize(HttpResponse, ObjectMapper, TypeReference)
and should be used for all Coinbase api responses except for public data. Public data does not return errors in the same way as protected data.- Type Parameters:
T
- the object type to deserialize- Parameters:
response
- the http responsejsonSerDes
- the jackson object mapper to usetypeReference
- the jackson type reference for deserialization- Returns:
- a new
CallResult
representing a success or a failure - Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if not deserializable
-
paginatedDeserialize
static <T> CallResult<io.vavr.collection.Seq<CoinbaseError>,PaginatedResponseDto<T>> paginatedDeserialize(java.net.http.HttpResponse<java.lang.String> response, com.fasterxml.jackson.databind.ObjectMapper jsonSerDes, com.fasterxml.jackson.core.type.TypeReference<PaginatedResponseDto<T>> typeReference) throws com.fasterxml.jackson.core.JsonProcessingException- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
singleFailureDeserialize
static <T> CallResult<io.vavr.collection.Seq<CoinbaseError>,DataDto<T>> singleFailureDeserialize(java.net.http.HttpResponse<java.lang.String> response, com.fasterxml.jackson.databind.ObjectMapper jsonSerDes, com.fasterxml.jackson.core.type.TypeReference<DataDto<T>> typeReference) throws com.fasterxml.jackson.core.JsonProcessingExceptionGeneric method to centralized the deserialization process of coinbase api responses and wrap the results in aCallResult
objectThis method is different of
deserialize(HttpResponse, ObjectMapper, TypeReference)
and should be used only for public data. Protected data does not return errors in the same way as public data.- Type Parameters:
T
- the object type to deserialize- Parameters:
response
- the http responsejsonSerDes
- the jackson object mapper to usetypeReference
- the jackson type reference for deserialization- Returns:
- a new
CallResult
representing a success or a failure - Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if not deserializable
-