Class BennyOkHttpClient.Builder
-
- All Implemented Interfaces:
public final class BennyOkHttpClient.BuilderA builder for BennyOkHttpClient.
-
-
Method Summary
Modifier and Type Method Description final BennyOkHttpClient.BuilderdispatcherExecutorService(ExecutorService dispatcherExecutorService)The executor service to use for running HTTP requests. final BennyOkHttpClient.BuilderdispatcherExecutorService(Optional<ExecutorService> dispatcherExecutorService)Alias for calling Builder.dispatcherExecutorService with dispatcherExecutorService.orElse(null).final BennyOkHttpClient.Builderproxy(Proxy proxy)final BennyOkHttpClient.Builderproxy(Optional<Proxy> proxy)Alias for calling Builder.proxy with proxy.orElse(null).final BennyOkHttpClient.BuildersslSocketFactory(SSLSocketFactory sslSocketFactory)The socket factory used to secure HTTPS connections. final BennyOkHttpClient.BuildersslSocketFactory(Optional<SSLSocketFactory> sslSocketFactory)Alias for calling Builder.sslSocketFactory with sslSocketFactory.orElse(null).final BennyOkHttpClient.BuildertrustManager(X509TrustManager trustManager)The trust manager used to secure HTTPS connections. final BennyOkHttpClient.BuildertrustManager(Optional<X509TrustManager> trustManager)Alias for calling Builder.trustManager with trustManager.orElse(null).final BennyOkHttpClient.BuilderhostnameVerifier(HostnameVerifier hostnameVerifier)The verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections. final BennyOkHttpClient.BuilderhostnameVerifier(Optional<HostnameVerifier> hostnameVerifier)Alias for calling Builder.hostnameVerifier with hostnameVerifier.orElse(null).final BennyOkHttpClient.BuildercheckJacksonVersionCompatibility(Boolean checkJacksonVersionCompatibility)Whether to throw an exception if any of the Jackson versions detected at runtime are incompatible with the SDK's minimum supported Jackson version (2.13.4). final BennyOkHttpClient.BuilderjsonMapper(JsonMapper jsonMapper)The Jackson JSON mapper to use for serializing and deserializing JSON. final BennyOkHttpClient.Buildersleeper(Sleeper sleeper)The interface to use for delaying execution, like during retries. final BennyOkHttpClient.Builderclock(Clock clock)The clock to use for operations that require timing, like retries. final BennyOkHttpClient.BuilderbaseUrl(String baseUrl)The base URL to use for every request. final BennyOkHttpClient.BuilderbaseUrl(Optional<String> baseUrl)Alias for calling Builder.baseUrl with baseUrl.orElse(null).final BennyOkHttpClient.Buildersandbox()Sets baseUrl to https://{subdomain}.bennyapi.com.final BennyOkHttpClient.BuilderresponseValidation(Boolean responseValidation)Whether to call validateon every response before returning it.final BennyOkHttpClient.Buildertimeout(Timeout timeout)Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding retries. final BennyOkHttpClient.Buildertimeout(Duration timeout)Sets the maximum time allowed for a complete HTTP call, not including retries. final BennyOkHttpClient.BuildermaxRetries(Integer maxRetries)The maximum number of times to retry failed requests, with a short exponential backoff between requests. final BennyOkHttpClient.BuilderapiKey(String apiKey)API key authentication for public endpoints final BennyOkHttpClient.Buildersubdomain(String subdomain)final BennyOkHttpClient.Builderheaders(Headers headers)final BennyOkHttpClient.Builderheaders(Map<String, Iterable<String>> headers)final BennyOkHttpClient.BuilderputHeader(String name, String value)final BennyOkHttpClient.BuilderputHeaders(String name, Iterable<String> values)final BennyOkHttpClient.BuilderputAllHeaders(Headers headers)final BennyOkHttpClient.BuilderputAllHeaders(Map<String, Iterable<String>> headers)final BennyOkHttpClient.BuilderreplaceHeaders(String name, String value)final BennyOkHttpClient.BuilderreplaceHeaders(String name, Iterable<String> values)final BennyOkHttpClient.BuilderreplaceAllHeaders(Headers headers)final BennyOkHttpClient.BuilderreplaceAllHeaders(Map<String, Iterable<String>> headers)final BennyOkHttpClient.BuilderremoveHeaders(String name)final BennyOkHttpClient.BuilderremoveAllHeaders(Set<String> names)final BennyOkHttpClient.BuilderqueryParams(QueryParams queryParams)final BennyOkHttpClient.BuilderqueryParams(Map<String, Iterable<String>> queryParams)final BennyOkHttpClient.BuilderputQueryParam(String key, String value)final BennyOkHttpClient.BuilderputQueryParams(String key, Iterable<String> values)final BennyOkHttpClient.BuilderputAllQueryParams(QueryParams queryParams)final BennyOkHttpClient.BuilderputAllQueryParams(Map<String, Iterable<String>> queryParams)final BennyOkHttpClient.BuilderreplaceQueryParams(String key, String value)final BennyOkHttpClient.BuilderreplaceQueryParams(String key, Iterable<String> values)final BennyOkHttpClient.BuilderreplaceAllQueryParams(QueryParams queryParams)final BennyOkHttpClient.BuilderreplaceAllQueryParams(Map<String, Iterable<String>> queryParams)final BennyOkHttpClient.BuilderremoveQueryParams(String key)final BennyOkHttpClient.BuilderremoveAllQueryParams(Set<String> keys)final BennyOkHttpClient.BuilderfromEnv()Updates configuration using system properties and environment variables. final BennyClientbuild()Returns an immutable instance of BennyClient. -
-
Method Detail
-
dispatcherExecutorService
final BennyOkHttpClient.Builder dispatcherExecutorService(ExecutorService dispatcherExecutorService)
The executor service to use for running HTTP requests.
Defaults to OkHttp's default executor service.
This class takes ownership of the executor service and shuts it down when closed.
-
dispatcherExecutorService
final BennyOkHttpClient.Builder dispatcherExecutorService(Optional<ExecutorService> dispatcherExecutorService)
Alias for calling Builder.dispatcherExecutorService with
dispatcherExecutorService.orElse(null).
-
proxy
final BennyOkHttpClient.Builder proxy(Proxy proxy)
-
proxy
final BennyOkHttpClient.Builder proxy(Optional<Proxy> proxy)
Alias for calling Builder.proxy with
proxy.orElse(null).
-
sslSocketFactory
final BennyOkHttpClient.Builder sslSocketFactory(SSLSocketFactory sslSocketFactory)
The socket factory used to secure HTTPS connections.
If this is set, then trustManager must also be set.
If unset, then the system default is used. Most applications should not call this method, and instead use the system default. The default include special optimizations that can be lost if the implementation is modified.
-
sslSocketFactory
final BennyOkHttpClient.Builder sslSocketFactory(Optional<SSLSocketFactory> sslSocketFactory)
Alias for calling Builder.sslSocketFactory with
sslSocketFactory.orElse(null).
-
trustManager
final BennyOkHttpClient.Builder trustManager(X509TrustManager trustManager)
The trust manager used to secure HTTPS connections.
If this is set, then sslSocketFactory must also be set.
If unset, then the system default is used. Most applications should not call this method, and instead use the system default. The default include special optimizations that can be lost if the implementation is modified.
-
trustManager
final BennyOkHttpClient.Builder trustManager(Optional<X509TrustManager> trustManager)
Alias for calling Builder.trustManager with
trustManager.orElse(null).
-
hostnameVerifier
final BennyOkHttpClient.Builder hostnameVerifier(HostnameVerifier hostnameVerifier)
The verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections.
If unset, then a default hostname verifier is used.
-
hostnameVerifier
final BennyOkHttpClient.Builder hostnameVerifier(Optional<HostnameVerifier> hostnameVerifier)
Alias for calling Builder.hostnameVerifier with
hostnameVerifier.orElse(null).
-
checkJacksonVersionCompatibility
final BennyOkHttpClient.Builder checkJacksonVersionCompatibility(Boolean checkJacksonVersionCompatibility)
Whether to throw an exception if any of the Jackson versions detected at runtime are incompatible with the SDK's minimum supported Jackson version (2.13.4).
Defaults to true. Use extreme caution when disabling this option. There is no guarantee that the SDK will work correctly when using an incompatible Jackson version.
-
jsonMapper
final BennyOkHttpClient.Builder jsonMapper(JsonMapper jsonMapper)
The Jackson JSON mapper to use for serializing and deserializing JSON.
Defaults to com.bennyapi.core.jsonMapper. The default is usually sufficient and rarely needs to be overridden.
-
sleeper
final BennyOkHttpClient.Builder sleeper(Sleeper sleeper)
The interface to use for delaying execution, like during retries.
This is primarily useful for using fake delays in tests.
Defaults to real execution delays.
This class takes ownership of the sleeper and closes it when closed.
-
clock
final BennyOkHttpClient.Builder clock(Clock clock)
The clock to use for operations that require timing, like retries.
This is primarily useful for using a fake clock in tests.
Defaults to Clock.systemUTC.
-
baseUrl
final BennyOkHttpClient.Builder baseUrl(String baseUrl)
The base URL to use for every request.
Defaults to the production environment:
https://{subdomain}.bennyapi.com.The following other environments, with dedicated builder methods, are available:
sandbox:
https://{subdomain}.bennyapi.com
-
baseUrl
final BennyOkHttpClient.Builder baseUrl(Optional<String> baseUrl)
Alias for calling Builder.baseUrl with
baseUrl.orElse(null).
-
sandbox
final BennyOkHttpClient.Builder sandbox()
Sets baseUrl to
https://{subdomain}.bennyapi.com.
-
responseValidation
final BennyOkHttpClient.Builder responseValidation(Boolean responseValidation)
Whether to call
validateon every response before returning it.Defaults to false, which means the shape of the response will not be validated upfront. Instead, validation will only occur for the parts of the response that are accessed.
-
timeout
final BennyOkHttpClient.Builder timeout(Timeout timeout)
Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding retries.
Defaults to Timeout.default.
-
timeout
final BennyOkHttpClient.Builder timeout(Duration timeout)
Sets the maximum time allowed for a complete HTTP call, not including retries.
See Timeout.request for more details.
For fine-grained control, pass a Timeout object.
-
maxRetries
final BennyOkHttpClient.Builder maxRetries(Integer maxRetries)
The maximum number of times to retry failed requests, with a short exponential backoff between requests.
Only the following error types are retried:
Connection errors (for example, due to a network connectivity problem)
408 Request Timeout
409 Conflict
429 Rate Limit
5xx Internal
The API may also explicitly instruct the SDK to retry or not retry a request.
Defaults to 2.
-
apiKey
final BennyOkHttpClient.Builder apiKey(String apiKey)
API key authentication for public endpoints
-
subdomain
final BennyOkHttpClient.Builder subdomain(String subdomain)
-
headers
final BennyOkHttpClient.Builder headers(Headers headers)
-
putHeader
final BennyOkHttpClient.Builder putHeader(String name, String value)
-
putHeaders
final BennyOkHttpClient.Builder putHeaders(String name, Iterable<String> values)
-
putAllHeaders
final BennyOkHttpClient.Builder putAllHeaders(Headers headers)
-
putAllHeaders
final BennyOkHttpClient.Builder putAllHeaders(Map<String, Iterable<String>> headers)
-
replaceHeaders
final BennyOkHttpClient.Builder replaceHeaders(String name, String value)
-
replaceHeaders
final BennyOkHttpClient.Builder replaceHeaders(String name, Iterable<String> values)
-
replaceAllHeaders
final BennyOkHttpClient.Builder replaceAllHeaders(Headers headers)
-
replaceAllHeaders
final BennyOkHttpClient.Builder replaceAllHeaders(Map<String, Iterable<String>> headers)
-
removeHeaders
final BennyOkHttpClient.Builder removeHeaders(String name)
-
removeAllHeaders
final BennyOkHttpClient.Builder removeAllHeaders(Set<String> names)
-
queryParams
final BennyOkHttpClient.Builder queryParams(QueryParams queryParams)
-
queryParams
final BennyOkHttpClient.Builder queryParams(Map<String, Iterable<String>> queryParams)
-
putQueryParam
final BennyOkHttpClient.Builder putQueryParam(String key, String value)
-
putQueryParams
final BennyOkHttpClient.Builder putQueryParams(String key, Iterable<String> values)
-
putAllQueryParams
final BennyOkHttpClient.Builder putAllQueryParams(QueryParams queryParams)
-
putAllQueryParams
final BennyOkHttpClient.Builder putAllQueryParams(Map<String, Iterable<String>> queryParams)
-
replaceQueryParams
final BennyOkHttpClient.Builder replaceQueryParams(String key, String value)
-
replaceQueryParams
final BennyOkHttpClient.Builder replaceQueryParams(String key, Iterable<String> values)
-
replaceAllQueryParams
final BennyOkHttpClient.Builder replaceAllQueryParams(QueryParams queryParams)
-
replaceAllQueryParams
final BennyOkHttpClient.Builder replaceAllQueryParams(Map<String, Iterable<String>> queryParams)
-
removeQueryParams
final BennyOkHttpClient.Builder removeQueryParams(String key)
-
removeAllQueryParams
final BennyOkHttpClient.Builder removeAllQueryParams(Set<String> keys)
-
fromEnv
final BennyOkHttpClient.Builder fromEnv()
Updates configuration using system properties and environment variables.
-
-
-
-