From de1f2fc1abe48e4bf1f3dc9259672af2e8667600 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sat, 3 Jul 2021 01:15:17 +0100 Subject: [PATCH] Add new endpoint - /search/beta --- src/main/java/me/goudham/APIWrapper.java | 18 ++++++++++++++++-- src/main/java/me/goudham/MyWaifuClient.java | 13 +++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/goudham/APIWrapper.java b/src/main/java/me/goudham/APIWrapper.java index c8225d5..981e9a5 100644 --- a/src/main/java/me/goudham/APIWrapper.java +++ b/src/main/java/me/goudham/APIWrapper.java @@ -367,11 +367,25 @@ public class APIWrapper { return apiMapper.deserialize(userProfileResult, UserList.class); } + /** + * Retrieve a {@link List} of {@link FilteredWaifu} with a search term by sending a POST request to the API + * + * @param searchString {@link String} that should be searched for + * @return {@link Response} of {@link List} with {@link FilteredWaifu} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ + Response> betaSearch(String searchString) throws APIMapperException, APIResponseException { + Result betaSearchResult = sendPostRequest("search/beta", Map.of("term", searchString)); + return apiMapper.deserializeToList(betaSearchResult, listOf(FilteredWaifu.class)); + } + /** * Retrieve a List of {@link FilteredWaifu}'s given a query, by sending POST request to API * * @param waifuName The name of the Waifu - * @return {@link Response} of {@link FilteredWaifu} + * @return {@link Response} of {@link List} with {@link FilteredWaifu} * @throws APIResponseException If {@link APIWrapper} could not return information properly * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model * @@ -385,7 +399,7 @@ public class APIWrapper { * Retrieve a List of {@link FilteredSeries}'s given a query, by sending POST request to API * * @param seriesName The name of the Series - * @return {@link Response} of {@link FilteredSeries} + * @return {@link Response} of {@link List} with {@link FilteredSeries} * @throws APIResponseException If {@link APIWrapper} could not return information properly * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model * diff --git a/src/main/java/me/goudham/MyWaifuClient.java b/src/main/java/me/goudham/MyWaifuClient.java index 130d345..35b1d16 100644 --- a/src/main/java/me/goudham/MyWaifuClient.java +++ b/src/main/java/me/goudham/MyWaifuClient.java @@ -328,6 +328,19 @@ public class MyWaifuClient { return APIWrapper.getUserList(String.valueOf(userId), String.valueOf(listId)); } + /** + * Allows searching for a {@link Waifu} + * This search is more aggressive when it comes to name matching, resulting in better accuracy in most cases + * + * @param searchString {@link String} that should be searched for + * @return {@link Response} of {@link List} with {@link FilteredWaifu} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + */ + public Response> betaSearch(@NotNull String searchString) throws APIResponseException, APIMapperException { + return APIWrapper.betaSearch(searchString); + } + /** * Searches only Waifu's using a given query. The higher the relevance, the better the match *