public final class InsightsClient extends Object implements Closeable
HttpTransport
which wraps the HTTP Client This client allows to build typed requests and read typed responses.
Requests are made under the Algolia's retry-strategy. This client is intended to be reused and
it's thread-safe.| Constructor and Description |
|---|
InsightsClient(InsightsConfig config,
HttpRequester httpRequester)
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the underlying Http Client
|
ConfigBase |
getConfig()
Get Client's configuration
|
InsightsResult |
sendEvent(InsightsEvent event)
This command pushes an event to the Insights API.
|
InsightsResult |
sendEvent(InsightsEvent event,
RequestOptions requestOptions)
This command pushes an event to the Insights API.
|
CompletableFuture<InsightsResult> |
sendEventAsync(InsightsEvent event)
This command pushes an event to the Insights API.
|
CompletableFuture<InsightsResult> |
sendEventAsync(InsightsEvent event,
RequestOptions requestOptions)
This command pushes an event to the Insights API.
|
InsightsResult |
sendEvents(List<InsightsEvent> events)
This command pushes an array of events to the Insights API.
|
InsightsResult |
sendEvents(List<InsightsEvent> events,
RequestOptions requestOptions)
This command pushes an array of events to the Insights API.
|
CompletableFuture<InsightsResult> |
sendEventsAsync(List<InsightsEvent> events)
This command pushes an array of events to the Insights API.
|
CompletableFuture<InsightsResult> |
sendEventsAsync(List<InsightsEvent> events,
RequestOptions requestOptions)
This command pushes an array of events to the Insights API.
|
UserInsightsClient |
user(String userToken) |
public InsightsClient(@Nonnull InsightsConfig config, @Nonnull HttpRequester httpRequester)
config - The configuration allows you to advanced configuration of the clients such as
batch size or custom hosts and timeout.httpRequester - Another HTTP Client than the default one. Must be an implementation of
HttpRequester.NullPointerException - If one of the following
ApplicationID/ApiKey/Configuration/Requester is nullIllegalArgumentException - If the ApplicationID or the APIKey are emptypublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - if an I/O error occurspublic ConfigBase getConfig()
public UserInsightsClient user(@Nonnull String userToken)
userToken - the user configpublic InsightsResult sendEvent(@Nonnull InsightsEvent event)
event - An eventAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationpublic InsightsResult sendEvent(@Nonnull InsightsEvent event, RequestOptions requestOptions)
event - An eventrequestOptions - RequestOptionsAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationpublic CompletableFuture<InsightsResult> sendEventAsync(@Nonnull InsightsEvent event)
event - An eventAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationpublic CompletableFuture<InsightsResult> sendEventAsync(@Nonnull InsightsEvent event, RequestOptions requestOptions)
event - An eventrequestOptions - RequestOptionsAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationpublic InsightsResult sendEvents(@Nonnull List<InsightsEvent> events)
events - List of eventsAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationpublic InsightsResult sendEvents(@Nonnull List<InsightsEvent> events, RequestOptions requestOptions)
events - List of eventsrequestOptions - RequestOptionsAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationpublic CompletableFuture<InsightsResult> sendEventsAsync(@Nonnull List<InsightsEvent> events)
events - List of eventsAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationpublic CompletableFuture<InsightsResult> sendEventsAsync(@Nonnull List<InsightsEvent> events, RequestOptions requestOptions)
events - List of eventsrequestOptions - RequestOptionsAlgoliaRetryException - When the retry has failed on all hostsAlgoliaApiException - When the API sends an http error codeAlgoliaRuntimeException - When an error occurred during the serializationCopyright © 2019. All rights reserved.