Class PersonalizationClient
- java.lang.Object
-
- com.algolia.search.PersonalizationClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class PersonalizationClient extends Object implements Closeable
Algolia's REST recommendation client that wraps an instance of the transporterHttpTransportwhich 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.- See Also:
- Algolia.com
-
-
Constructor Summary
Constructors Constructor Description PersonalizationClient(PersonalizationConfig config, HttpRequester httpRequester)Creates a customPersonalizationClientwith the givenPersonalizationConfigand the givenHttpRequester
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying Http ClientDeletePersonalizationProfileResponsedeletePersonalizationProfile(String userToken)Delete the user profile and all its associated data.DeletePersonalizationProfileResponsedeletePersonalizationProfile(String userToken, RequestOptions requestOptions)Delete the user profile and all its associated data.CompletableFuture<DeletePersonalizationProfileResponse>deletePersonalizationProfileAsync(String userToken)Delete the user profile and all its associated data.CompletableFuture<DeletePersonalizationProfileResponse>deletePersonalizationProfileAsync(String userToken, RequestOptions requestOptions)Delete the user profile and all its associated data.ConfigBasegetConfig()Get Client's configurationPersonalizationProfileResponsegetPersonalizationProfile(String userToken)Get the user profile built from Personalization strategy.PersonalizationProfileResponsegetPersonalizationProfile(String userToken, RequestOptions requestOptions)Get the user profile built from Personalization strategy.CompletableFuture<PersonalizationProfileResponse>getPersonalizationProfileAsync(String userToken)Get the user profile built from Personalization strategy.CompletableFuture<PersonalizationProfileResponse>getPersonalizationProfileAsync(String userToken, RequestOptions requestOptions)Get the user profile built from Personalization strategy.GetStrategyResponsegetPersonalizationStrategy()Returns the personalization strategy of the applicationGetStrategyResponsegetPersonalizationStrategy(RequestOptions requestOptions)Returns the personalization strategy of the applicationCompletableFuture<GetStrategyResponse>getPersonalizationStrategyAsync()Returns the personalization strategy of the applicationCompletableFuture<GetStrategyResponse>getPersonalizationStrategyAsync(RequestOptions requestOptions)Returns the personalization strategy of the applicationHttpTransportgetTransport()Transport object responsible for the serialization/deserialization and the retry strategy.SetStrategyResponsesetPersonalizationStrategy(SetStrategyRequest request)This command configures the personalization strategySetStrategyResponsesetPersonalizationStrategy(SetStrategyRequest request, RequestOptions requestOptions)This command configures the personalization strategyCompletableFuture<SetStrategyResponse>setPersonalizationStrategyAsync(SetStrategyRequest request)This command configures the personalization strategyCompletableFuture<SetStrategyResponse>setPersonalizationStrategyAsync(SetStrategyRequest request, RequestOptions requestOptions)This command configures the personalization strategy
-
-
-
Constructor Detail
-
PersonalizationClient
public PersonalizationClient(@Nonnull PersonalizationConfig config, @Nonnull HttpRequester httpRequester)
Creates a customPersonalizationClientwith the givenPersonalizationConfigand the givenHttpRequester- Parameters:
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 ofHttpRequester.- Throws:
NullPointerException- If one of the following ApplicationID/ApiKey/Configuration/Requester is nullIllegalArgumentException- If the ApplicationID or the APIKey are empty
-
-
Method Detail
-
close
public void close() throws IOExceptionClose the underlying Http Client- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
getTransport
public HttpTransport getTransport()
Transport object responsible for the serialization/deserialization and the retry strategy.
-
getPersonalizationStrategy
public GetStrategyResponse getPersonalizationStrategy()
Returns the personalization strategy of the application- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getPersonalizationStrategy
public GetStrategyResponse getPersonalizationStrategy(RequestOptions requestOptions)
Returns the personalization strategy of the application- Parameters:
requestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getPersonalizationStrategyAsync
public CompletableFuture<GetStrategyResponse> getPersonalizationStrategyAsync()
Returns the personalization strategy of the application- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getPersonalizationStrategyAsync
public CompletableFuture<GetStrategyResponse> getPersonalizationStrategyAsync(RequestOptions requestOptions)
Returns the personalization strategy of the application- Parameters:
requestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
setPersonalizationStrategy
public SetStrategyResponse setPersonalizationStrategy(@Nonnull SetStrategyRequest request)
This command configures the personalization strategy- Parameters:
request- The personalization strategy- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
setPersonalizationStrategy
public SetStrategyResponse setPersonalizationStrategy(@Nonnull SetStrategyRequest request, RequestOptions requestOptions)
This command configures the personalization strategy- Parameters:
request- The personalization strategyrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
setPersonalizationStrategyAsync
public CompletableFuture<SetStrategyResponse> setPersonalizationStrategyAsync(@Nonnull SetStrategyRequest request)
This command configures the personalization strategy- Parameters:
request- The personalization strategy- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
setPersonalizationStrategyAsync
public CompletableFuture<SetStrategyResponse> setPersonalizationStrategyAsync(@Nonnull SetStrategyRequest request, RequestOptions requestOptions)
This command configures the personalization strategy- Parameters:
request- The personalization strategyrequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getPersonalizationProfile
public PersonalizationProfileResponse getPersonalizationProfile(@Nonnull String userToken)
Get the user profile built from Personalization strategy.The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
- Parameters:
userToken- userToken representing the user for which to fetch the Personalization profile- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getPersonalizationProfile
public PersonalizationProfileResponse getPersonalizationProfile(@Nonnull String userToken, RequestOptions requestOptions)
Get the user profile built from Personalization strategy.The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
- Parameters:
userToken- userToken representing the user for which to fetch the Personalization profilerequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getPersonalizationProfileAsync
public CompletableFuture<PersonalizationProfileResponse> getPersonalizationProfileAsync(@Nonnull String userToken)
Get the user profile built from Personalization strategy.The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
- Parameters:
userToken- userToken representing the user for which to fetch the Personalization profile- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getPersonalizationProfileAsync
public CompletableFuture<PersonalizationProfileResponse> getPersonalizationProfileAsync(@Nonnull String userToken, RequestOptions requestOptions)
Get the user profile built from Personalization strategy.The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
- Parameters:
userToken- userToken representing the user for which to fetch the Personalization profilerequestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
deletePersonalizationProfile
public DeletePersonalizationProfileResponse deletePersonalizationProfile(@Nonnull String userToken)
Delete the user profile and all its associated data.Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means that if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile.
It might take a couple hours before for the deletion request to be fully processed.
- Parameters:
userToken- userToken representing the user for which to delete the Personalization profile and associated data.- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
deletePersonalizationProfile
public DeletePersonalizationProfileResponse deletePersonalizationProfile(@Nonnull String userToken, RequestOptions requestOptions)
Delete the user profile and all its associated data.Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means that if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile.
It might take a couple hours before for the deletion request to be fully processed.
- Parameters:
userToken- userToken representing the user for which to delete the Personalization profile and associated data.requestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
deletePersonalizationProfileAsync
public CompletableFuture<DeletePersonalizationProfileResponse> deletePersonalizationProfileAsync(@Nonnull String userToken)
Delete the user profile and all its associated data.Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means that if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile.
It might take a couple hours before for the deletion request to be fully processed.
- Parameters:
userToken- userToken representing the user for which to delete the Personalization profile and associated data.- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
deletePersonalizationProfileAsync
public CompletableFuture<DeletePersonalizationProfileResponse> deletePersonalizationProfileAsync(@Nonnull String userToken, RequestOptions requestOptions)
Delete the user profile and all its associated data.Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means that if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile.
It might take a couple hours before for the deletion request to be fully processed.
- Parameters:
userToken- userToken representing the user for which to delete the Personalization profile and associated data.requestOptions- Options to pass to this request- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
getConfig
public ConfigBase getConfig()
Get Client's configuration
-
-