From 59508153edda514082efd2d4d97db55d4fad655e Mon Sep 17 00:00:00 2001 From: Hammy Date: Tue, 8 Jun 2021 02:57:38 +0100 Subject: [PATCH] Add new endpoint - getDailyWaifu() --- src/main/java/org/goudham/me/APIWrapper.java | 6 ++++++ src/main/java/org/goudham/me/MyWaifuClient.java | 5 +++++ .../org/goudham/me/api/entity/waifu/FilteredWaifu.java | 7 ++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/goudham/me/APIWrapper.java b/src/main/java/org/goudham/me/APIWrapper.java index 5d59f2a..648c7aa 100644 --- a/src/main/java/org/goudham/me/APIWrapper.java +++ b/src/main/java/org/goudham/me/APIWrapper.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.type.TypeFactory; import org.goudham.me.api.entity.series.FilteredSeries; import org.goudham.me.api.entity.series.Series; +import org.goudham.me.api.entity.waifu.FilteredWaifu; import org.goudham.me.api.entity.waifu.Waifu; import org.goudham.me.exception.APIMapperException; import org.goudham.me.exception.APIResponseException; @@ -95,6 +96,11 @@ public class APIWrapper { return apiMapper.deserialize(waifuResult, Waifu.class); } + Response getDailyWaifu() throws APIResponseException, APIMapperException { + Result waifuResult = sendRequest(httpClient, "meta/daily"); + return apiMapper.deserialize(waifuResult, FilteredWaifu.class); + } + Response getSeries(String param) throws APIResponseException, APIMapperException { Result seriesResult = sendRequest(httpClient, "series/" + param); return apiMapper.deserialize(seriesResult, Series.class); diff --git a/src/main/java/org/goudham/me/MyWaifuClient.java b/src/main/java/org/goudham/me/MyWaifuClient.java index 7aaabf4..2c5890f 100644 --- a/src/main/java/org/goudham/me/MyWaifuClient.java +++ b/src/main/java/org/goudham/me/MyWaifuClient.java @@ -2,6 +2,7 @@ package org.goudham.me; import org.goudham.me.api.entity.series.FilteredSeries; import org.goudham.me.api.entity.series.Series; +import org.goudham.me.api.entity.waifu.FilteredWaifu; import org.goudham.me.api.entity.waifu.Waifu; import org.goudham.me.exception.APIMapperException; import org.goudham.me.exception.APIResponseException; @@ -62,6 +63,10 @@ public class MyWaifuClient { return APIWrapper.getWaifu(String.valueOf(id)); } + public Response getDailyWaifu() throws APIResponseException, APIMapperException { + return APIWrapper.getDailyWaifu(); + } + public Response getSeries(@NotNull Integer id) throws APIMapperException, APIResponseException { return APIWrapper.getSeries(String.valueOf(id)); } diff --git a/src/main/java/org/goudham/me/api/entity/waifu/FilteredWaifu.java b/src/main/java/org/goudham/me/api/entity/waifu/FilteredWaifu.java index c12e091..52abbe1 100644 --- a/src/main/java/org/goudham/me/api/entity/waifu/FilteredWaifu.java +++ b/src/main/java/org/goudham/me/api/entity/waifu/FilteredWaifu.java @@ -1,16 +1,12 @@ package org.goudham.me.api.entity.waifu; +import com.fasterxml.jackson.annotation.*; import org.goudham.me.api.entity.series.FilteredSeries; import java.util.List; import java.util.Objects; import javax.annotation.processing.Generated; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyDescription; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - /** * Filtered Waifu @@ -52,6 +48,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; "id" }) @Generated("jsonschema2pojo") +@JsonIgnoreProperties(ignoreUnknown = true) public class FilteredWaifu { /** * Used to generate readable URL's for the {@link FilteredWaifu}