Merge pull request #11 from sgoudham/main

All GET Requests are supported & Documentation Updated
release
Hamothy 3 years ago committed by GitHub
commit 3063771456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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]
![license]
![maven-central]
![build-status]
@ -22,14 +24,86 @@ This is an Asynchronous API Wrapper for [MyWaifuList](https://mywaifulist.moe/da
# 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
# Configuration
TODO
## 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. Only
the `apiKey` is required to instantiate MyWaifuClient.
```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. 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;
# Usage
import java.net.http.HttpClient;
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)
.withConnectTimeout(Duration.ofMinutes(10))
.build();
}
}
```
# Usage
TODO
# Download
Latest Stable Version: ![maven-central]
<p>Be sure to replace the **VERSION** key below with the one of the versions shown above!</p>
**Maven**
```xml
<!-- https://mvnrepository.com/artifact/me.goudham/MyWaifuWrapper -->
<dependency>
<groupId>me.goudham</groupId>
<artifactId>MyWaifuWrapper</artifactId>
<version>VERSION</version>
</dependency>
```
**Gradle**
```gradle
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/me.goudham/MyWaifuWrapper
implementation group: 'me.goudham', name: 'MyWaifuWrapper', version: 'VERSION'
}
```
## 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)

@ -6,7 +6,7 @@
<groupId>me.goudham</groupId>
<artifactId>MyWaifuWrapper</artifactId>
<version>0.1.1</version>
<version>0.2.0</version>
<packaging>jar</packaging>
<name>MyWaifuWrapper</name>
@ -150,7 +150,7 @@
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>

@ -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,76 +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<Waifu> 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<PaginationData<WaifuImage>> 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<PaginationData<FilteredWaifu>> 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<FilteredWaifu> 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<FilteredWaifu> 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<List<FilteredSeries>> 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<List<FilteredWaifu>> getBestWaifus() throws APIResponseException, APIMapperException {
Result waifuResults = sendRequest("airing/best");
return apiMapper.deserializeToList(waifuResults, listOf(FilteredWaifu.class));
}
/**
* Retrieve a List of Popular Waifus <i>(Raw Count of Total Votes)</i> 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<List<FilteredWaifu>> 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<List<FilteredWaifu>> 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<Series> 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<PaginationData<FilteredSeries>> 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<List<FilteredSeries>> 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<List<FilteredWaifu>> 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<User> 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<PaginationData<FilteredWaifu>> 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<List<UserList>> 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<UserList> getUserList(String userId, String listId) throws APIResponseException, APIMapperException {
Result userProfileResult = sendRequest("user/" + userId + "/lists/" + listId);
return apiMapper.deserialize(userProfileResult, UserList.class);

@ -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;
@ -28,6 +29,7 @@ import java.util.concurrent.Executor;
*
* <p> Main entry point for retrieving information from MyWaifuList.</p>
* <p> {@link APIWrapper} is utilised to make the API requests </p>
*
*/
public class MyWaifuClient {
private final APIWrapper APIWrapper;
@ -49,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()
@ -61,91 +64,266 @@ 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<Waifu> getWaifu(@NotNull String slug) throws APIResponseException, APIMapperException {
private Response<Waifu> 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<Waifu> getWaifu(@NotNull Integer id) throws APIResponseException, APIMapperException {
return APIWrapper.getWaifu(String.valueOf(id));
}
/**
* 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} 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<PaginationData<WaifuImage>> 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<PaginationData<FilteredWaifu>> 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<FilteredWaifu> 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<FilteredWaifu> 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<List<FilteredSeries>> 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<List<FilteredWaifu>> getBestWaifus() throws APIMapperException, APIResponseException {
return APIWrapper.getBestWaifus();
}
/**
* Retrieve a List of Popular Waifus <i>(Raw Count of Total Votes)</i> 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<List<FilteredWaifu>> 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<List<FilteredWaifu>> getTrashWaifus() throws APIMapperException, APIResponseException {
return APIWrapper.getTrashWaifus();
}
public Response<Series> 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<Series> 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<Series> 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<PaginationData<FilteredSeries>> 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<List<FilteredSeries>> 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<List<FilteredWaifu>> 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<List<FilteredWaifu>> 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<User> 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<PaginationData<FilteredWaifu>> 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<List<UserList>> 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<UserList> getUserList(@NotNull Integer userId, @NotNull Integer listId) throws APIMapperException, APIResponseException {
return APIWrapper.getUserList(String.valueOf(userId), String.valueOf(listId));
}

@ -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<T> {
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 + '\'' +
'}';
}
}

@ -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 + '\'' +
'}';
}
}

@ -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<T> {
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 +
'}';
}
}

@ -20,6 +20,7 @@ import java.util.Objects;
* <li>{@link String romaji}</li>
* <li>{@link String romajiName}</li>
* <li>{@link String displayPicture}</li>
* <li>{@link String description}</li>
* <li>{@link Integer likes}</li>
* <li>{@link Integer trash}</li>
* <li>{@link String type}</li>

@ -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;
}
}
Loading…
Cancel
Save