Package com.bandwidth.controllers
Class BaseController
java.lang.Object
com.bandwidth.controllers.BaseController
- Direct Known Subclasses:
APIController
,APIController
public abstract class BaseController
extends java.lang.Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
BaseController.RequestExecutor
RequestExecutorprotected static interface
BaseController.RequestSupplier
RequestSupplierprotected static interface
BaseController.ResponseHandler<T>
ResponseHandler -
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,AuthManager>
authManagers
protected Configuration
config
Protected variables to hold an instance of Configurationprotected static java.lang.String
userAgent
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseController(Configuration config, HttpClient httpClient, java.util.Map<java.lang.String,AuthManager> authManagers)
-
Method Summary
Modifier and Type Method Description HttpClient
getClientInstance()
Shared instance of the Http client<T> java.util.concurrent.CompletableFuture<ApiResponse<T>>
makeHttpCallAsync(BaseController.RequestSupplier requestSupplier, BaseController.RequestExecutor requestExecutor, BaseController.ResponseHandler<T> responseHandler)
Make an asynchronous HTTP endpoint callprotected void
validateResponse(HttpResponse response, HttpContext context)
Validates the response against HTTP errors defined at the API level
-
Field Details
-
config
Protected variables to hold an instance of Configuration -
userAgent
protected static final java.lang.String userAgent- See Also:
- Constant Field Values
-
authManagers
-
-
Constructor Details
-
BaseController
protected BaseController(Configuration config, HttpClient httpClient, java.util.Map<java.lang.String,AuthManager> authManagers)
-
-
Method Details
-
getClientInstance
Shared instance of the Http client- Returns:
- The shared instance of the http client
-
validateResponse
Validates the response against HTTP errors defined at the API level- Parameters:
response
- The response recievedcontext
- Context of the request and the recieved response- Throws:
ApiException
-
makeHttpCallAsync
public <T> java.util.concurrent.CompletableFuture<ApiResponse<T>> makeHttpCallAsync(BaseController.RequestSupplier requestSupplier, BaseController.RequestExecutor requestExecutor, BaseController.ResponseHandler<T> responseHandler)Make an asynchronous HTTP endpoint call- Parameters:
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 response- Returns:
- An object of type CompletableFuture
-