Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for App Store Server API v1.13 and App Store Server Notif… #116

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

Expand All @@ -32,6 +34,7 @@ public class JWSRenewalInfoDecodedPayload implements DecodedSignedData {
private static final String SERIALIZED_NAME_RENEWAL_PRICE = "renewalPrice";
private static final String SERIALIZED_NAME_CURRENCY = "currency";
private static final String SERIALIZED_NAME_OFFER_DISCOUNT_TYPE = "offerDiscountType";
private static final String SERIALIZED_NAME_ELIGIBLE_WIN_BACK_OFFER_IDS = "eligibleWinBackOfferIds";
@JsonProperty(SERIALIZED_NAME_EXPIRATION_INTENT)
private Integer expirationIntent;
@JsonProperty(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID)
Expand Down Expand Up @@ -70,6 +73,8 @@ public class JWSRenewalInfoDecodedPayload implements DecodedSignedData {
private String currency;
@JsonProperty(SERIALIZED_NAME_OFFER_DISCOUNT_TYPE)
private String offerDiscountType;
@JsonProperty(SERIALIZED_NAME_ELIGIBLE_WIN_BACK_OFFER_IDS)
private List<String> eligibleWinBackOfferIds = null;
@JsonAnySetter
private Map<String, Object> unknownFields;

Expand Down Expand Up @@ -466,6 +471,34 @@ public void setRawOfferDiscountType(String rawOfferDiscountType) {
this.offerDiscountType = rawOfferDiscountType;
}

public JWSRenewalInfoDecodedPayload eligibleWinBackOfferIds(List<String> eligibleWinBackOfferIds) {
this.eligibleWinBackOfferIds = eligibleWinBackOfferIds;
return this;
}

public JWSRenewalInfoDecodedPayload addEligibleWinBackOfferId(String eligibleWinBackOfferId) {
if (this.eligibleWinBackOfferIds == null) {
this.eligibleWinBackOfferIds = new ArrayList<>();
}
this.eligibleWinBackOfferIds.add(eligibleWinBackOfferId);
return this;
}

/**
* An array of win-back offer identifiers that a customer is eligible to redeem, which sorts the identifiers to present the better offers first.
*
* @return eligibleWinBackOfferIds
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/eligiblewinbackofferids">eligibleWinBackOfferIds</a>
**/
public List<String> getEligibleWinBackOfferIds() {
return eligibleWinBackOfferIds;
}

public void setEligibleWinBackOfferIds(List<String> eligibleWinBackOfferIds) {
this.eligibleWinBackOfferIds = eligibleWinBackOfferIds;
}


public JWSRenewalInfoDecodedPayload unknownFields(Map<String, Object> unknownFields) {
this.unknownFields = unknownFields;
return this;
Expand Down Expand Up @@ -510,12 +543,13 @@ public boolean equals(Object o) {
Objects.equals(this.renewalPrice, jwSRenewalInfoDecodedPayload.renewalPrice) &&
Objects.equals(this.currency, jwSRenewalInfoDecodedPayload.currency) &&
Objects.equals(this.offerDiscountType, jwSRenewalInfoDecodedPayload.offerDiscountType) &&
Objects.equals(this.eligibleWinBackOfferIds, jwSRenewalInfoDecodedPayload.eligibleWinBackOfferIds) &&
Objects.equals(this.unknownFields, jwSRenewalInfoDecodedPayload.unknownFields);
}

@Override
public int hashCode() {
return Objects.hash(expirationIntent, originalTransactionId, autoRenewProductId, productId, autoRenewStatus, isInBillingRetryPeriod, priceIncreaseStatus, gracePeriodExpiresDate, offerType, offerIdentifier, signedDate, environment, recentSubscriptionStartDate, renewalDate, renewalPrice, currency, offerDiscountType, unknownFields);
return Objects.hash(expirationIntent, originalTransactionId, autoRenewProductId, productId, autoRenewStatus, isInBillingRetryPeriod, priceIncreaseStatus, gracePeriodExpiresDate, offerType, offerIdentifier, signedDate, environment, recentSubscriptionStartDate, renewalDate, renewalPrice, currency, offerDiscountType, eligibleWinBackOfferIds, unknownFields);
}

@Override
Expand All @@ -538,6 +572,7 @@ public String toString() {
", renewalPrice=" + renewalPrice +
", currency='" + currency + '\'' +
", offerDiscountType='" + offerDiscountType + '\'' +
", eligibleWinBackOfferIds=" + eligibleWinBackOfferIds +
", unknownFields=" + unknownFields +
'}';
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/apple/itunes/storekit/model/OfferType.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum OfferType {

INTRODUCTORY_OFFER(1),
PROMOTIONAL_OFFER(2),
SUBSCRIPTION_OFFER_CODE(3);
SUBSCRIPTION_OFFER_CODE(3),
WIN_BACK_OFFER(4);

private final Integer value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

public class JWSRenewalInfoDecodedPayloadTest {

Expand Down Expand Up @@ -42,5 +43,6 @@ public void testRenewalInfoDecoding() throws IOException, NoSuchAlgorithmExcepti
Assertions.assertEquals("USD", renewalInfo.getCurrency());
Assertions.assertEquals(OfferDiscountType.PAY_AS_YOU_GO, renewalInfo.getOfferDiscountType());
Assertions.assertEquals("PAY_AS_YOU_GO", renewalInfo.getRawOfferDiscountType());
Assertions.assertEquals(List.of("eligible1", "eligible2"), renewalInfo.getEligibleWinBackOfferIds());
}
}
8 changes: 6 additions & 2 deletions src/test/resources/models/signedRenewalInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"renewalDate": 1698148850000,
"renewalPrice": 9990,
"currency": "USD",
"offerDiscountType": "PAY_AS_YOU_GO"
}
"offerDiscountType": "PAY_AS_YOU_GO",
"eligibleWinBackOfferIds": [
"eligible1",
"eligible2"
]
}
Loading