All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.algolia.search.UserInsightsClient Maven / Gradle / Ivy

The newest version!
package com.algolia.search;

import com.algolia.search.exceptions.AlgoliaApiException;
import com.algolia.search.exceptions.AlgoliaRetryException;
import com.algolia.search.exceptions.AlgoliaRuntimeException;
import com.algolia.search.exceptions.LaunderThrowable;
import com.algolia.search.models.RequestOptions;
import com.algolia.search.models.insights.InsightsEvent;
import com.algolia.search.models.insights.InsightsResult;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;

@SuppressWarnings("WeakerAccess")
public final class UserInsightsClient {

  private final String userToken;
  private final InsightsClient insightsClient;

  public UserInsightsClient(String userToken, InsightsClient insightsClient) {
    this.userToken = userToken;
    this.insightsClient = insightsClient;
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult clickedFilters(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List filters) {
    return LaunderThrowable.await(clickedFiltersAsync(eventName, indexName, filters));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult clickedFilters(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List filters,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        clickedFiltersAsync(eventName, indexName, filters, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture clickedFiltersAsync(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List filters) {
    return clickedFiltersAsync(eventName, indexName, filters, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture clickedFiltersAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List filters,
      RequestOptions requestOptions) {

    InsightsEvent event =
        new InsightsEvent()
            .setEventType("click")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setFilters(filters);

    return insightsClient.sendEventAsync(event, requestOptions);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult clickedObjectIDs(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List objectIDs) {
    return LaunderThrowable.await(clickedObjectIDsAsync(eventName, indexName, objectIDs));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult clickedObjectIDs(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        clickedObjectIDsAsync(eventName, indexName, objectIDs, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture clickedObjectIDsAsync(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List objectIDs) {
    return clickedObjectIDsAsync(eventName, indexName, objectIDs, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture clickedObjectIDsAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      RequestOptions requestOptions) {

    InsightsEvent event =
        new InsightsEvent()
            .setEventType("click")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setObjectIDs(objectIDs);

    return insightsClient.sendEventAsync(event, requestOptions);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param positions List of position
   * @param queryID The query Id
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult clickedObjectIDsAfterSearch(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull List positions,
      @Nonnull String queryID) {
    return LaunderThrowable.await(
        clickedObjectIDsAfterSearchAsync(eventName, indexName, objectIDs, positions, queryID));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param positions List of position
   * @param queryID The query Id
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult clickedObjectIDsAfterSearch(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull List positions,
      @Nonnull String queryID,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        clickedObjectIDsAfterSearchAsync(
            eventName, indexName, objectIDs, positions, queryID, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param positions List of position
   * @param queryID The query Id
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture clickedObjectIDsAfterSearchAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull List positions,
      @Nonnull String queryID) {
    return clickedObjectIDsAfterSearchAsync(
        eventName, indexName, objectIDs, positions, queryID, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param positions List of position
   * @param queryID The query Id
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture clickedObjectIDsAfterSearchAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull List positions,
      @Nonnull String queryID,
      RequestOptions requestOptions) {

    InsightsEvent event =
        new InsightsEvent()
            .setEventType("click")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setObjectIDs(objectIDs)
            .setPositions(positions)
            .setQueryID(queryID);

    return insightsClient.sendEventAsync(event, requestOptions);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult convertedObjectIDs(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List objectIDs) {
    return LaunderThrowable.await(convertedObjectIDsAsync(eventName, indexName, objectIDs));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult convertedObjectIDs(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        convertedObjectIDsAsync(eventName, indexName, objectIDs, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture convertedObjectIDsAsync(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List objectIDs) {
    return convertedObjectIDsAsync(eventName, indexName, objectIDs, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture convertedObjectIDsAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      RequestOptions requestOptions) {
    InsightsEvent event =
        new InsightsEvent()
            .setEventType("conversion")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setObjectIDs(objectIDs);

    return insightsClient.sendEventAsync(event, requestOptions);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param queryID The query Id
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult convertedObjectIDsAfterSearch(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull String queryID) {
    return LaunderThrowable.await(
        convertedObjectIDsAfterSearchAsync(eventName, indexName, objectIDs, queryID));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param queryID The query Id
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult convertedObjectIDsAfterSearch(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull String queryID,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        convertedObjectIDsAfterSearchAsync(
            eventName, indexName, objectIDs, queryID, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param queryID The query Id
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture convertedObjectIDsAfterSearchAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull String queryID) {
    return convertedObjectIDsAfterSearchAsync(eventName, indexName, objectIDs, queryID, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param queryID The query Id
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture convertedObjectIDsAfterSearchAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      @Nonnull String queryID,
      RequestOptions requestOptions) {
    InsightsEvent event =
        new InsightsEvent()
            .setEventType("conversion")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setObjectIDs(objectIDs)
            .setQueryID(queryID);

    return insightsClient.sendEventAsync(event, requestOptions);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The index name
   * @param filters List of filters
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult convertedFilters(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List filters) {
    return LaunderThrowable.await(convertedFiltersAsync(eventName, indexName, filters));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The index name
   * @param filters List of filters
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult convertedFilters(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List filters,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        convertedFiltersAsync(eventName, indexName, filters, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The index name
   * @param filters List of filters
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture convertedFiltersAsync(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List filters) {
    InsightsEvent event =
        new InsightsEvent()
            .setEventType("conversion")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setFilters(filters);

    return insightsClient.sendEventAsync(event, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The index name
   * @param filters List of filters
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture convertedFiltersAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List filters,
      RequestOptions requestOptions) {
    InsightsEvent event =
        new InsightsEvent()
            .setEventType("conversion")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setFilters(filters);

    return insightsClient.sendEventAsync(event, requestOptions);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult viewedFilters(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List filters) {
    return LaunderThrowable.await(viewedFiltersAsync(eventName, indexName, filters));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult viewedFilters(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List filters,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        viewedFiltersAsync(eventName, indexName, filters, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture viewedFiltersAsync(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List filters) {
    return viewedFiltersAsync(eventName, indexName, filters, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param filters Filters parameters
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture viewedFiltersAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List filters,
      RequestOptions requestOptions) {
    InsightsEvent event =
        new InsightsEvent()
            .setEventType("view")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setFilters(filters);

    return insightsClient.sendEventAsync(event, requestOptions);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult viewedObjectIDs(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List objectIDs) {
    return LaunderThrowable.await(viewedObjectIDsAsync(eventName, indexName, objectIDs));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public InsightsResult viewedObjectIDs(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      RequestOptions requestOptions) {
    return LaunderThrowable.await(
        viewedObjectIDsAsync(eventName, indexName, objectIDs, requestOptions));
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture viewedObjectIDsAsync(
      @Nonnull String eventName, @Nonnull String indexName, @Nonnull List objectIDs) {
    return viewedObjectIDsAsync(eventName, indexName, objectIDs, null);
  }

  /**
   * @param eventName The Event Name
   * @param indexName The Index Name
   * @param objectIDs List of objectId
   * @param requestOptions RequestOptions
   * @throws AlgoliaRetryException When the retry has failed on all hosts
   * @throws AlgoliaApiException When the API sends an http error code
   * @throws AlgoliaRuntimeException When an error occurred during the serialization
   */
  public CompletableFuture viewedObjectIDsAsync(
      @Nonnull String eventName,
      @Nonnull String indexName,
      @Nonnull List objectIDs,
      RequestOptions requestOptions) {
    InsightsEvent event =
        new InsightsEvent()
            .setEventType("view")
            .setUserToken(userToken)
            .setEventName(eventName)
            .setIndex(indexName)
            .setObjectIDs(objectIDs);

    return insightsClient.sendEventAsync(event, requestOptions);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy