public abstract class BaseRemoteEngineApiClient extends Object implements Closeable
| Modifier | Constructor and Description |
|---|---|
protected |
BaseRemoteEngineApiClient(org.slf4j.Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
protected <T> T |
buildApiFor(String baseUrl,
Class<T> apiClass)
Allows to easily build a retrofit API annotated class instance for the given base URL and API
class.
|
protected abstract String |
buildAuthorizationHeaderValue(okhttp3.Request request)
Builds the value to be contained in Authorization header included in http requests.
|
protected com.fasterxml.jackson.databind.ObjectMapper |
buildConverterMapper()
Configures a Jackson ObjectMapper to be used by retrofit to serialized and deserialize requests
and responses for the API.
|
protected RemoteEngineException |
buildRemoteEngineException(int code,
String message)
Builds a
RemoteEngineException for a given status code and message. |
void |
close() |
protected void |
configureHttpClient(okhttp3.OkHttpClient.Builder builder) |
protected <T> T |
execApiCall(retrofit2.Call<T> call)
Executes the given retrofit call, throwing an exception if the response code is not a
successful one, or returning the call response otherwise.
|
protected BaseRemoteEngineApiClient(org.slf4j.Logger logger)
protected void configureHttpClient(okhttp3.OkHttpClient.Builder builder)
protected abstract String buildAuthorizationHeaderValue(okhttp3.Request request) throws IOException
request - contains information about the request which may be helpful to define the proper
authorization value to be used.IOException - if there is some problem contacting remote engine service (e.g.: when
refreshing a token).protected <T> T buildApiFor(String baseUrl, Class<T> apiClass)
T - specifies the type for the class that contains all the API annotated methods.baseUrl - specifies the base URL to be used for all API methods of the given class.apiClass - specifies the class which contains all the API annotated methods.protected com.fasterxml.jackson.databind.ObjectMapper buildConverterMapper()
Any particular RemoteEngineApiClient can override this method to specify custom configuration of the ObjectMapper.
protected <T> T execApiCall(retrofit2.Call<T> call)
throws IOException
T - specifies the response type to be returned by the method call API invocation.call - specifies the API method call to execute.IOException - if the response status code is not a successful one, or there is some
problem contacting the remote engine service.protected RemoteEngineException buildRemoteEngineException(int code, String message)
RemoteEngineException for a given status code and message.
This method is provided for backwards compatibility purposes, allowing existing remote engine apis to keep throwing their custom exceptions.
code - the response status code that generated the exception.message - the response body.public void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2024. All rights reserved.