Skip to content

Commit ddbec57

Browse files
authored
refactor: rename RecommendationClient to PersonalizationClient (#750)
1 parent f9896ed commit ddbec57

File tree

12 files changed

+585
-44
lines changed

12 files changed

+585
-44
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.algolia.search;
2+
3+
import javax.annotation.Nonnull;
4+
5+
/**
6+
* Algolia's REST recommendation client that wraps an instance of the transporter {@link
7+
* HttpTransport} which wraps the HTTP Client This client allows to build typed requests and read
8+
* typed responses. Requests are made under the Algolia's retry-strategy. This client is intended to
9+
* be reused and it's thread-safe.
10+
*
11+
* @see <a href="https://www.algolia.com/doc/rest-api/personalization/">Algolia.com</a>
12+
*/
13+
public class DefaultPersonalizationClient {
14+
15+
// Suppress default constructor for noninstantiability
16+
private DefaultPersonalizationClient() {
17+
throw new AssertionError();
18+
}
19+
20+
/**
21+
* Creates a {@link PersonalizationClient} with the given credentials The default HttpClient
22+
* implementation is {@link ApacheHttpRequester}
23+
*
24+
* @param applicationID The Algolia Application ID
25+
* @param apiKey The Algolia API Key
26+
* @param region Region where your personalization data is stored and processed.
27+
* @throws NullPointerException If one of the following ApplicationID/ApiKey is null
28+
* @throws IllegalArgumentException If the ApplicationID or the APIKey are empty
29+
*/
30+
public static PersonalizationClient create(
31+
@Nonnull String applicationID, @Nonnull String apiKey, @Nonnull String region) {
32+
return create(new PersonalizationConfig.Builder(applicationID, apiKey, region).build());
33+
}
34+
35+
/**
36+
* Creates a default {@link PersonalizationClient} with the given {@link SearchConfig}. The
37+
* default HttpClient implementation is {@link ApacheHttpRequester}
38+
*
39+
* @param config The configuration allows you to advanced configuration of the clients such as
40+
* batch size or custom hosts and timeout.
41+
* @throws NullPointerException If one of the following ApplicationID/ApiKey/Config is null
42+
* @throws IllegalArgumentException If the ApplicationID or the APIKey are empty
43+
*/
44+
public static PersonalizationClient create(@Nonnull PersonalizationConfig config) {
45+
return new PersonalizationClient(config, new ApacheHttpRequester(config));
46+
}
47+
}

algoliasearch-apache/src/main/java/com/algolia/search/DefaultRecommendationClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
* be reused and it's thread-safe.
1010
*
1111
* @see <a href="https://www.algolia.com/doc/rest-api/recommendation/">Algolia.com</a>
12+
* @deprecated use {@link DefaultPersonalizationClient} instead
1213
*/
1314
@SuppressWarnings("WeakerAccess")
15+
@Deprecated
1416
public class DefaultRecommendationClient {
1517

1618
/**
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.algolia.search.personalization;
2+
3+
import com.algolia.search.DefaultPersonalizationClient;
4+
import com.algolia.search.IntegrationTestExtension;
5+
import com.algolia.search.PersonalizationClient;
6+
import com.algolia.search.integration.TestHelpers;
7+
import java.io.IOException;
8+
import org.junit.jupiter.api.AfterAll;
9+
import org.junit.jupiter.api.extension.ExtendWith;
10+
11+
@ExtendWith({IntegrationTestExtension.class})
12+
class PersonalizationTest
13+
extends com.algolia.search.integration.personalization.PersonalizationTest {
14+
15+
private static final PersonalizationClient personalizationClient =
16+
DefaultPersonalizationClient.create(
17+
TestHelpers.ALGOLIA_APPLICATION_ID_1, TestHelpers.ALGOLIA_ADMIN_KEY_1, "eu");
18+
19+
PersonalizationTest() {
20+
super(personalizationClient);
21+
}
22+
23+
@AfterAll
24+
static void close() throws IOException {
25+
personalizationClient.close();
26+
}
27+
}

algoliasearch-apache/src/test/java/com/algolia/search/recommendation/RecommendationTest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)