From 497938981409644e4d7baf43265cf6ae27590f85 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 23 Feb 2025 15:41:40 +0100 Subject: [PATCH] Include gift expiration date in return value of ApiHandler#redeemGiftCode --- .../globaltags/wrapper/http/ApiHandler.java | 6 ++-- .../http/schemas/GiftCodeRedeemSchema.java | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/rappytv/globaltags/wrapper/http/schemas/GiftCodeRedeemSchema.java diff --git a/src/main/java/com/rappytv/globaltags/wrapper/http/ApiHandler.java b/src/main/java/com/rappytv/globaltags/wrapper/http/ApiHandler.java index fe02b01..355174c 100644 --- a/src/main/java/com/rappytv/globaltags/wrapper/http/ApiHandler.java +++ b/src/main/java/com/rappytv/globaltags/wrapper/http/ApiHandler.java @@ -690,7 +690,7 @@ public void createGiftCode(@NotNull String name, @NotNull String role, int maxUs * @param code The gift code to redeem * @param consumer The action to be executed on response. */ - public void redeemGiftCode(@NotNull String code, @NotNull Consumer> consumer) { + public void redeemGiftCode(@NotNull String code, @NotNull Consumer> consumer) { Objects.requireNonNull(code); Objects.requireNonNull(consumer); new ApiRequest<>( @@ -698,13 +698,13 @@ public void redeemGiftCode(@NotNull String code, @NotNull Consumer { if (!response.isSuccessful()) { consumer.accept(new ApiResponse<>(false, null, response.getError())); return; } - consumer.accept(new ApiResponse<>(true, response.getData().message, null)); + consumer.accept(new ApiResponse<>(true, response.getData(), null)); }); } diff --git a/src/main/java/com/rappytv/globaltags/wrapper/http/schemas/GiftCodeRedeemSchema.java b/src/main/java/com/rappytv/globaltags/wrapper/http/schemas/GiftCodeRedeemSchema.java new file mode 100644 index 0000000..d583458 --- /dev/null +++ b/src/main/java/com/rappytv/globaltags/wrapper/http/schemas/GiftCodeRedeemSchema.java @@ -0,0 +1,34 @@ +package com.rappytv.globaltags.wrapper.http.schemas; + +import com.google.gson.annotations.SerializedName; +import org.jetbrains.annotations.NotNull; + +import java.util.Date; + +public class GiftCodeRedeemSchema extends MessageSchema { + + @SerializedName("expires_at") + private final Date expiresAt; + + /** + * @param expiresAt When the gift expires + */ + public GiftCodeRedeemSchema(@NotNull Date expiresAt) { + this.expiresAt = expiresAt; + } + + /** + * @return the gift expiration date + */ + @NotNull + public Date getCode() { + return this.expiresAt; + } + + @Override + public String toString() { + return "GiftCodeRedeemSchema{" + + "expiresAt=" + this.expiresAt + + '}'; + } +}