public static class RestClient.Builder extends Object
Constructor and Description |
---|
Builder()
Creates an instance of the builder with a base URL to the service.
|
Builder(okhttp3.OkHttpClient.Builder httpClientBuilder,
retrofit2.Retrofit.Builder retrofitBuilder)
Creates an instance of the builder with a base URL and 2 custom builders.
|
Modifier and Type | Method and Description |
---|---|
RestClient |
build()
Build a RestClient with all the current configurations.
|
RestClient.Builder |
withBaseUrl(Environment environment,
Environment.Endpoint endpoint)
Sets the base URL with the default from the Environment.
|
RestClient.Builder |
withBaseUrl(String baseUrl)
Sets the dynamic base URL.
|
RestClient.Builder |
withCallbackExecutor(Executor executor)
Sets the executor for async callbacks to run on.
|
RestClient.Builder |
withConnectionTimeout(long timeout,
TimeUnit unit)
Set the connection timeout on the HTTP client.
|
RestClient.Builder |
withCredentials(ServiceClientCredentials credentials)
Sets the credentials.
|
RestClient.Builder |
withInterceptor(okhttp3.Interceptor interceptor)
Add an interceptor the Http client pipeline.
|
RestClient.Builder |
withLogLevel(LogLevel logLevel)
Sets the HTTP log level.
|
RestClient.Builder |
withMaxIdleConnections(int maxIdleConnections)
Set the maximum idle connections for the HTTP client.
|
RestClient.Builder |
withNetworkInterceptor(okhttp3.Interceptor networkInterceptor)
Add an interceptor the network layer of Http client pipeline.
|
RestClient.Builder |
withProxy(Proxy proxy)
Sets the proxy for the HTTP client.
|
RestClient.Builder |
withProxyAuthenticator(okhttp3.Authenticator proxyAuthenticator)
Sets the proxy authenticator for the HTTP client.
|
RestClient.Builder |
withReadTimeout(long timeout,
TimeUnit unit)
Set the read timeout on the HTTP client.
|
RestClient.Builder |
withResponseBuilderFactory(ResponseBuilder.Factory responseBuilderFactory)
Sets the response builder factory.
|
RestClient.Builder |
withRetryStrategy(RetryStrategy strategy)
Adds a retry strategy to the client.
|
RestClient.Builder |
withSerializerAdapter(SerializerAdapter<?> serializerAdapter)
Sets the serialization adapter.
|
RestClient.Builder |
withUserAgent(String userAgent)
Sets the user agent header.
|
public Builder()
public Builder(okhttp3.OkHttpClient.Builder httpClientBuilder, retrofit2.Retrofit.Builder retrofitBuilder)
httpClientBuilder
- the builder to build an OkHttpClient
.retrofitBuilder
- the builder to build a Retrofit
.public RestClient.Builder withBaseUrl(String baseUrl)
baseUrl
- the base URL to use.public RestClient.Builder withBaseUrl(Environment environment, Environment.Endpoint endpoint)
environment
- the environment to useendpoint
- the environment endpoint the application is accessingpublic RestClient.Builder withSerializerAdapter(SerializerAdapter<?> serializerAdapter)
serializerAdapter
- the adapter to a serializerpublic RestClient.Builder withResponseBuilderFactory(ResponseBuilder.Factory responseBuilderFactory)
responseBuilderFactory
- the response builder factorypublic RestClient.Builder withCredentials(ServiceClientCredentials credentials)
credentials
- the credentials object.public RestClient.Builder withUserAgent(String userAgent)
userAgent
- the user agent header.public RestClient.Builder withLogLevel(LogLevel logLevel)
logLevel
- the LogLevel
enum.public RestClient.Builder withInterceptor(okhttp3.Interceptor interceptor)
interceptor
- the interceptor to add.public RestClient.Builder withNetworkInterceptor(okhttp3.Interceptor networkInterceptor)
networkInterceptor
- the interceptor to add.public RestClient.Builder withReadTimeout(long timeout, TimeUnit unit)
timeout
- the timeout numeric valueunit
- the time unit for the numeric valuepublic RestClient.Builder withConnectionTimeout(long timeout, TimeUnit unit)
timeout
- the timeout numeric valueunit
- the time unit for the numeric valuepublic RestClient.Builder withMaxIdleConnections(int maxIdleConnections)
maxIdleConnections
- the maximum idle connectionspublic RestClient.Builder withCallbackExecutor(Executor executor)
executor
- the executor to execute the callbacks.public RestClient.Builder withProxy(Proxy proxy)
proxy
- the proxy to usepublic RestClient.Builder withProxyAuthenticator(okhttp3.Authenticator proxyAuthenticator)
proxyAuthenticator
- the proxy authenticator to usepublic RestClient.Builder withRetryStrategy(RetryStrategy strategy)
strategy
- the retry strategy to addpublic RestClient build()
RestClient
.Copyright © 2019. All rights reserved.