public abstract class AbstractRestClient extends AbstractClient<AbstractWebRequest,AbstractWebResponse>
Abstract AbstractRestClient class.
Constructor and Description |
---|
AbstractRestClient()
Some rest clients do not require authentication
|
AbstractRestClient(HttpOptions options)
Create a new client using the provided
HttpOptions |
AbstractRestClient(String authToken)
Constructor accepting a
String representing the authentication token for the provider |
Modifier and Type | Method and Description |
---|---|
protected void |
applyAuthenticationScheme(org.asynchttpclient.RequestBuilder requestBuilder,
String authToken)
Override this method if the client requires authentication.
|
protected HttpMessenger |
createMessenger(Options options)
Factory method for
Messenger . |
protected abstract AbstractWebApiResponse |
createWebApiResponse(org.asynchttpclient.Response response)
A factory method that creates an
AbstractWebApiResponse instance based on the Http Response |
String |
getAuthToken()
Getter for the field
authToken . |
protected void |
registerContentTypeProcessor(String contentType,
ContentTypeProcessor processor)
Register custom content processors based on the value defined in the Content-Type header
|
protected void |
removeContentTypeProcessor(String contentType)
removeContentTypeProcessor.
|
protected CompletableFuture<AbstractWebResponse> |
send(AbstractWebRequest message)
send.
|
void |
setAuthToken(String authToken)
Setter for the field
authToken . |
close, getExecutor, getMessenger, getOptions, id, send, send
public AbstractRestClient()
public AbstractRestClient(String authToken)
String
representing the authentication token for the providerauthToken
- A String
containing the authentication token for the providerpublic AbstractRestClient(HttpOptions options)
HttpOptions
options
- The HttpOptions
to be used by the clientprotected void registerContentTypeProcessor(String contentType, ContentTypeProcessor processor)
Register custom content processors based on the value defined in the Content-Type header
contentType
- A String
Content-Type identifierprocessor
- The ContentTypeProcessor
that will handle the response body conversionprotected HttpMessenger createMessenger(Options options)
Messenger
.
Factory method for creating the default HttpMessenger
protected CompletableFuture<AbstractWebResponse> send(AbstractWebRequest message)
send.
message
- a AbstractWebRequest
objectCompletableFuture
objectprotected void applyAuthenticationScheme(org.asynchttpclient.RequestBuilder requestBuilder, String authToken)
Override this method if the client requires authentication.
requestBuilder
- The RequestBuilder
containing the request parameters of the concrete Request
authToken
- A String
representing the authetntication token to be passed to the providerprotected abstract AbstractWebApiResponse createWebApiResponse(org.asynchttpclient.Response response)
A factory method that creates an AbstractWebApiResponse
instance based on the Http Response
response
- The Http Response
received by the transportAbstractWebApiResponse
protected void removeContentTypeProcessor(String contentType)
removeContentTypeProcessor.
contentType
- a String
objectCopyright © 2016–2024. All rights reserved.