Package org.stellar.sdk.requests
Class ResponseHandler<T>
java.lang.Object
org.stellar.sdk.requests.ResponseHandler<T>
-
Constructor Summary
ConstructorDescriptionResponseHandler
(com.google.gson.reflect.TypeToken<T> type) "Generics on a type are typically erased at runtime, except when the type is compiled with the generic parameter bound. -
Method Summary
Modifier and TypeMethodDescriptionhandleResponse
(okhttp3.Response response) Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.handleResponse
(okhttp3.Response response, boolean submitTransactionAsync) Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.
-
Constructor Details
-
ResponseHandler
"Generics on a type are typically erased at runtime, except when the type is compiled with the generic parameter bound. In that case, the compiler inserts the generic type information into the compiled class. In other cases, that is not possible." More info: http://stackoverflow.com/a/14506181- Parameters:
type
-
-
-
Method Details
-
handleResponse
Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.- Parameters:
response
- The HTTP response to handle- Returns:
- The parsed object of type T
- Throws:
TooManyRequestsException
- If the response code is 429 (Too Many Requests)UnexpectedException
- If the response body is empty or there's an unexpected error reading the responseBadRequestException
- If the response code is in the 4xx rangeBadResponseException
- If the response code is in the 5xx range
-
handleResponse
Handles the HTTP response and converts it to the appropriate object or throws exceptions based on the response status.- Parameters:
response
- The HTTP response to handlesubmitTransactionAsync
- Only set it to true when callingServer.submitTransactionXdrAsync(String)
.- Returns:
- The parsed object of type T
- Throws:
TooManyRequestsException
- If the response code is 429 (Too Many Requests)UnexpectedException
- If the response body is empty or there's an unexpected error reading the responseBadRequestException
- If the response code is in the 4xx rangeBadResponseException
- If the response code is in the 5xx range
-