public abstract class GenericAPIClientBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
apiKey |
protected String |
applicationId |
protected int |
connectTimeout |
protected String |
customAgent |
protected String |
customAgentVersion |
protected Map<String,String> |
customHeaders |
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
protected Random |
random |
protected int |
readTimeout |
| Constructor and Description |
|---|
GenericAPIClientBuilder(String applicationId,
String apiKey)
Initialize this builder with the applicationId and apiKey
|
| Modifier and Type | Method and Description |
|---|---|
protected List<String> |
generateBuildHosts() |
protected Map<String,String> |
generateHeaders() |
protected List<String> |
generateQueryHosts() |
GenericAPIClientBuilder |
setConnectTimeout(int connectTimeout)
Set the connect timeout of the HTTP client
|
GenericAPIClientBuilder |
setExtraHeader(String key,
String value)
Set extra headers to the requests
|
GenericAPIClientBuilder |
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Set the Jackson ObjectMapper, it overrides the default one and add 2 features:
* Enables: AUTO_CLOSE_JSON_CONTENT
* Disables: FAIL_ON_UNKNOWN_PROPERTIES
|
GenericAPIClientBuilder |
setReadTimeout(int readTimeout)
Set the read timeout of the HTTP client
|
GenericAPIClientBuilder |
setUserAgent(String customAgent,
String customAgentVersion)
Customize the user agent
|
protected final Random random
protected final String applicationId
protected final String apiKey
protected String customAgent
protected String customAgentVersion
protected int connectTimeout
protected int readTimeout
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
public GenericAPIClientBuilder(@Nonnull String applicationId, @Nonnull String apiKey)
applicationId - APP_ID can be found on https://www.algolia.com/api-keysapiKey - Algolia API_KEY can also be found on https://www.algolia.com/api-keyspublic GenericAPIClientBuilder setUserAgent(@Nonnull String customAgent, @Nonnull String customAgentVersion)
customAgent - key to add to the user agentcustomAgentVersion - value of this key to add to the user agentpublic GenericAPIClientBuilder setExtraHeader(@Nonnull String key, String value)
key - name of the headervalue - value of the headerpublic GenericAPIClientBuilder setConnectTimeout(int connectTimeout)
connectTimeout - the value in mspublic GenericAPIClientBuilder setReadTimeout(int readTimeout)
readTimeout - the value in mspublic GenericAPIClientBuilder setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper - the mapperCopyright © 2016. All rights reserved.