-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
585 additions
and
44 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
algoliasearch-apache/src/main/java/com/algolia/search/DefaultPersonalizationClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...iasearch-apache/src/test/java/com/algolia/search/personalization/PersonalizationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
algoliasearch-apache/src/test/java/com/algolia/search/recommendation/RecommendationTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.