From fad4948fc075cfbb19772ec64209300bd47f5110 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 01:45:07 +0100 Subject: [PATCH 01/16] Update documentation --- src/main/java/me/goudham/domain/waifu/FilteredWaifu.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/me/goudham/domain/waifu/FilteredWaifu.java b/src/main/java/me/goudham/domain/waifu/FilteredWaifu.java index 9cce0fb..cbcf7e0 100644 --- a/src/main/java/me/goudham/domain/waifu/FilteredWaifu.java +++ b/src/main/java/me/goudham/domain/waifu/FilteredWaifu.java @@ -20,6 +20,7 @@ import java.util.Objects; *
  • {@link String romaji}
  • *
  • {@link String romajiName}
  • *
  • {@link String displayPicture}
  • + *
  • {@link String description}
  • *
  • {@link Integer likes}
  • *
  • {@link Integer trash}
  • *
  • {@link String type}
  • From 2580c0756af5677a954d09ba514bc68f41578bc0 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 01:55:53 +0100 Subject: [PATCH 02/16] Update pom.xml Auto Release to OSSRH --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cd0f603..6c323e5 100644 --- a/pom.xml +++ b/pom.xml @@ -150,7 +150,7 @@ ossrh https://s01.oss.sonatype.org/ - false + true From 0f891e466d0f3263f1efea70ead61c5e2a717db8 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 01:58:29 +0100 Subject: [PATCH 03/16] Add Enum for User Actions on Waifus Reduces the chance of user error to near 0% as they are forced to use this enum --- .../java/me/goudham/util/WaifuListType.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/me/goudham/util/WaifuListType.java diff --git a/src/main/java/me/goudham/util/WaifuListType.java b/src/main/java/me/goudham/util/WaifuListType.java new file mode 100644 index 0000000..6758677 --- /dev/null +++ b/src/main/java/me/goudham/util/WaifuListType.java @@ -0,0 +1,25 @@ +package me.goudham.util; + +import me.goudham.domain.user.User; +import me.goudham.domain.waifu.Waifu; + +/** + * Specifies the different actions that the {@link User} can + * perform on a {@link Waifu} + * + */ +public enum WaifuListType { + CREATED("created"), + LIKED("like"), + TRASHED("trash"); + + private final String listType; + + WaifuListType(String listType) { + this.listType = listType; + } + + public String getListType() { + return listType; + } +} From ff0f82a8d4ac8865e2f686306a11dbe8742791e3 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 02:00:09 +0100 Subject: [PATCH 04/16] Add support for getting User Waifus This includes waifus that have been created, liked or trashed --- src/main/java/me/goudham/APIWrapper.java | 5 +++++ src/main/java/me/goudham/MyWaifuClient.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/me/goudham/APIWrapper.java b/src/main/java/me/goudham/APIWrapper.java index 95aff97..12700e8 100644 --- a/src/main/java/me/goudham/APIWrapper.java +++ b/src/main/java/me/goudham/APIWrapper.java @@ -156,6 +156,11 @@ public class APIWrapper { return apiMapper.deserialize(userProfileResult, User.class); } + Response> getUserWaifus(String userId, String listType, String pageNum) throws APIResponseException, APIMapperException { + Result userWaifusResult = sendRequest("user/" + userId + "/" + listType + "?page=" + pageNum); + return apiMapper.deserializeToPaginationData(userWaifusResult, paginationData(FilteredWaifu.class)); + } + Response> getUserLists(String userId) throws APIResponseException, APIMapperException { Result userProfileResult = sendRequest("user/" + userId + "/lists"); return apiMapper.deserializeToList(userProfileResult, listOf(UserList.class)); diff --git a/src/main/java/me/goudham/MyWaifuClient.java b/src/main/java/me/goudham/MyWaifuClient.java index 67bc5cb..02406ed 100644 --- a/src/main/java/me/goudham/MyWaifuClient.java +++ b/src/main/java/me/goudham/MyWaifuClient.java @@ -11,6 +11,7 @@ import me.goudham.domain.waifu.WaifuImage; import me.goudham.exception.APIMapperException; import me.goudham.exception.APIResponseException; import me.goudham.util.Season; +import me.goudham.util.WaifuListType; import org.jetbrains.annotations.NotNull; import javax.net.ssl.SSLParameters; @@ -86,6 +87,15 @@ public class MyWaifuClient { return APIWrapper.getWaifu(String.valueOf(id)); } + /** + * Retrieves paginated images from the gallery, in sets of 10 + * + * @param id The id of the {@link Waifu} + * @param pageNum The page number of the gallery + * @return {@link Response} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + */ public Response> getWaifuImages(@NotNull Integer id, @NotNull Integer pageNum) throws APIResponseException, APIMapperException { return APIWrapper.getWaifuImages(String.valueOf(id), String.valueOf(pageNum)); } @@ -142,6 +152,9 @@ public class MyWaifuClient { return APIWrapper.getUserProfile(String.valueOf(id)); } + public Response> getUserWaifus(@NotNull Integer id, @NotNull WaifuListType waifuListType, @NotNull Integer pageNum) throws APIMapperException, APIResponseException { + return APIWrapper.getUserWaifus(String.valueOf(id), waifuListType.getListType(), String.valueOf(pageNum)); + } public Response> getUserLists(@NotNull Integer id) throws APIMapperException, APIResponseException { return APIWrapper.getUserLists(String.valueOf(id)); } From 2b25cc8f6d7f76658ae69fb00dbea537f8ef90d5 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 02:08:10 +0100 Subject: [PATCH 05/16] Add equals(), hashCode() & toString() methods --- src/main/java/me/goudham/Response.java | 24 ++++++++++++++++++++++++ src/main/java/me/goudham/Result.java | 22 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/main/java/me/goudham/Response.java b/src/main/java/me/goudham/Response.java index 0d228fa..906bc76 100644 --- a/src/main/java/me/goudham/Response.java +++ b/src/main/java/me/goudham/Response.java @@ -3,6 +3,8 @@ package me.goudham; import me.goudham.domain.series.Series; import me.goudham.domain.waifu.Waifu; +import java.util.Objects; + /** * This is returned to the User when called by methods in {@link MyWaifuClient}. * E.g {@link MyWaifuClient#getWaifu(Integer)} @@ -38,4 +40,26 @@ public class Response { public String getBody() { return body; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Response response = (Response) o; + return Objects.equals(model, response.model) && Objects.equals(statusCode, response.statusCode) && Objects.equals(body, response.body); + } + + @Override + public int hashCode() { + return Objects.hash(model, statusCode, body); + } + + @Override + public String toString() { + return "Response{" + + "model=" + model + + ", statusCode=" + statusCode + + ", body='" + body + '\'' + + '}'; + } } diff --git a/src/main/java/me/goudham/Result.java b/src/main/java/me/goudham/Result.java index 387ce84..2d8fb5e 100644 --- a/src/main/java/me/goudham/Result.java +++ b/src/main/java/me/goudham/Result.java @@ -1,6 +1,7 @@ package me.goudham; import java.net.http.HttpRequest; +import java.util.Objects; /** * Represents a Result from a {@link HttpRequest} with the resulting @@ -22,4 +23,25 @@ class Result { String getBody() { return body; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Result result = (Result) o; + return Objects.equals(statusCode, result.statusCode) && Objects.equals(body, result.body); + } + + @Override + public int hashCode() { + return Objects.hash(statusCode, body); + } + + @Override + public String toString() { + return "Result{" + + "statusCode=" + statusCode + + ", body='" + body + '\'' + + '}'; + } } From d05c80c49986ebe7644708244f06bde7a0b9a798 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 02:08:45 +0100 Subject: [PATCH 06/16] Add equals(), hashCode() & toString() methods --- .../domain/pagination/PaginationData.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/me/goudham/domain/pagination/PaginationData.java b/src/main/java/me/goudham/domain/pagination/PaginationData.java index 2437e4e..c5ea94a 100644 --- a/src/main/java/me/goudham/domain/pagination/PaginationData.java +++ b/src/main/java/me/goudham/domain/pagination/PaginationData.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyDescription; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import java.util.List; +import java.util.Objects; /** * {@link PaginationData} @@ -81,4 +82,25 @@ public class PaginationData { this.meta = meta; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PaginationData that = (PaginationData) o; + return Objects.equals(data, that.data) && Objects.equals(links, that.links) && Objects.equals(meta, that.meta); + } + + @Override + public int hashCode() { + return Objects.hash(data, links, meta); + } + + @Override + public String toString() { + return "PaginationData{" + + "data=" + data + + ", links=" + links + + ", meta=" + meta + + '}'; + } } \ No newline at end of file From 1206db4bf84df5cf9c80cace5ad2ad766b1d6eaa Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 02:10:16 +0100 Subject: [PATCH 07/16] Add support for getting paginated sets of Waifus --- src/main/java/me/goudham/APIWrapper.java | 5 +++++ src/main/java/me/goudham/MyWaifuClient.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/me/goudham/APIWrapper.java b/src/main/java/me/goudham/APIWrapper.java index 12700e8..56c5ad3 100644 --- a/src/main/java/me/goudham/APIWrapper.java +++ b/src/main/java/me/goudham/APIWrapper.java @@ -101,6 +101,11 @@ public class APIWrapper { return apiMapper.deserializeToPaginationData(waifuImagesResult, paginationData(WaifuImage.class)); } + Response> getWaifusByPage(String pageNum) throws APIResponseException, APIMapperException { + Result waifusByPageResult = sendRequest("waifu?page=" + pageNum); + return apiMapper.deserializeToPaginationData(waifusByPageResult, paginationData(FilteredWaifu.class)); + } + Response getDailyWaifu() throws APIResponseException, APIMapperException { Result dailyWaifuResult = sendRequest("meta/daily"); return apiMapper.deserialize(dailyWaifuResult, FilteredWaifu.class); diff --git a/src/main/java/me/goudham/MyWaifuClient.java b/src/main/java/me/goudham/MyWaifuClient.java index 02406ed..690aa6b 100644 --- a/src/main/java/me/goudham/MyWaifuClient.java +++ b/src/main/java/me/goudham/MyWaifuClient.java @@ -100,6 +100,10 @@ public class MyWaifuClient { return APIWrapper.getWaifuImages(String.valueOf(id), String.valueOf(pageNum)); } + public Response> getWaifusByPage(@NotNull Integer pageNum) throws APIMapperException, APIResponseException { + return APIWrapper.getWaifusByPage(String.valueOf(pageNum)); + } + public Response getDailyWaifu() throws APIResponseException, APIMapperException { return APIWrapper.getDailyWaifu(); } From 22d123da5511d561ce770ae9dbb0a2c380501638 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 02:56:30 +0100 Subject: [PATCH 08/16] Add documentation --- src/main/java/me/goudham/MyWaifuClient.java | 177 +++++++++++++++++++- 1 file changed, 169 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/goudham/MyWaifuClient.java b/src/main/java/me/goudham/MyWaifuClient.java index 690aa6b..95b811d 100644 --- a/src/main/java/me/goudham/MyWaifuClient.java +++ b/src/main/java/me/goudham/MyWaifuClient.java @@ -29,6 +29,7 @@ import java.util.concurrent.Executor; * *

    Main entry point for retrieving information from MyWaifuList.

    *

    {@link APIWrapper} is utilised to make the API requests

    + * */ public class MyWaifuClient { private final APIWrapper APIWrapper; @@ -50,6 +51,7 @@ public class MyWaifuClient { * * @param apiKey API Key to authorise API request * @return {@link MyWaifuClient} + * */ public static MyWaifuClient createDefault(@NotNull String apiKey) { HttpClient httpClient = HttpClient.newBuilder() @@ -62,25 +64,27 @@ public class MyWaifuClient { } /** - * Retrieves information about the {@link Waifu} specified by the given slug + * Retrieve detailed information about the {@link Waifu} specified by the given slug * * @param slug The slug of the {@link Waifu} - * @return {@link Response} + * @return {@link Response} of {@link Waifu} * @throws APIResponseException If {@link APIWrapper} could not return information properly * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * @see #getWaifu(Integer) * */ - public Response getWaifu(@NotNull String slug) throws APIResponseException, APIMapperException { + private Response getWaifu(@NotNull String slug) throws APIResponseException, APIMapperException { return APIWrapper.getWaifu(slug); } /** - * Retrieves information about the {@link Waifu} specified by the given id + * Retrieve information about the {@link Waifu} specified by the given id * * @param id The id of the {@link Waifu} - * @return {@link Response} + * @return {@link Response} of {@link Waifu} * @throws APIResponseException If {@link APIWrapper} could not return information properly * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * @see #getWaifu(String) * */ public Response getWaifu(@NotNull Integer id) throws APIResponseException, APIMapperException { @@ -88,81 +92,238 @@ public class MyWaifuClient { } /** - * Retrieves paginated images from the gallery, in sets of 10 + * Retrieve paginated images from the gallery, in sets of 10 * * @param id The id of the {@link Waifu} * @param pageNum The page number of the gallery - * @return {@link Response} + * @return {@link Response} of {@link WaifuImage} * @throws APIResponseException If {@link APIWrapper} could not return information properly * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * */ public Response> getWaifuImages(@NotNull Integer id, @NotNull Integer pageNum) throws APIResponseException, APIMapperException { return APIWrapper.getWaifuImages(String.valueOf(id), String.valueOf(pageNum)); } + /** + * Retrieve an array of {@link FilteredWaifu}'s, sorted alphabetically + * + * @param pageNum The page number of the gallery + * @return {@link Response} of {@link PaginationData} 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> getWaifusByPage(@NotNull Integer pageNum) throws APIMapperException, APIResponseException { return APIWrapper.getWaifusByPage(String.valueOf(pageNum)); } + /** + * Retrieve the Waifu of the Day + * + * @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 + * + */ public Response getDailyWaifu() throws APIResponseException, APIMapperException { return APIWrapper.getDailyWaifu(); } + /** + * Retrieve a Random Waifu from the Website + * + * @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 + * + */ public Response getRandomWaifu() throws APIResponseException, APIMapperException { return APIWrapper.getRandomWaifu(); } + /** + * Retrieve a List of Currently Airing Anime + * + * @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 + * + */ public Response> getSeasonalAnime() throws APIMapperException, APIResponseException { return APIWrapper.getSeasonalAnime(); } + /** + * Retrieve the Best Waifus of the Current Season + * + * @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> getBestWaifus() throws APIMapperException, APIResponseException { return APIWrapper.getBestWaifus(); } + /** + * Retrieve a List of Popular Waifus (Raw Count of Total Votes) of the Current Season + * + * @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> getPopularWaifus() throws APIMapperException, APIResponseException { return APIWrapper.getPopularWaifus(); } + /** + * Retrieve the Most Disliked Waifus of the Current Season + * + * @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> getTrashWaifus() throws APIMapperException, APIResponseException { return APIWrapper.getTrashWaifus(); } - public Response getSeries(@NotNull String slug) throws APIMapperException, APIResponseException { + /** + * Retrieve detailed information about a given {@link Series} specified by the given slug + * + * @param slug The slug of the {@link Series} + * @return {@link Response} of {@link Series} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * @see #getSeries(Integer) + * + */ + private Response getSeries(@NotNull String slug) throws APIMapperException, APIResponseException { return APIWrapper.getSeries(slug); } + /** + * Retrieve detailed information about a given {@link Series} specified by the given id + * + * @param id The id of the {@link Series} + * @return {@link Response} of {@link Series} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * @see #getSeries(String) + * + */ public Response getSeries(@NotNull Integer id) throws APIMapperException, APIResponseException { return APIWrapper.getSeries(String.valueOf(id)); } + /** + * Retrieve paginated information about a Series + * + * @param pageNum The page number of the gallery + * @return {@link Response} of {@link PaginationData} with {@link FilteredSeries} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ public Response> getSeriesByPage(@NotNull Integer pageNum) throws APIMapperException, APIResponseException { return APIWrapper.getSeriesByPage(String.valueOf(pageNum)); } + /** + * Retrieve the List of Anime that Aired in a given Season and Year + * + * @param season The specified season from {@link Season} + * @param year The specified year + * @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 + * + */ public Response> getAllSeries(@NotNull Season season, @NotNull Integer year) throws APIResponseException, APIMapperException { return APIWrapper.getAllSeries(season, year); } + /** + * Retrieve a set of Waifus for a given {@link Series} specified by the given slug + * + * @param slug The slug of the {@link Series} + * @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 + * @see #getSeriesWaifus(Integer) + * + */ public Response> getSeriesWaifus(@NotNull String slug) throws APIMapperException, APIResponseException { return APIWrapper.getSeriesWaifus(slug); } + /** + * Retrieve a set of Waifus for a given {@link Series} specified by the given id + * + * @param id The id of the {@link Series} + * @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 + * @see #getSeriesWaifus(String) + * + */ public Response> getSeriesWaifus(@NotNull Integer id) throws APIMapperException, APIResponseException { return APIWrapper.getSeriesWaifus(String.valueOf(id)); } + /** + * Retrieve information about the {@link User} + * + * @param id The id of the {@link User} + * @return {@link Response} of {@link User} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ public Response getUserProfile(@NotNull Integer id) throws APIMapperException, APIResponseException { return APIWrapper.getUserProfile(String.valueOf(id)); } + /** + * Retrieve the Waifus Created, Liked, or Trashed for the given {@link User} id + * + * @param id The id of the {@link User} + * @param waifuListType The specified action E.g {@link WaifuListType#LIKED} + * @param pageNum The page number of the gallery + * @return {@link Response} of {@link PaginationData} 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> getUserWaifus(@NotNull Integer id, @NotNull WaifuListType waifuListType, @NotNull Integer pageNum) throws APIMapperException, APIResponseException { return APIWrapper.getUserWaifus(String.valueOf(id), waifuListType.getListType(), String.valueOf(pageNum)); } + + /** + * Retrieve a List of all {@link UserList}'s shown + * + * @param id The id of the {@link User} + * @return {@link Response} of {@link List} with {@link UserList} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ public Response> getUserLists(@NotNull Integer id) throws APIMapperException, APIResponseException { return APIWrapper.getUserLists(String.valueOf(id)); } + /** + * Retrieve the Specific {@link UserList}, with {@link Waifu}'s + * + * @param userId The id of the {@link User} + * @param listId The id of the {@link UserList} + * @return {@link Response} of {@link UserList} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ public Response getUserList(@NotNull Integer userId, @NotNull Integer listId) throws APIMapperException, APIResponseException { return APIWrapper.getUserList(String.valueOf(userId), String.valueOf(listId)); } From bdec13b2b492f1f3b736047b4780fcf970bbf923 Mon Sep 17 00:00:00 2001 From: fossabot Date: Sat, 12 Jun 2021 19:19:44 -0700 Subject: [PATCH 09/16] Add license scan report and status Signed off by: fossabot --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2730d07..d026bb1 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@

    An Asynchronous Java API Wrapper for MyWaifuList

    # Summary +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_shield) + This is an Asynchronous API Wrapper for [MyWaifuList](https://mywaifulist.moe/dash) @@ -33,3 +35,7 @@ TODO TODO + + +## License +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_large) \ No newline at end of file From 98c29543795e841fbadc82ac3032046b17973c99 Mon Sep 17 00:00:00 2001 From: Hamothy <58985301+sgoudham@users.noreply.github.com> Date: Sun, 13 Jun 2021 03:29:23 +0100 Subject: [PATCH 10/16] Update README.md --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d026bb1..0dcf7f9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ [codecov]: https://codecov.io/gh/sgoudham/MyWaifuWrapper/branch/release/graph/badge.svg?token=RxUDnCWnF0 [issues]: https://img.shields.io/github/issues/sgoudham/MyWaifuWrapper?label=issues [pull-requests]: https://img.shields.io/github/issues-pr/sgoudham/MyWaifuWrapper +[fossa]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=shield +[![fossa]](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_shield) ![license] ![maven-central] ![build-status] @@ -16,7 +18,6 @@

    An Asynchronous Java API Wrapper for MyWaifuList

    # Summary -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_shield) This is an Asynchronous API Wrapper for [MyWaifuList](https://mywaifulist.moe/dash) @@ -34,8 +35,5 @@ TODO TODO - - - ## License -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_large) \ No newline at end of file +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_large) From d8898a4987f2f6bf69a5aa3dc9dfd47ab0b37891 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 03:50:02 +0100 Subject: [PATCH 11/16] Update README.md --- README.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0dcf7f9..46634ac 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,40 @@ # Summary - This is an Asynchronous API Wrapper for [MyWaifuList](https://mywaifulist.moe/dash) # Disclaimer Given that MyWaifuList is a primarily user-driven website and this API is currently in an Alpha state, -the data returned may not be fully complete and at its best quality +the data returned **may not be** fully complete and at its best quality # Download -TODO +Latest Stable Version: ![Maven Central](https://img.shields.io/maven-central/v/me.goudham/MyWaifuWrapper) +

    Be sure to replace the **VERSION** key below with the one of the versions shown above!

    + +**Maven** +```xml + + + me.goudham + MyWaifuWrapper + VERSION + + +``` + +**Gradle** +```gradle +repositories { + mavenCentral() +} + +dependencies { + // https://mvnrepository.com/artifact/me.goudham/MyWaifuWrapper + implementation group: 'me.goudham', name: 'MyWaifuWrapper', version: 'VERSION' +} +``` # Usage From 374c11fb8bd521c4cf98c015ba04fe91ce3b0c9d Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 04:10:47 +0100 Subject: [PATCH 12/16] Update README.md --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 46634ac..5df0130 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,52 @@ This is an Asynchronous API Wrapper for [MyWaifuList](https://mywaifulist.moe/da Given that MyWaifuList is a primarily user-driven website and this API is currently in an Alpha state, the data returned **may not be** fully complete and at its best quality +# Configuration + +## Creating The MyWaifuClient + +There are 2 ways to create the [MyWaifuClient](https://github.com/sgoudham/MyWaifuWrapper/blob/main/src/main/java/me/goudham/MyWaifuClient.java) ++ `createDefault(apiKey)` ++ `build()` + +### createDefault() + +`createDefault(apiKey)` will provide a default implementation and return a MyWaifuClient ready to be used. + +```java +public class Main { + private static void main(String[] args) { + MyWaifuClient myWaifuClient = MyWaifuClient.createDefault("apiKey"); + } +} +``` + +### build() + +`build()` is used to build the object from the ground up, allowing for the fine-tuning of properties within the +MyWaifuClient + +```java +import me.goudham.MyWaifuClient; + +import java.net.http.HttpClient; +import java.time.Duration; + +public class Main { + private static void main(String[] args) { + // Creating MyWaifuClient through Builder + MyWaifuClient myWaifuClient = new MyWaifuClient.Builder("apiKey") + .withVersion(HttpClient.Version.HTTP_2) + .withConnectTimeout(Duration.ofMinutes(10)) + .build(); + } +} +``` + +# Usage + +TODO + # Download Latest Stable Version: ![Maven Central](https://img.shields.io/maven-central/v/me.goudham/MyWaifuWrapper) @@ -54,9 +100,5 @@ dependencies { } ``` -# Usage - -TODO - ## License [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_large) From dc58ef428260514b46f19562a607ea9689adbde5 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 04:11:34 +0100 Subject: [PATCH 13/16] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5df0130..e05dbd2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [pull-requests]: https://img.shields.io/github/issues-pr/sgoudham/MyWaifuWrapper [fossa]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper.svg?type=shield -[![fossa]](https://app.fossa.com/projects/git%2Bgithub.com%2Fsgoudham%2FMyWaifuWrapper?ref=badge_shield) +![fossa] ![license] ![maven-central] ![build-status] @@ -74,7 +74,7 @@ TODO # Download -Latest Stable Version: ![Maven Central](https://img.shields.io/maven-central/v/me.goudham/MyWaifuWrapper) +Latest Stable Version: ![maven-central]

    Be sure to replace the **VERSION** key below with the one of the versions shown above!

    **Maven** From 5a2d0650211ff1e62bd89dd2bc9f7cd4e0efc9af Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 04:16:35 +0100 Subject: [PATCH 14/16] Update README.md --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e05dbd2..615cabc 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ There are 2 ways to create the [MyWaifuClient](https://github.com/sgoudham/MyWai ### createDefault() -`createDefault(apiKey)` will provide a default implementation and return a MyWaifuClient ready to be used. +`createDefault(apiKey)` will provide a default implementation and return a MyWaifuClient ready to be used. Only +the `apiKey` is required to instantiate MyWaifuClient. ```java public class Main { @@ -49,7 +50,8 @@ public class Main { ### build() `build()` is used to build the object from the ground up, allowing for the fine-tuning of properties within the -MyWaifuClient +MyWaifuClient. Not all the additional properties need to specified within the builder but the bare minimum would be +the `apiKey` within the Builder constructor and then `.build()` ```java import me.goudham.MyWaifuClient; @@ -59,6 +61,9 @@ import java.time.Duration; public class Main { private static void main(String[] args) { + // Bare Minimum (Would recommend using createDefault()) + MyWaifuClient myWaifuClient = new MyWaifuClient.Builder("apiKey").build(); + // Creating MyWaifuClient through Builder MyWaifuClient myWaifuClient = new MyWaifuClient.Builder("apiKey") .withVersion(HttpClient.Version.HTTP_2) From c068d6ab27a1ca45fe069bbc85b06c98a481f9fc Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 04:47:37 +0100 Subject: [PATCH 15/16] Update documentation --- src/main/java/me/goudham/APIWrapper.java | 154 +++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/src/main/java/me/goudham/APIWrapper.java b/src/main/java/me/goudham/APIWrapper.java index 56c5ad3..a7fca8a 100644 --- a/src/main/java/me/goudham/APIWrapper.java +++ b/src/main/java/me/goudham/APIWrapper.java @@ -11,6 +11,7 @@ import me.goudham.domain.waifu.WaifuImage; import me.goudham.exception.APIMapperException; import me.goudham.exception.APIResponseException; import me.goudham.util.Season; +import me.goudham.util.WaifuListType; import java.io.IOException; import java.net.URI; @@ -91,86 +92,239 @@ public class APIWrapper { } } + /** + * Retrieve detailed information about the {@link Waifu} by sending request to API + * + * @param waifuId The id of the {@link Waifu} + * @return {@link Response} of {@link Waifu} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response getWaifu(String waifuId) throws APIResponseException, APIMapperException { Result waifuResult = sendRequest("waifu/" + waifuId); return apiMapper.deserialize(waifuResult, Waifu.class); } + /** + * Retrieve paginated images from the gallery, in sets of 10, by sending request to API + * + * @param waifuId The id of the {@link Waifu} + * @param pageNum The page number of the gallery + * @return {@link Response} of {@link WaifuImage} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response> getWaifuImages(String waifuId, String pageNum) throws APIResponseException, APIMapperException { Result waifuImagesResult = sendRequest("waifu/" + waifuId + "/images?page=" + pageNum); return apiMapper.deserializeToPaginationData(waifuImagesResult, paginationData(WaifuImage.class)); } + /** + * Retrieve an array of {@link FilteredWaifu}'s, sorted alphabetically, by sending request to API + * + * @param pageNum The page number of the gallery + * @return {@link Response} of {@link PaginationData} 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> getWaifusByPage(String pageNum) throws APIResponseException, APIMapperException { Result waifusByPageResult = sendRequest("waifu?page=" + pageNum); return apiMapper.deserializeToPaginationData(waifusByPageResult, paginationData(FilteredWaifu.class)); } + /** + * Retrieve the Waifu of the Day by sending request to API + * + * @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 getDailyWaifu() throws APIResponseException, APIMapperException { Result dailyWaifuResult = sendRequest("meta/daily"); return apiMapper.deserialize(dailyWaifuResult, FilteredWaifu.class); } + /** + * Retrieve a Random Waifu from the Website by sending request to API + * + * @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 getRandomWaifu() throws APIResponseException, APIMapperException { Result randomWaifuResult = sendRequest("meta/random"); return apiMapper.deserialize(randomWaifuResult, FilteredWaifu.class); } + /** + * Retrieve a List of Currently Airing Anim by sending request to API + * + * @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 + * + */ Response> getSeasonalAnime() throws APIResponseException, APIMapperException { Result seasonalAnimeResult = sendRequest("airing"); return apiMapper.deserializeToList(seasonalAnimeResult, listOf(FilteredSeries.class)); } + /** + * Retrieve the Best Waifus of the Current Season by sending request to API + * + * @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> getBestWaifus() throws APIResponseException, APIMapperException { Result waifuResults = sendRequest("airing/best"); return apiMapper.deserializeToList(waifuResults, listOf(FilteredWaifu.class)); } + /** + * Retrieve a List of Popular Waifus (Raw Count of Total Votes) of the Current Season + * by sending request to API + * + * @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> getPopularWaifus() throws APIResponseException, APIMapperException { Result waifuResults = sendRequest("airing/popular"); return apiMapper.deserializeToList(waifuResults, listOf(FilteredWaifu.class)); } + /** + * Retrieve the Most Disliked Waifus of the Current Season by sending request to API + * + * @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> getTrashWaifus() throws APIResponseException, APIMapperException { Result waifuResults = sendRequest("airing/trash"); return apiMapper.deserializeToList(waifuResults, listOf(FilteredWaifu.class)); } + /** + * Retrieve detailed information about a given {@link Series} by sending request to API + * + * @param seriesId The id of the {@link Series} + * @return {@link Response} of {@link Series} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response getSeries(String seriesId) throws APIResponseException, APIMapperException { Result seriesResult = sendRequest("series/" + seriesId); return apiMapper.deserialize(seriesResult, Series.class); } + /** + * Retrieve paginated information about a Series by sending request to API + * + * @param pageNum The page number of the gallery + * @return {@link Response} of {@link PaginationData} with {@link FilteredSeries} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response> getSeriesByPage(String pageNum) throws APIResponseException, APIMapperException { Result seriesPageResult = sendRequest("series?page=" + pageNum); return apiMapper.deserializeToPaginationData(seriesPageResult, paginationData(FilteredSeries.class)); } + /** + * Retrieve the List of Anime that Aired in a given Season and Year by sending request to API + * + * @param season The specified season from {@link Season} + * @param year The specified year + * @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 + * + */ Response> getAllSeries(Season season, Integer year) throws APIResponseException, APIMapperException { Result allSeriesResult = sendRequest("airing/" + season.getSeason() + "/" + year); return apiMapper.deserializeToList(allSeriesResult, listOf(FilteredSeries.class)); } + /** + * Retrieve a set of Waifus for a given {@link Series} by sending request to API + * + * @param seriesId The id of the {@link Series} + * @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> getSeriesWaifus(String seriesId) throws APIResponseException, APIMapperException { Result allWaifusFromSeriesResults = sendRequest("series/" + seriesId + "/waifus"); return apiMapper.deserializeToList(allWaifusFromSeriesResults, listOf(FilteredWaifu.class)); } + /** + * Retrieve information about the {@link User} by sending request to API + * + * @param userId The id of the {@link User} + * @return {@link Response} of {@link User} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response getUserProfile(String userId) throws APIResponseException, APIMapperException { Result userProfileResult = sendRequest("user/" + userId); return apiMapper.deserialize(userProfileResult, User.class); } + /** + * Retrieve the Waifus Created, Liked, or Trashed for the given {@link User} id by sending request to API + * + * @param userId The id of the {@link User} + * @param listType The specified action E.g {@link WaifuListType#LIKED} + * @param pageNum The page number of the gallery + * @return {@link Response} of {@link PaginationData} 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> getUserWaifus(String userId, String listType, String pageNum) throws APIResponseException, APIMapperException { Result userWaifusResult = sendRequest("user/" + userId + "/" + listType + "?page=" + pageNum); return apiMapper.deserializeToPaginationData(userWaifusResult, paginationData(FilteredWaifu.class)); } + /** + * Retrieve a List of all {@link UserList}'s shown by sending request to API + * + * @param userId The id of the {@link User} + * @return {@link Response} of {@link List} with {@link UserList} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response> getUserLists(String userId) throws APIResponseException, APIMapperException { Result userProfileResult = sendRequest("user/" + userId + "/lists"); return apiMapper.deserializeToList(userProfileResult, listOf(UserList.class)); } + /** + * Retrieve the Specific {@link UserList}, with {@link Waifu}'s by sending request to API + * + * @param userId The id of the {@link User} + * @param listId The id of the {@link UserList} + * @return {@link Response} of {@link UserList} + * @throws APIResponseException If {@link APIWrapper} could not return information properly + * @throws APIMapperException If {@link APIMapper} could not correctly {@code deserialize} model + * + */ Response getUserList(String userId, String listId) throws APIResponseException, APIMapperException { Result userProfileResult = sendRequest("user/" + userId + "/lists/" + listId); return apiMapper.deserialize(userProfileResult, UserList.class); From 7c8905afde785c5452982210d0ff7bd2a67730d8 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 13 Jun 2021 04:54:09 +0100 Subject: [PATCH 16/16] Increment version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c323e5..b61a18a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.goudham MyWaifuWrapper - 0.1.1 + 0.2.0 jar MyWaifuWrapper