public abstract class BaseApi extends Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
BaseApi.RequestExecutor
RequestExecutor
|
protected static interface |
BaseApi.RequestSupplier
RequestSupplier
|
protected static interface |
BaseApi.ResponseHandler<T>
ResponseHandler
|
Modifier and Type | Field and Description |
---|---|
protected Map<String,AuthManager> |
authManagers |
protected Configuration |
config
Protected variables to hold an instance of Configuration
|
protected HttpCallback |
httpCallback
Protected variable to hold an instance of HttpCallback if the user provides it
|
protected static String |
userAgent |
Modifier | Constructor and Description |
---|---|
protected |
BaseApi(Configuration config,
HttpClient httpClient,
Map<String,AuthManager> authManagers) |
protected |
BaseApi(Configuration config,
HttpClient httpClient,
Map<String,AuthManager> authManagers,
HttpCallback httpCallback) |
Modifier and Type | Method and Description |
---|---|
HttpClient |
getClientInstance()
Shared instance of the Http client
|
HttpCallback |
getHttpCallback()
Get httpCallback associated with this controller
|
<T> CompletableFuture<T> |
makeHttpCallAsync(BaseApi.RequestSupplier requestSupplier,
BaseApi.RequestExecutor requestExecutor,
BaseApi.ResponseHandler<T> responseHandler)
Make an asynchronous HTTP endpoint call
|
protected void |
validateResponse(HttpResponse response,
HttpContext context)
Validates the response against HTTP errors defined at the API level
|
protected final Configuration config
protected static final String userAgent
protected final HttpCallback httpCallback
protected Map<String,AuthManager> authManagers
protected BaseApi(Configuration config, HttpClient httpClient, Map<String,AuthManager> authManagers)
protected BaseApi(Configuration config, HttpClient httpClient, Map<String,AuthManager> authManagers, HttpCallback httpCallback)
public HttpCallback getHttpCallback()
public HttpClient getClientInstance()
protected void validateResponse(HttpResponse response, HttpContext context) throws ApiException
response
- The response recievedcontext
- Context of the request and the recieved responseApiException
public <T> CompletableFuture<T> makeHttpCallAsync(BaseApi.RequestSupplier requestSupplier, BaseApi.RequestExecutor requestExecutor, BaseApi.ResponseHandler<T> responseHandler)
requestSupplier
- An object of RequestSupplier to supply an instance of HttpRequestrequestExecutor
- An object of RequestExecutor to execute the request & get the responseresponseHandler
- An object of ResponseHandler to handle the endpoint responseCopyright © 2020. All rights reserved.