From cb93c45dcf973b60e1efda97ca63aa93b9393497 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 27 Oct 2023 15:52:24 -0700 Subject: [PATCH] Allow accessing new Enum values without requiring a library upgrade --- .../itunes/storekit/client/APIException.java | 13 +- .../client/AppStoreServerAPIClient.java | 23 ++- .../itunes/storekit/model/AppTransaction.java | 17 ++- .../storekit/model/ConsumptionRequest.java | 138 ++++++++++++++---- .../com/apple/itunes/storekit/model/Data.java | 34 ++++- .../storekit/model/HistoryResponse.java | 17 ++- .../model/JWSRenewalInfoDecodedPayload.java | 85 +++++++++-- .../model/JWSTransactionDecodedPayload.java | 102 ++++++++++--- .../storekit/model/LastTransactionsItem.java | 17 ++- .../storekit/model/OrderLookupResponse.java | 17 ++- .../model/ResponseBodyV2DecodedPayload.java | 34 ++++- .../storekit/model/SendAttemptItem.java | 17 ++- .../apple/itunes/storekit/model/Summary.java | 19 ++- 13 files changed, 430 insertions(+), 103 deletions(-) diff --git a/src/main/java/com/apple/itunes/storekit/client/APIException.java b/src/main/java/com/apple/itunes/storekit/client/APIException.java index 157e3c00..cb97f695 100644 --- a/src/main/java/com/apple/itunes/storekit/client/APIException.java +++ b/src/main/java/com/apple/itunes/storekit/client/APIException.java @@ -9,7 +9,7 @@ */ public class APIException extends Exception { private final int httpStatusCode; - private final APIError apiError; + private final Long apiError; public APIException(int httpStatusCode) { this.httpStatusCode = httpStatusCode; @@ -18,7 +18,12 @@ public APIException(int httpStatusCode) { public APIException(int httpStatusCode, APIError apiError) { this.httpStatusCode = httpStatusCode; - this.apiError = apiError; + this.apiError = apiError != null ? apiError.errorCode() : null; + } + + public APIException(int httpStatusCode, Long rawApiError) { + this.httpStatusCode = httpStatusCode; + this.apiError = rawApiError; } public int getHttpStatusCode() { @@ -26,6 +31,10 @@ public int getHttpStatusCode() { } public APIError getApiError() { + return apiError != null ? APIError.fetchErrorResponseFromErrorCode(apiError) : null; + } + + public Long getRawApiError() { return apiError; } diff --git a/src/main/java/com/apple/itunes/storekit/client/AppStoreServerAPIClient.java b/src/main/java/com/apple/itunes/storekit/client/AppStoreServerAPIClient.java index 1c01fc35..881c9b6a 100644 --- a/src/main/java/com/apple/itunes/storekit/client/AppStoreServerAPIClient.java +++ b/src/main/java/com/apple/itunes/storekit/client/AppStoreServerAPIClient.java @@ -58,15 +58,14 @@ public class AppStoreServerAPIClient { * @param environment The environment to target */ public AppStoreServerAPIClient(String signingKey, String keyId, String issuerId, String bundleId, Environment environment) { - BearerTokenAuthenticator bearerTokenAuthenticator = new BearerTokenAuthenticator(signingKey, keyId, issuerId, bundleId); - this.bearerTokenAuthenticator = bearerTokenAuthenticator; + this.bearerTokenAuthenticator = new BearerTokenAuthenticator(signingKey, keyId, issuerId, bundleId); OkHttpClient.Builder builder = new OkHttpClient.Builder(); this.httpClient = builder.build(); this.urlBase = HttpUrl.parse(environment.equals(Environment.SANDBOX) ? SANDBOX_URL : PRODUCTION_URL); this.gson = new Gson(); } - private Request buildRequest(String path, String method, Map> queryParameters, Object body) { + private Response makeRequest(String path, String method, Map> queryParameters, Object body) throws IOException { Request.Builder requestBuilder = new Request.Builder(); requestBuilder.addHeader("User-Agent", USER_AGENT); requestBuilder.addHeader("Authorization", "Bearer " + bearerTokenAuthenticator.generateToken()); @@ -86,13 +85,16 @@ private Request buildRequest(String path, String method, Map T makeHttpCall(String path, String method, Map> queryParameters, Object body, Class clazz) throws IOException, APIException { - Request request = buildRequest(path, method, queryParameters, body); + protected Response getResponse(Request request) throws IOException { Call call = httpClient.newCall(request); - try (Response r = call.execute()) { + return call.execute(); + } + + protected T makeHttpCall(String path, String method, Map> queryParameters, Object body, Class clazz) throws IOException, APIException { + try (Response r = makeRequest(path, method, queryParameters, body)) { if (r.code() >= 200 && r.code() < 300) { if (clazz.equals(Void.class)) { return null; @@ -109,10 +111,7 @@ private T makeHttpCall(String path, String method, Map> ResponseBody responseBody = r.body(); if (responseBody != null) { ErrorPayload errorPayload = gson.fromJson(responseBody.charStream(), ErrorPayload.class); - APIError apiError = APIError.fetchErrorResponseFromErrorCode(errorPayload.getErrorCode()); - if (apiError != null) { - throw new APIException(r.code(), apiError); - } + throw new APIException(r.code(), errorPayload.getErrorCode()); } } catch (APIException e) { throw e; @@ -137,7 +136,7 @@ private T makeHttpCall(String path, String method, Map> * @see Extend Subscription Renewal Dates for All Active Subscribers */ public MassExtendRenewalDateResponse extendRenewalDateForAllActiveSubscribers(MassExtendRenewalDateRequest massExtendRenewalDateRequest) throws APIException, IOException { - return makeHttpCall("/inApps/v1/subscriptions/extend/mass/", "POST", Map.of(), massExtendRenewalDateRequest, MassExtendRenewalDateResponse.class); + return makeHttpCall("/inApps/v1/subscriptions/extend/mass", "POST", Map.of(), massExtendRenewalDateRequest, MassExtendRenewalDateResponse.class); } /** diff --git a/src/main/java/com/apple/itunes/storekit/model/AppTransaction.java b/src/main/java/com/apple/itunes/storekit/model/AppTransaction.java index 003ed450..0af6c2aa 100644 --- a/src/main/java/com/apple/itunes/storekit/model/AppTransaction.java +++ b/src/main/java/com/apple/itunes/storekit/model/AppTransaction.java @@ -25,7 +25,7 @@ public class AppTransaction implements DecodedSignedData { private static final String SERIALIZED_NAME_PREORDER_DATE = "preorderDate"; @SerializedName(SERIALIZED_NAME_RECEIPT_TYPE) - private Environment receiptType; + private String receiptType; @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; @SerializedName(SERIALIZED_NAME_BUNDLE_ID) @@ -53,15 +53,26 @@ public class AppTransaction implements DecodedSignedData { @see environment */ public Environment getReceiptType() { + return this.receiptType != null ? Environment.fromValue(this.receiptType) : null; + } + + /** + * @see #getReceiptType() + */ + public String getRawReceiptType() { return this.receiptType; } public void setReceiptType(Environment receiptType) { - this.receiptType = receiptType; + this.receiptType = receiptType != null ? receiptType.getValue() : null; + } + + public void setRawReceiptType(String rawReceiptType) { + this.receiptType = rawReceiptType; } public AppTransaction receiptType(Environment receiptType) { - this.receiptType = receiptType; + this.receiptType = receiptType != null ? receiptType.getValue() : null; return this; } diff --git a/src/main/java/com/apple/itunes/storekit/model/ConsumptionRequest.java b/src/main/java/com/apple/itunes/storekit/model/ConsumptionRequest.java index 801fe037..0528b752 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ConsumptionRequest.java +++ b/src/main/java/com/apple/itunes/storekit/model/ConsumptionRequest.java @@ -27,25 +27,25 @@ public class ConsumptionRequest { @SerializedName(SERIALIZED_NAME_CUSTOMER_CONSENTED) private Boolean customerConsented; @SerializedName(SERIALIZED_NAME_CONSUMPTION_STATUS) - private ConsumptionStatus consumptionStatus; + private Integer consumptionStatus; @SerializedName(SERIALIZED_NAME_PLATFORM) - private Platform platform; + private Integer platform; @SerializedName(SERIALIZED_NAME_SAMPLE_CONTENT_PROVIDED) private Boolean sampleContentProvided; @SerializedName(SERIALIZED_NAME_DELIVERY_STATUS) - private DeliveryStatus deliveryStatus; + private Integer deliveryStatus; @SerializedName(SERIALIZED_NAME_APP_ACCOUNT_TOKEN) private UUID appAccountToken; @SerializedName(SERIALIZED_NAME_ACCOUNT_TENURE) - private AccountTenure accountTenure; + private Integer accountTenure; @SerializedName(SERIALIZED_NAME_PLAY_TIME) - private PlayTime playTime; + private Integer playTime; @SerializedName(SERIALIZED_NAME_LIFETIME_DOLLARS_REFUNDED) - private LifetimeDollarsRefunded lifetimeDollarsRefunded; + private Integer lifetimeDollarsRefunded; @SerializedName(SERIALIZED_NAME_LIFETIME_DOLLARS_PURCHASED) - private LifetimeDollarsPurchased lifetimeDollarsPurchased; + private Integer lifetimeDollarsPurchased; @SerializedName(SERIALIZED_NAME_USER_STATUS) - private UserStatus userStatus; + private Integer userStatus; public ConsumptionRequest() { @@ -71,7 +71,7 @@ public void setCustomerConsented(Boolean customerConsented) { } public ConsumptionRequest consumptionStatus(ConsumptionStatus consumptionStatus) { - this.consumptionStatus = consumptionStatus; + this.consumptionStatus = consumptionStatus != null ? consumptionStatus.getValue() : null; return this; } @@ -82,15 +82,26 @@ public ConsumptionRequest consumptionStatus(ConsumptionStatus consumptionStatus) * @see consumptionStatus **/ public ConsumptionStatus getConsumptionStatus() { + return consumptionStatus != null ? ConsumptionStatus.fromValue(consumptionStatus) : null; + } + + /** + * @see #getConsumptionStatus() + */ + public Integer getRawConsumptionStatus() { return consumptionStatus; } public void setConsumptionStatus(ConsumptionStatus consumptionStatus) { - this.consumptionStatus = consumptionStatus; + this.consumptionStatus = consumptionStatus != null ? consumptionStatus.getValue() : null; + } + + public void setRawConsumptionStatus(Integer rawConsumptionStatus) { + this.consumptionStatus = rawConsumptionStatus; } public ConsumptionRequest platform(Platform platform) { - this.platform = platform; + this.platform = platform != null ? platform.getValue() : null; return this; } @@ -101,11 +112,22 @@ public ConsumptionRequest platform(Platform platform) { * @see platform **/ public Platform getPlatform() { + return platform != null ? Platform.fromValue(platform) : null; + } + + /** + * @see #getPlatform() + */ + public Integer getRawPlatform() { return platform; } public void setPlatform(Platform platform) { - this.platform = platform; + this.platform = platform != null ? platform.getValue() : null; + } + + public void setRawPlatform(Integer rawPlatform) { + this.platform = rawPlatform; } public ConsumptionRequest sampleContentProvided(Boolean sampleContentProvided) { @@ -128,7 +150,7 @@ public void setSampleContentProvided(Boolean sampleContentProvided) { } public ConsumptionRequest deliveryStatus(DeliveryStatus deliveryStatus) { - this.deliveryStatus = deliveryStatus; + this.deliveryStatus = deliveryStatus != null ? deliveryStatus.getValue() : null; return this; } @@ -139,11 +161,22 @@ public ConsumptionRequest deliveryStatus(DeliveryStatus deliveryStatus) { * @see deliveryStatus **/ public DeliveryStatus getDeliveryStatus() { + return deliveryStatus != null ? DeliveryStatus.fromValue(deliveryStatus) : null; + } + + /** + * @see #getDeliveryStatus() + */ + public Integer getRawDeliveryStatus() { return deliveryStatus; } public void setDeliveryStatus(DeliveryStatus deliveryStatus) { - this.deliveryStatus = deliveryStatus; + this.deliveryStatus = deliveryStatus != null ? deliveryStatus.getValue() : null; + } + + public void setRawDeliveryStatus(Integer rawDeliveryStatus) { + this.deliveryStatus = rawDeliveryStatus; } public ConsumptionRequest appAccountToken(UUID appAccountToken) { @@ -166,7 +199,7 @@ public void setAppAccountToken(UUID appAccountToken) { } public ConsumptionRequest accountTenure(AccountTenure accountTenure) { - this.accountTenure = accountTenure; + this.accountTenure = accountTenure != null ? accountTenure.getValue() : null; return this; } @@ -177,15 +210,26 @@ public ConsumptionRequest accountTenure(AccountTenure accountTenure) { * @see accountTenure **/ public AccountTenure getAccountTenure() { + return accountTenure != null ? AccountTenure.fromValue(accountTenure) : null; + } + + /** + * @see #getAccountTenure() + */ + public Integer getRawAccountTenure() { return accountTenure; } public void setAccountTenure(AccountTenure accountTenure) { - this.accountTenure = accountTenure; + this.accountTenure = accountTenure != null ? accountTenure.getValue() : null; + } + + public void setRawAccountTenure(Integer rawAccountTenure) { + this.accountTenure = rawAccountTenure; } public ConsumptionRequest playTime(PlayTime playTime) { - this.playTime = playTime; + this.playTime = playTime != null ? playTime.getValue() : null; return this; } @@ -193,18 +237,29 @@ public ConsumptionRequest playTime(PlayTime playTime) { * A value that indicates the amount of time that the customer used the app. * * @return playTime - * @see ConsumptionRequest + * @see playTime **/ public PlayTime getPlayTime() { + return playTime != null ? PlayTime.fromValue(playTime) : null; + } + + /** + * @see #getPlayTime() + */ + public Integer getRawPlayTime() { return playTime; } public void setPlayTime(PlayTime playTime) { - this.playTime = playTime; + this.playTime = playTime != null ? playTime.getValue() : null; + } + + public void setRawPlayTime(Integer rawPlayTime) { + this.playTime = rawPlayTime; } public ConsumptionRequest lifetimeDollarsRefunded(LifetimeDollarsRefunded lifetimeDollarsRefunded) { - this.lifetimeDollarsRefunded = lifetimeDollarsRefunded; + this.lifetimeDollarsRefunded = lifetimeDollarsRefunded != null ? lifetimeDollarsRefunded.getValue() : null; return this; } @@ -215,15 +270,26 @@ public ConsumptionRequest lifetimeDollarsRefunded(LifetimeDollarsRefunded lifeti * @see lifetimeDollarsRefunded **/ public LifetimeDollarsRefunded getLifetimeDollarsRefunded() { + return lifetimeDollarsRefunded != null ? LifetimeDollarsRefunded.fromValue(lifetimeDollarsRefunded) : null; + } + + /** + * @see #getLifetimeDollarsRefunded() + */ + public Integer getRawLifetimeDollarsRefunded() { return lifetimeDollarsRefunded; } public void setLifetimeDollarsRefunded(LifetimeDollarsRefunded lifetimeDollarsRefunded) { - this.lifetimeDollarsRefunded = lifetimeDollarsRefunded; + this.lifetimeDollarsRefunded = lifetimeDollarsRefunded != null ? lifetimeDollarsRefunded.getValue() : null; + } + + public void setRawLifetimeDollarsRefunded(Integer rawLifetimeDollarsRefunded) { + this.lifetimeDollarsRefunded = rawLifetimeDollarsRefunded; } public ConsumptionRequest lifetimeDollarsPurchased(LifetimeDollarsPurchased lifetimeDollarsPurchased) { - this.lifetimeDollarsPurchased = lifetimeDollarsPurchased; + this.lifetimeDollarsPurchased = lifetimeDollarsPurchased != null ? lifetimeDollarsPurchased.getValue() : null; return this; } @@ -234,15 +300,26 @@ public ConsumptionRequest lifetimeDollarsPurchased(LifetimeDollarsPurchased life * @see lifetimeDollarsPurchased **/ public LifetimeDollarsPurchased getLifetimeDollarsPurchased() { + return lifetimeDollarsPurchased != null ? LifetimeDollarsPurchased.fromValue(lifetimeDollarsPurchased) : null; + } + + /** + * @see #getLifetimeDollarsPurchased() + */ + public Integer getRawLifetimeDollarsPurchased() { return lifetimeDollarsPurchased; } public void setLifetimeDollarsPurchased(LifetimeDollarsPurchased lifetimeDollarsPurchased) { - this.lifetimeDollarsPurchased = lifetimeDollarsPurchased; + this.lifetimeDollarsPurchased = lifetimeDollarsPurchased != null ? lifetimeDollarsPurchased.getValue() : null; + } + + public void setRawLifetimeDollarsPurchased(Integer rawLifetimeDollarsPurchased) { + this.lifetimeDollarsPurchased = rawLifetimeDollarsPurchased; } public ConsumptionRequest userStatus(UserStatus userStatus) { - this.userStatus = userStatus; + this.userStatus = userStatus != null ? userStatus.getValue() : null; return this; } @@ -253,11 +330,22 @@ public ConsumptionRequest userStatus(UserStatus userStatus) { * @see userStatus **/ public UserStatus getUserStatus() { + return userStatus != null ? UserStatus.fromValue(userStatus) : null; + } + + /** + * @see #getUserStatus() + */ + public Integer getRawUserStatus() { return userStatus; } public void setUserStatus(UserStatus userStatus) { - this.userStatus = userStatus; + this.userStatus = userStatus != null ? userStatus.getValue() : null; + } + + public void setRawUserStatus(Integer rawUserStatus) { + this.userStatus = rawUserStatus; } @Override diff --git a/src/main/java/com/apple/itunes/storekit/model/Data.java b/src/main/java/com/apple/itunes/storekit/model/Data.java index 2ca567b9..c04fcd4e 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Data.java +++ b/src/main/java/com/apple/itunes/storekit/model/Data.java @@ -20,7 +20,7 @@ public class Data { private static final String SERIALIZED_NAME_SIGNED_RENEWAL_INFO = "signedRenewalInfo"; private static final String SERIALIZED_NAME_STATUS = "status"; @SerializedName(SERIALIZED_NAME_ENVIRONMENT) - private Environment environment; + private String environment; @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; @SerializedName(SERIALIZED_NAME_BUNDLE_ID) @@ -32,14 +32,14 @@ public class Data { @SerializedName(SERIALIZED_NAME_SIGNED_RENEWAL_INFO) private String signedRenewalInfo; @SerializedName(SERIALIZED_NAME_STATUS) - private Status status; + private Integer status; public Data() { } public Data environment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; return this; } @@ -50,11 +50,22 @@ public Data environment(Environment environment) { * @see environment **/ public Environment getEnvironment() { + return environment != null ? Environment.fromValue(environment) : null; + } + + /** + * @see #getEnvironment() + */ + public String getRawEnvironment() { return environment; } public void setEnvironment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; + } + + public void setRawEnvironment(String rawEnvironment) { + this.environment = rawEnvironment; } public Data appAppleId(Long appAppleId) { @@ -153,7 +164,7 @@ public void setSignedRenewalInfo(String signedRenewalInfo) { } public Data status(Status status) { - this.status = status; + this.status = status != null ? status.getValue() : null; return this; } @@ -164,11 +175,22 @@ public Data status(Status status) { * @see status **/ public Status getStatus() { + return status != null ? Status.fromValue(status) : null; + } + + /** + * @see #getStatus() + */ + public Integer getRawStatus() { return status; } public void setStatus(Status status) { - this.status = status; + this.status = status != null ? status.getValue() : null; + } + + public void setRawStatus(Integer rawStatus) { + this.status = rawStatus; } @Override diff --git a/src/main/java/com/apple/itunes/storekit/model/HistoryResponse.java b/src/main/java/com/apple/itunes/storekit/model/HistoryResponse.java index 9e6b477a..0e0b7a53 100644 --- a/src/main/java/com/apple/itunes/storekit/model/HistoryResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/HistoryResponse.java @@ -29,7 +29,7 @@ public class HistoryResponse { @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; @SerializedName(SERIALIZED_NAME_ENVIRONMENT) - private Environment environment; + private String environment; @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTIONS) private List signedTransactions = null; @@ -114,7 +114,7 @@ public void setAppAppleId(Long appAppleId) { } public HistoryResponse environment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; return this; } @@ -125,11 +125,22 @@ public HistoryResponse environment(Environment environment) { * @see environment **/ public Environment getEnvironment() { + return environment != null ? Environment.fromValue(environment) : null; + } + + /** + * @see #getEnvironment() + */ + public String getRawEnvironment() { return environment; } public void setEnvironment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; + } + + public void setRawEnvironment(String rawEnvironment) { + this.environment = rawEnvironment; } public HistoryResponse signedTransactions(List signedTransactions) { diff --git a/src/main/java/com/apple/itunes/storekit/model/JWSRenewalInfoDecodedPayload.java b/src/main/java/com/apple/itunes/storekit/model/JWSRenewalInfoDecodedPayload.java index 1e77f2ab..e7efc0bc 100644 --- a/src/main/java/com/apple/itunes/storekit/model/JWSRenewalInfoDecodedPayload.java +++ b/src/main/java/com/apple/itunes/storekit/model/JWSRenewalInfoDecodedPayload.java @@ -27,7 +27,7 @@ public class JWSRenewalInfoDecodedPayload implements DecodedSignedData { private static final String SERIALIZED_NAME_RECENT_SUBSCRIPTION_START_DATE = "recentSubscriptionStartDate"; private static final String SERIALIZED_NAME_RENEWAL_DATE = "renewalDate"; @SerializedName(SERIALIZED_NAME_EXPIRATION_INTENT) - private ExpirationIntent expirationIntent; + private Integer expirationIntent; @SerializedName(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) private String originalTransactionId; @SerializedName(SERIALIZED_NAME_AUTO_RENEW_PRODUCT_ID) @@ -35,21 +35,21 @@ public class JWSRenewalInfoDecodedPayload implements DecodedSignedData { @SerializedName(SERIALIZED_NAME_PRODUCT_ID) private String productId; @SerializedName(SERIALIZED_NAME_AUTO_RENEW_STATUS) - private AutoRenewStatus autoRenewStatus; + private Integer autoRenewStatus; @SerializedName(SERIALIZED_NAME_IS_IN_BILLING_RETRY_PERIOD) private Boolean isInBillingRetryPeriod; @SerializedName(SERIALIZED_NAME_PRICE_INCREASE_STATUS) - private PriceIncreaseStatus priceIncreaseStatus; + private Integer priceIncreaseStatus; @SerializedName(SERIALIZED_NAME_GRACE_PERIOD_EXPIRES_DATE) private Long gracePeriodExpiresDate; @SerializedName(SERIALIZED_NAME_OFFER_TYPE) - private OfferType offerType; + private Integer offerType; @SerializedName(SERIALIZED_NAME_OFFER_IDENTIFIER) private String offerIdentifier; @SerializedName(SERIALIZED_NAME_SIGNED_DATE) private Long signedDate; @SerializedName(SERIALIZED_NAME_ENVIRONMENT) - private Environment environment; + private String environment; @SerializedName(SERIALIZED_NAME_RECENT_SUBSCRIPTION_START_DATE) private Long recentSubscriptionStartDate; @SerializedName(SERIALIZED_NAME_RENEWAL_DATE) @@ -60,7 +60,7 @@ public JWSRenewalInfoDecodedPayload() { } public JWSRenewalInfoDecodedPayload expirationIntent(ExpirationIntent expirationIntent) { - this.expirationIntent = expirationIntent; + this.expirationIntent = expirationIntent != null ? expirationIntent.getValue() : null; return this; } @@ -71,11 +71,22 @@ public JWSRenewalInfoDecodedPayload expirationIntent(ExpirationIntent expiration * @see expirationIntent **/ public ExpirationIntent getExpirationIntent() { + return expirationIntent != null ? ExpirationIntent.fromValue(expirationIntent) : null; + } + + /** + * @see #getExpirationIntent() + */ + public Integer getRawExpirationIntent() { return expirationIntent; } public void setExpirationIntent(ExpirationIntent expirationIntent) { - this.expirationIntent = expirationIntent; + this.expirationIntent = expirationIntent != null ? expirationIntent.getValue() : null; + } + + public void setRawExpirationIntent(Integer rawExpirationIntent) { + this.expirationIntent = rawExpirationIntent; } public JWSRenewalInfoDecodedPayload originalTransactionId(String originalTransactionId) { @@ -136,7 +147,7 @@ public void setProductId(String productId) { } public JWSRenewalInfoDecodedPayload autoRenewStatus(AutoRenewStatus autoRenewStatus) { - this.autoRenewStatus = autoRenewStatus; + this.autoRenewStatus = autoRenewStatus != null ? autoRenewStatus.getValue() : null; return this; } @@ -147,11 +158,22 @@ public JWSRenewalInfoDecodedPayload autoRenewStatus(AutoRenewStatus autoRenewSta * @see autoRenewStatus **/ public AutoRenewStatus getAutoRenewStatus() { + return autoRenewStatus != null ? AutoRenewStatus.fromValue(autoRenewStatus) : null; + } + + /** + * @see #getAutoRenewStatus() + */ + public Integer getRawAutoRenewStatus() { return autoRenewStatus; } public void setAutoRenewStatus(AutoRenewStatus autoRenewStatus) { - this.autoRenewStatus = autoRenewStatus; + this.autoRenewStatus = autoRenewStatus != null ? autoRenewStatus.getValue() : null; + } + + public void setRawAutoRenewStatus(Integer rawAutoRenewStatus) { + this.autoRenewStatus = rawAutoRenewStatus; } public JWSRenewalInfoDecodedPayload isInBillingRetryPeriod(Boolean isInBillingRetryPeriod) { @@ -174,7 +196,7 @@ public void setIsInBillingRetryPeriod(Boolean isInBillingRetryPeriod) { } public JWSRenewalInfoDecodedPayload priceIncreaseStatus(PriceIncreaseStatus priceIncreaseStatus) { - this.priceIncreaseStatus = priceIncreaseStatus; + this.priceIncreaseStatus = priceIncreaseStatus != null ? priceIncreaseStatus.getValue() : null; return this; } @@ -185,11 +207,22 @@ public JWSRenewalInfoDecodedPayload priceIncreaseStatus(PriceIncreaseStatus pric * @see priceIncreaseStatus **/ public PriceIncreaseStatus getPriceIncreaseStatus() { + return priceIncreaseStatus != null ? PriceIncreaseStatus.fromValue(priceIncreaseStatus) : null; + } + + /** + * @see #getPriceIncreaseStatus() + */ + public Integer getRawPriceIncreaseStatus() { return priceIncreaseStatus; } public void setPriceIncreaseStatus(PriceIncreaseStatus priceIncreaseStatus) { - this.priceIncreaseStatus = priceIncreaseStatus; + this.priceIncreaseStatus = priceIncreaseStatus != null ? priceIncreaseStatus.getValue() : null; + } + + public void setRawPriceIncreaseStatus(Integer rawPriceIncreaseStatus) { + this.priceIncreaseStatus = rawPriceIncreaseStatus; } public JWSRenewalInfoDecodedPayload gracePeriodExpiresDate(Long gracePeriodExpiresDate) { @@ -212,7 +245,7 @@ public void setGracePeriodExpiresDate(Long gracePeriodExpiresDate) { } public JWSRenewalInfoDecodedPayload offerType(OfferType offerType) { - this.offerType = offerType; + this.offerType = offerType != null ? offerType.getValue() : null; return this; } @@ -223,11 +256,22 @@ public JWSRenewalInfoDecodedPayload offerType(OfferType offerType) { * @see offerType **/ public OfferType getOfferType() { + return offerType != null ? OfferType.fromValue(offerType) : null; + } + + /** + * @see #getOfferType() + */ + public Integer getRawOfferType() { return offerType; } public void setOfferType(OfferType offerType) { - this.offerType = offerType; + this.offerType = offerType != null ? offerType.getValue() : null; + } + + public void setRawOfferType(Integer rawOfferType) { + this.offerType = rawOfferType; } public JWSRenewalInfoDecodedPayload offerIdentifier(String offerIdentifier) { @@ -269,7 +313,7 @@ public void setSignedDate(Long signedDate) { } public JWSRenewalInfoDecodedPayload environment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; return this; } @@ -280,11 +324,22 @@ public JWSRenewalInfoDecodedPayload environment(Environment environment) { * @see environment **/ public Environment getEnvironment() { + return environment != null ? Environment.fromValue(environment) : null; + } + + /** + * @see #getEnvironment() + */ + public String getRawEnvironment() { return environment; } public void setEnvironment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; + } + + public void setRawEnvironment(String rawEnvironment) { + this.environment = rawEnvironment; } public JWSRenewalInfoDecodedPayload recentSubscriptionStartDate(Long recentSubscriptionStartDate) { diff --git a/src/main/java/com/apple/itunes/storekit/model/JWSTransactionDecodedPayload.java b/src/main/java/com/apple/itunes/storekit/model/JWSTransactionDecodedPayload.java index 232d3c62..6316cd14 100644 --- a/src/main/java/com/apple/itunes/storekit/model/JWSTransactionDecodedPayload.java +++ b/src/main/java/com/apple/itunes/storekit/model/JWSTransactionDecodedPayload.java @@ -57,31 +57,31 @@ public class JWSTransactionDecodedPayload implements DecodedSignedData { @SerializedName(SERIALIZED_NAME_QUANTITY) private Integer quantity; @SerializedName(SERIALIZED_NAME_TYPE) - private Type type; + private String type; @SerializedName(SERIALIZED_NAME_APP_ACCOUNT_TOKEN) private UUID appAccountToken; @SerializedName(SERIALIZED_NAME_IN_APP_OWNERSHIP_TYPE) - private InAppOwnershipType inAppOwnershipType; + private String inAppOwnershipType; @SerializedName(SERIALIZED_NAME_SIGNED_DATE) private Long signedDate; @SerializedName(SERIALIZED_NAME_REVOCATION_REASON) - private RevocationReason revocationReason; + private Integer revocationReason; @SerializedName(SERIALIZED_NAME_REVOCATION_DATE) private Long revocationDate; @SerializedName(SERIALIZED_NAME_IS_UPGRADED) private Boolean isUpgraded; @SerializedName(SERIALIZED_NAME_OFFER_TYPE) - private OfferType offerType; + private Integer offerType; @SerializedName(SERIALIZED_NAME_OFFER_IDENTIFIER) private String offerIdentifier; @SerializedName(SERIALIZED_NAME_ENVIRONMENT) - private Environment environment; + private String environment; @SerializedName(SERIALIZED_NAME_STOREFRONT) private String storefront; @SerializedName(SERIALIZED_NAME_STOREFRONT_ID) private String storefrontId; @SerializedName(SERIALIZED_NAME_TRANSACTION_REASON) - private TransactionReason transactionReason; + private String transactionReason; public JWSTransactionDecodedPayload() { @@ -278,7 +278,7 @@ public void setQuantity(Integer quantity) { } public JWSTransactionDecodedPayload type(Type type) { - this.type = type; + this.type = type != null ? type.getValue() : null; return this; } @@ -289,11 +289,22 @@ public JWSTransactionDecodedPayload type(Type type) { * @see type **/ public Type getType() { + return type != null ? Type.fromValue(type) : null; + } + + /** + * @see #getType() + */ + public String getRawType() { return type; } public void setType(Type type) { - this.type = type; + this.type = type != null ? type.getValue() : null; + } + + public void setRawType(String rawType) { + this.type = rawType; } public JWSTransactionDecodedPayload appAccountToken(UUID appAccountToken) { @@ -316,7 +327,7 @@ public void setAppAccountToken(UUID appAccountToken) { } public JWSTransactionDecodedPayload inAppOwnershipType(InAppOwnershipType inAppOwnershipType) { - this.inAppOwnershipType = inAppOwnershipType; + this.inAppOwnershipType = inAppOwnershipType != null ? inAppOwnershipType.getValue() : null; return this; } @@ -327,11 +338,22 @@ public JWSTransactionDecodedPayload inAppOwnershipType(InAppOwnershipType inAppO * @see inAppOwnershipType **/ public InAppOwnershipType getInAppOwnershipType() { + return inAppOwnershipType != null ? InAppOwnershipType.fromValue(inAppOwnershipType) : null; + } + + /** + * @see #getRawInAppOwnershipType() + */ + public String getRawInAppOwnershipType() { return inAppOwnershipType; } public void setInAppOwnershipType(InAppOwnershipType inAppOwnershipType) { - this.inAppOwnershipType = inAppOwnershipType; + this.inAppOwnershipType = inAppOwnershipType != null ? inAppOwnershipType.getValue() : null; + } + + public void setRawInAppOwnershipType(String rawInAppOwnershipType) { + this.inAppOwnershipType = rawInAppOwnershipType; } public JWSTransactionDecodedPayload signedDate(Long signedDate) { @@ -354,7 +376,7 @@ public void setSignedDate(Long signedDate) { } public JWSTransactionDecodedPayload revocationReason(RevocationReason revocationReason) { - this.revocationReason = revocationReason; + this.revocationReason = revocationReason != null ? revocationReason.getValue() : null; return this; } @@ -365,11 +387,22 @@ public JWSTransactionDecodedPayload revocationReason(RevocationReason revocation * @see revocationReason **/ public RevocationReason getRevocationReason() { + return revocationReason != null ? RevocationReason.fromValue(revocationReason) : null; + } + + /** + * @see #getRevocationReason() + */ + public Integer getRawRevocationReason() { return revocationReason; } public void setRevocationReason(RevocationReason revocationReason) { - this.revocationReason = revocationReason; + this.revocationReason = revocationReason != null ? revocationReason.getValue(): null; + } + + public void setRawRevocationReason(Integer rawRevocationReason) { + this.revocationReason = rawRevocationReason; } public JWSTransactionDecodedPayload revocationDate(Long revocationDate) { @@ -411,7 +444,7 @@ public void setIsUpgraded(Boolean isUpgraded) { } public JWSTransactionDecodedPayload offerType(OfferType offerType) { - this.offerType = offerType; + this.offerType = offerType != null ? offerType.getValue() : null; return this; } @@ -422,11 +455,22 @@ public JWSTransactionDecodedPayload offerType(OfferType offerType) { * @see offerType **/ public OfferType getOfferType() { + return offerType != null ? OfferType.fromValue(offerType) : null; + } + + /** + * @see #getOfferType() + */ + public Integer getRawOfferType() { return offerType; } public void setOfferType(OfferType offerType) { - this.offerType = offerType; + this.offerType = offerType != null ? offerType.getValue() : null; + } + + public void setRawOfferType(Integer rawOfferType) { + this.offerType = rawOfferType; } public JWSTransactionDecodedPayload offerIdentifier(String offerIdentifier) { @@ -449,7 +493,7 @@ public void setOfferIdentifier(String offerIdentifier) { } public JWSTransactionDecodedPayload environment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; return this; } @@ -460,11 +504,22 @@ public JWSTransactionDecodedPayload environment(Environment environment) { * @see environment **/ public Environment getEnvironment() { + return environment != null ? Environment.fromValue(environment) : null; + } + + /** + * @see #getRawEnvironment() + */ + public String getRawEnvironment() { return environment; } public void setEnvironment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; + } + + public void setRawEnvironment(String rawEnvironment) { + this.environment = rawEnvironment; } public JWSTransactionDecodedPayload storefront(String storefront) { @@ -506,7 +561,7 @@ public void setStorefrontId(String storefrontId) { } public JWSTransactionDecodedPayload transactionReason(TransactionReason transactionReason) { - this.transactionReason = transactionReason; + this.transactionReason = transactionReason != null ? transactionReason.getValue() : null; return this; } @@ -517,11 +572,22 @@ public JWSTransactionDecodedPayload transactionReason(TransactionReason transact * @see transactionReason **/ public TransactionReason getTransactionReason() { + return transactionReason != null ? TransactionReason.fromValue(transactionReason) : null; + } + + /** + * @see #getTransactionReason() + */ + public String getRawTransactionReason() { return transactionReason; } public void setTransactionReason(TransactionReason transactionReason) { - this.transactionReason = transactionReason; + this.transactionReason = transactionReason != null ? transactionReason.getValue() : null; + } + + public void setRawTransactionReason(String rawTransactionReason) { + this.transactionReason = rawTransactionReason; } @Override diff --git a/src/main/java/com/apple/itunes/storekit/model/LastTransactionsItem.java b/src/main/java/com/apple/itunes/storekit/model/LastTransactionsItem.java index 9306d6d1..1517a0dd 100644 --- a/src/main/java/com/apple/itunes/storekit/model/LastTransactionsItem.java +++ b/src/main/java/com/apple/itunes/storekit/model/LastTransactionsItem.java @@ -17,7 +17,7 @@ public class LastTransactionsItem { private static final String SERIALIZED_NAME_SIGNED_TRANSACTION_INFO = "signedTransactionInfo"; private static final String SERIALIZED_NAME_SIGNED_RENEWAL_INFO = "signedRenewalInfo"; @SerializedName(SERIALIZED_NAME_STATUS) - private Status status; + private Integer status; @SerializedName(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) private String originalTransactionId; @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO) @@ -30,7 +30,7 @@ public LastTransactionsItem() { } public LastTransactionsItem status(Status status) { - this.status = status; + this.status = status != null ? status.getValue() : null; return this; } @@ -41,11 +41,22 @@ public LastTransactionsItem status(Status status) { * @see status **/ public Status getStatus() { + return status != null ? Status.fromValue(status) : null; + } + + /** + * @see #getStatus() + */ + public Integer getRawStatus() { return status; } public void setStatus(Status status) { - this.status = status; + this.status = status != null ? status.getValue() : null; + } + + public void setRawStatus(Integer rawStatus) { + this.status = rawStatus; } public LastTransactionsItem originalTransactionId(String originalTransactionId) { diff --git a/src/main/java/com/apple/itunes/storekit/model/OrderLookupResponse.java b/src/main/java/com/apple/itunes/storekit/model/OrderLookupResponse.java index 83c58092..d1283ad3 100644 --- a/src/main/java/com/apple/itunes/storekit/model/OrderLookupResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/OrderLookupResponse.java @@ -17,7 +17,7 @@ public class OrderLookupResponse { private static final String SERIALIZED_NAME_STATUS = "status"; private static final String SERIALIZED_NAME_SIGNED_TRANSACTIONS = "signedTransactions"; @SerializedName(SERIALIZED_NAME_STATUS) - private OrderLookupStatus status; + private Integer status; @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTIONS) private List signedTransactions = null; @@ -26,7 +26,7 @@ public OrderLookupResponse() { } public OrderLookupResponse status(OrderLookupStatus status) { - this.status = status; + this.status = status != null ? status.getValue() : null; return this; } @@ -37,11 +37,22 @@ public OrderLookupResponse status(OrderLookupStatus status) { * @see OrderLookupStatus **/ public OrderLookupStatus getStatus() { + return status != null ? OrderLookupStatus.fromValue(status) : null; + } + + /** + * @see #getStatus() + */ + public Integer getRawStatus() { return status; } public void setStatus(OrderLookupStatus status) { - this.status = status; + this.status = status != null ? status.getValue() : null; + } + + public void setRawStatus(Integer rawStatus) { + this.status = rawStatus; } public OrderLookupResponse signedTransactions(List signedTransactions) { diff --git a/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2DecodedPayload.java b/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2DecodedPayload.java index 36f7de0b..ef5bde10 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2DecodedPayload.java +++ b/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2DecodedPayload.java @@ -20,9 +20,9 @@ public class ResponseBodyV2DecodedPayload implements DecodedSignedData { private static final String SERIALIZED_NAME_SIGNED_DATE = "signedDate"; private static final String SERIALIZED_NAME_SUMMARY = "summary"; @SerializedName(SERIALIZED_NAME_NOTIFICATION_TYPE) - private NotificationTypeV2 notificationType; + private String notificationType; @SerializedName(SERIALIZED_NAME_SUBTYPE) - private Subtype subtype; + private String subtype; @SerializedName(SERIALIZED_NAME_NOTIFICATION_U_U_I_D) private String notificationUUID; @SerializedName(SERIALIZED_NAME_DATA) @@ -39,7 +39,7 @@ public ResponseBodyV2DecodedPayload() { } public ResponseBodyV2DecodedPayload notificationType(NotificationTypeV2 notificationType) { - this.notificationType = notificationType; + this.notificationType = notificationType != null ? notificationType.getValue() : null; return this; } @@ -50,15 +50,26 @@ public ResponseBodyV2DecodedPayload notificationType(NotificationTypeV2 notifica * @see notificationType **/ public NotificationTypeV2 getNotificationType() { + return notificationType != null ? NotificationTypeV2.fromValue(notificationType) : null; + } + + /** + * @see #getNotificationType() + */ + public String getRawNotificationType() { return notificationType; } public void setNotificationType(NotificationTypeV2 notificationType) { - this.notificationType = notificationType; + this.notificationType = notificationType != null ? notificationType.getValue() : null; + } + + public void setRawNotificationType(String rawNotificationType) { + this.notificationType = rawNotificationType; } public ResponseBodyV2DecodedPayload subtype(Subtype subtype) { - this.subtype = subtype; + this.subtype = subtype != null ? subtype.getValue() : null; return this; } @@ -69,11 +80,22 @@ public ResponseBodyV2DecodedPayload subtype(Subtype subtype) { * @see subtype **/ public Subtype getSubtype() { + return subtype != null ? Subtype.fromValue(subtype) : null; + } + + /** + * @see #getSubtype() + */ + public String getRawSubtype() { return subtype; } public void setSubtype(Subtype subtype) { - this.subtype = subtype; + this.subtype = subtype != null ? subtype.getValue() : null; + } + + public void setRawSubtype(String rawSubtype) { + this.subtype = rawSubtype; } public ResponseBodyV2DecodedPayload notificationUUID(String notificationUUID) { diff --git a/src/main/java/com/apple/itunes/storekit/model/SendAttemptItem.java b/src/main/java/com/apple/itunes/storekit/model/SendAttemptItem.java index 8a393822..d60b5270 100644 --- a/src/main/java/com/apple/itunes/storekit/model/SendAttemptItem.java +++ b/src/main/java/com/apple/itunes/storekit/model/SendAttemptItem.java @@ -17,7 +17,7 @@ public class SendAttemptItem { @SerializedName(SERIALIZED_NAME_ATTEMPT_DATE) private Long attemptDate; @SerializedName(SERIALIZED_NAME_SEND_ATTEMPT_RESULT) - private SendAttemptResult sendAttemptResult; + private String sendAttemptResult; public SendAttemptItem() { } @@ -42,7 +42,7 @@ public void setAttemptDate(Long attemptDate) { } public SendAttemptItem sendAttemptResult(SendAttemptResult sendAttemptResult) { - this.sendAttemptResult = sendAttemptResult; + this.sendAttemptResult = sendAttemptResult != null ? sendAttemptResult.getValue() : null; return this; } @@ -53,11 +53,22 @@ public SendAttemptItem sendAttemptResult(SendAttemptResult sendAttemptResult) { * @see sendAttemptResult **/ public SendAttemptResult getSendAttemptResult() { + return sendAttemptResult != null ? SendAttemptResult.fromValue(sendAttemptResult) : null; + } + + /** + * @see #getSendAttemptResult() + */ + public String getRawSendAttemptResult() { return sendAttemptResult; } public void setSendAttemptResult(SendAttemptResult sendAttemptResult) { - this.sendAttemptResult = sendAttemptResult; + this.sendAttemptResult = sendAttemptResult != null ? sendAttemptResult.getValue() : null; + } + + public void setRawSendAttemptResult(String rawSendAttemptResult) { + this.sendAttemptResult = rawSendAttemptResult; } @Override diff --git a/src/main/java/com/apple/itunes/storekit/model/Summary.java b/src/main/java/com/apple/itunes/storekit/model/Summary.java index b1f761ab..dfd41596 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Summary.java +++ b/src/main/java/com/apple/itunes/storekit/model/Summary.java @@ -23,7 +23,7 @@ public class Summary { private static final String SERIALIZED_NAME_SUCCEEDED_COUNT = "succeededCount"; private static final String SERIALIZED_NAME_FAILED_COUNT = "failedCount"; @SerializedName(SERIALIZED_NAME_ENVIRONMENT) - private Environment environment; + private String environment; @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; @SerializedName(SERIALIZED_NAME_BUNDLE_ID) @@ -33,7 +33,7 @@ public class Summary { @SerializedName(SERIALIZED_NAME_REQUEST_IDENTIFIER) private String requestIdentifier; @SerializedName(SERIALIZED_NAME_STOREFRONT_COUNTRY_CODES) - private List storefrontCountryCodes = null; + private List storefrontCountryCodes; @SerializedName(SERIALIZED_NAME_SUCCEEDED_COUNT) private Long succeededCount; @SerializedName(SERIALIZED_NAME_FAILED_COUNT) @@ -44,7 +44,7 @@ public Summary() { } public Summary environment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; return this; } @@ -55,11 +55,22 @@ public Summary environment(Environment environment) { * @see environment **/ public Environment getEnvironment() { + return environment != null ? Environment.fromValue(environment) : null; + } + + /** + * @see #getEnvironment() + */ + public String getRawEnvironment() { return environment; } public void setEnvironment(Environment environment) { - this.environment = environment; + this.environment = environment != null ? environment.getValue() : null; + } + + public void setRawEnvironment(String rawEnvironment) { + this.environment = rawEnvironment; } public Summary appAppleId(Long appAppleId) {