Skip to content

Commit 07578cd

Browse files
authored
Merge pull request #38 from Global-Tags/development
fix: Include gift expiration date in return value of ApiHandler#redeemGiftCode
2 parents f7983b9 + 4979389 commit 07578cd

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

src/main/java/com/rappytv/globaltags/wrapper/http/ApiHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,21 +690,21 @@ public void createGiftCode(@NotNull String name, @NotNull String role, int maxUs
690690
* @param code The gift code to redeem
691691
* @param consumer The action to be executed on response.
692692
*/
693-
public void redeemGiftCode(@NotNull String code, @NotNull Consumer<ApiResponse<String>> consumer) {
693+
public void redeemGiftCode(@NotNull String code, @NotNull Consumer<ApiResponse<GiftCodeRedeemSchema>> consumer) {
694694
Objects.requireNonNull(code);
695695
Objects.requireNonNull(consumer);
696696
new ApiRequest<>(
697697
this.api,
698698
"POST",
699699
Routes.redeemGiftCode(code),
700700
emptyBody,
701-
MessageSchema.class
701+
GiftCodeRedeemSchema.class
702702
).sendRequestAsync((response) -> {
703703
if (!response.isSuccessful()) {
704704
consumer.accept(new ApiResponse<>(false, null, response.getError()));
705705
return;
706706
}
707-
consumer.accept(new ApiResponse<>(true, response.getData().message, null));
707+
consumer.accept(new ApiResponse<>(true, response.getData(), null));
708708
});
709709
}
710710

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.rappytv.globaltags.wrapper.http.schemas;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import org.jetbrains.annotations.NotNull;
5+
6+
import java.util.Date;
7+
8+
public class GiftCodeRedeemSchema extends MessageSchema {
9+
10+
@SerializedName("expires_at")
11+
private final Date expiresAt;
12+
13+
/**
14+
* @param expiresAt When the gift expires
15+
*/
16+
public GiftCodeRedeemSchema(@NotNull Date expiresAt) {
17+
this.expiresAt = expiresAt;
18+
}
19+
20+
/**
21+
* @return the gift expiration date
22+
*/
23+
@NotNull
24+
public Date getCode() {
25+
return this.expiresAt;
26+
}
27+
28+
@Override
29+
public String toString() {
30+
return "GiftCodeRedeemSchema{" +
31+
"expiresAt=" + this.expiresAt +
32+
'}';
33+
}
34+
}

0 commit comments

Comments
 (0)