From e8bced78cb55f994164c7260d77a2bcfe8b12f31 Mon Sep 17 00:00:00 2001 From: Hammy Date: Tue, 15 Jun 2021 02:40:58 +0100 Subject: [PATCH] Add endpoint support for searchSeries & Update documentation --- src/main/java/me/goudham/APIWrapper.java | 23 +++++++++++++++++++++ src/main/java/me/goudham/MyWaifuClient.java | 22 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/main/java/me/goudham/APIWrapper.java b/src/main/java/me/goudham/APIWrapper.java index 6ef4eae..c8225d5 100644 --- a/src/main/java/me/goudham/APIWrapper.java +++ b/src/main/java/me/goudham/APIWrapper.java @@ -367,11 +367,34 @@ public class APIWrapper { return apiMapper.deserialize(userProfileResult, UserList.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} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response> searchWaifus(String waifuName) throws APIMapperException, APIResponseException { Result searchWaifusResult = sendPostRequest("search/waifus", Map.of("term", waifuName)); return apiMapper.deserializeToList(searchWaifusResult, listOf(FilteredWaifu.class)); } + /** + * 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} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ + Response> searchSeries(String seriesName) throws APIMapperException, APIResponseException { + Result searchSeriesResult = sendPostRequest("search/series", Map.of("term", seriesName)); + return apiMapper.deserializeToList(searchSeriesResult, listOf(FilteredSeries.class)); + } + void setApiKey(String apiKey) { this.apiKey = apiKey; } diff --git a/src/main/java/me/goudham/MyWaifuClient.java b/src/main/java/me/goudham/MyWaifuClient.java index a77a77d..130d345 100644 --- a/src/main/java/me/goudham/MyWaifuClient.java +++ b/src/main/java/me/goudham/MyWaifuClient.java @@ -328,10 +328,32 @@ public class MyWaifuClient { return APIWrapper.getUserList(String.valueOf(userId), String.valueOf(listId)); } + /** + * Searches only Waifu's using a given query. The higher the relevance, the better the match + * + * @param name The name of the Waifu + * @return {@link Response} of {@link FilteredWaifu} + * @throws APIMapperException If {@link APIWrapper} could not return information properly + * @throws APIResponseException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ public Response> searchWaifus(@NotNull String name) throws APIMapperException, APIResponseException { return APIWrapper.searchWaifus(name); } + /** + * Searches only Series' using a given query. The higher the relevance, the better the match + * + * @param name The name of the Series + * @return {@link Response} of {@link FilteredSeries} + * @throws APIMapperException If {@link APIWrapper} could not return information properly + * @throws APIResponseException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ + public Response> searchSeries(@NotNull String name) throws APIMapperException, APIResponseException { + return APIWrapper.searchSeries(name); + } + /** * Builder for {@link MyWaifuClient} *