Skip to content

Commit

Permalink
refactor: rename RecommendationClient to PersonalizationClient (#750
Browse files Browse the repository at this point in the history
)
  • Loading branch information
aallam authored Jul 19, 2021
1 parent f9896ed commit ddbec57
Show file tree
Hide file tree
Showing 12 changed files with 585 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.algolia.search;

import javax.annotation.Nonnull;

/**
* Algolia's REST recommendation client that wraps an instance of the transporter {@link
* 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.
*
* @see <a href="https://www.algolia.com/doc/rest-api/personalization/">Algolia.com</a>
*/
public class DefaultPersonalizationClient {

// Suppress default constructor for noninstantiability
private DefaultPersonalizationClient() {
throw new AssertionError();
}

/**
* Creates a {@link PersonalizationClient} with the given credentials The default HttpClient
* implementation is {@link ApacheHttpRequester}
*
* @param applicationID The Algolia Application ID
* @param apiKey The Algolia API Key
* @param region Region where your personalization data is stored and processed.
* @throws NullPointerException If one of the following ApplicationID/ApiKey is null
* @throws IllegalArgumentException If the ApplicationID or the APIKey are empty
*/
public static PersonalizationClient create(
@Nonnull String applicationID, @Nonnull String apiKey, @Nonnull String region) {
return create(new PersonalizationConfig.Builder(applicationID, apiKey, region).build());
}

/**
* Creates a default {@link PersonalizationClient} with the given {@link SearchConfig}. The
* default HttpClient implementation is {@link ApacheHttpRequester}
*
* @param config The configuration allows you to advanced configuration of the clients such as
* batch size or custom hosts and timeout.
* @throws NullPointerException If one of the following ApplicationID/ApiKey/Config is null
* @throws IllegalArgumentException If the ApplicationID or the APIKey are empty
*/
public static PersonalizationClient create(@Nonnull PersonalizationConfig config) {
return new PersonalizationClient(config, new ApacheHttpRequester(config));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* be reused and it's thread-safe.
*
* @see <a href="https://www.algolia.com/doc/rest-api/recommendation/">Algolia.com</a>
* @deprecated use {@link DefaultPersonalizationClient} instead
*/
@SuppressWarnings("WeakerAccess")
@Deprecated
public class DefaultRecommendationClient {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.algolia.search.personalization;

import com.algolia.search.DefaultPersonalizationClient;
import com.algolia.search.IntegrationTestExtension;
import com.algolia.search.PersonalizationClient;
import com.algolia.search.integration.TestHelpers;
import java.io.IOException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.extension.ExtendWith;

@ExtendWith({IntegrationTestExtension.class})
class PersonalizationTest
extends com.algolia.search.integration.personalization.PersonalizationTest {

private static final PersonalizationClient personalizationClient =
DefaultPersonalizationClient.create(
TestHelpers.ALGOLIA_APPLICATION_ID_1, TestHelpers.ALGOLIA_ADMIN_KEY_1, "eu");

PersonalizationTest() {
super(personalizationClient);
}

@AfterAll
static void close() throws IOException {
personalizationClient.close();
}
}

This file was deleted.

Loading

0 comments on commit ddbec57

Please sign in to comment.