From ed5fb0150bb587353a98887c753157acf6fb519d Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 4 Dec 2023 10:38:44 -0600 Subject: [PATCH] Switch GSON to Jackson to allow unknownFields to be parsed --- NOTICE.txt | 7 +- build.gradle | 2 +- .../client/AppStoreServerAPIClient.java | 27 ++++- .../itunes/storekit/model/AccountTenure.java | 24 +--- .../itunes/storekit/model/AppTransaction.java | 64 +++++++---- .../storekit/model/AutoRenewStatus.java | 24 +--- .../model/CheckTestNotificationResponse.java | 36 +++++- .../storekit/model/ConsumptionRequest.java | 24 ++-- .../storekit/model/ConsumptionStatus.java | 24 +--- .../com/apple/itunes/storekit/model/Data.java | 46 ++++++-- .../itunes/storekit/model/DeliveryStatus.java | 24 +--- .../itunes/storekit/model/Environment.java | 24 +--- .../itunes/storekit/model/ErrorPayload.java | 7 ++ .../storekit/model/ExpirationIntent.java | 24 +--- .../storekit/model/ExtendReasonCode.java | 24 +--- .../model/ExtendRenewalDateRequest.java | 8 +- .../model/ExtendRenewalDateResponse.java | 38 +++++-- .../model/FirstSendAttemptResult.java | 69 ------------ .../storekit/model/HistoryResponse.java | 44 ++++++-- .../storekit/model/InAppOwnershipType.java | 24 +--- .../model/JWSRenewalInfoDecodedPayload.java | 71 ++++++++---- .../model/JWSTransactionDecodedPayload.java | 105 +++++++++++------- .../storekit/model/LastTransactionsItem.java | 38 +++++-- .../model/LifetimeDollarsPurchased.java | 24 +--- .../model/LifetimeDollarsRefunded.java | 24 +--- .../model/MassExtendRenewalDateRequest.java | 12 +- .../model/MassExtendRenewalDateResponse.java | 33 +++++- .../MassExtendRenewalDateStatusResponse.java | 41 +++++-- .../model/NotificationHistoryRequest.java | 14 +-- .../model/NotificationHistoryResponse.java | 37 +++++- .../NotificationHistoryResponseItem.java | 35 +++++- .../storekit/model/NotificationTypeV2.java | 24 +--- .../storekit/model/OfferDiscountType.java | 24 +--- .../itunes/storekit/model/OfferType.java | 24 +--- .../storekit/model/OrderLookupResponse.java | 35 +++++- .../storekit/model/OrderLookupStatus.java | 24 +--- .../apple/itunes/storekit/model/Platform.java | 24 +--- .../apple/itunes/storekit/model/PlayTime.java | 24 +--- .../storekit/model/PriceIncreaseStatus.java | 24 +--- .../storekit/model/RefundHistoryResponse.java | 37 +++++- .../itunes/storekit/model/ResponseBodyV2.java | 33 +++++- .../model/ResponseBodyV2DecodedPayload.java | 49 ++++++-- .../storekit/model/RevocationReason.java | 24 +--- .../storekit/model/SendAttemptItem.java | 39 +++++-- .../storekit/model/SendAttemptResult.java | 24 +--- .../model/SendTestNotificationResponse.java | 33 +++++- .../apple/itunes/storekit/model/Status.java | 24 +--- .../itunes/storekit/model/StatusResponse.java | 41 +++++-- .../SubscriptionGroupIdentifierItem.java | 35 +++++- .../apple/itunes/storekit/model/Subtype.java | 24 +--- .../apple/itunes/storekit/model/Summary.java | 49 ++++++-- .../model/TransactionInfoResponse.java | 33 +++++- .../storekit/model/TransactionReason.java | 24 +--- .../com/apple/itunes/storekit/model/Type.java | 24 +--- .../itunes/storekit/model/UserStatus.java | 24 +--- .../XcodeCompatibleTimestampDeserializer.java | 17 +-- .../verification/SignedDataVerifier.java | 22 +++- .../client/AppStoreServerAPIClientTest.java | 81 ++++++++++++-- .../storekit/model/AppTransactionTest.java | 5 +- .../XcodeSignedDataVerifierTest.java | 5 +- ...istoryResponseWithMalformedAppAppleId.json | 11 ++ ...storyResponseWithMalformedEnvironment.json | 11 ++ 62 files changed, 1015 insertions(+), 855 deletions(-) delete mode 100644 src/main/java/com/apple/itunes/storekit/model/FirstSendAttemptResult.java create mode 100644 src/test/resources/models/transactionHistoryResponseWithMalformedAppAppleId.json create mode 100644 src/test/resources/models/transactionHistoryResponseWithMalformedEnvironment.json diff --git a/NOTICE.txt b/NOTICE.txt index c49dcfc6..2916a022 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -212,9 +212,7 @@ okhttp contirbutors (okhttp) _____________________ -Google Inc. (gson) - -Google Gson +jackson-databind contributors (jackson-databind) Apache License Version 2.0, January 2004 @@ -404,7 +402,7 @@ Google Gson same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2008-2011 Google Inc. + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -417,7 +415,6 @@ Google Gson WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - _____________________ Auth0, Inc. (java-jwt) diff --git a/build.gradle b/build.gradle index 146543ae..7c4fbe8d 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ targetCompatibility = JavaVersion.VERSION_11 dependencies { implementation 'com.squareup.okhttp3:okhttp:4.11.0' - implementation 'com.google.code.gson:gson:2.10.1' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0' implementation 'com.auth0:java-jwt:4.4.0' implementation 'org.bouncycastle:bcprov-jdk15on:1.70' 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 f0c2ad0d..0b2d203d 100644 --- a/src/main/java/com/apple/itunes/storekit/client/AppStoreServerAPIClient.java +++ b/src/main/java/com/apple/itunes/storekit/client/AppStoreServerAPIClient.java @@ -21,7 +21,10 @@ import com.apple.itunes.storekit.model.StatusResponse; import com.apple.itunes.storekit.model.TransactionHistoryRequest; import com.apple.itunes.storekit.model.TransactionInfoResponse; -import com.google.gson.Gson; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import okhttp3.Call; import okhttp3.HttpUrl; import okhttp3.MediaType; @@ -47,7 +50,7 @@ public class AppStoreServerAPIClient { private final OkHttpClient httpClient; private final BearerTokenAuthenticator bearerTokenAuthenticator; private final HttpUrl urlBase; - private final Gson gson; + private final ObjectMapper objectMapper; /** * Create an App Store Server API client @@ -62,7 +65,13 @@ public AppStoreServerAPIClient(String signingKey, String keyId, String issuerId, 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(); + this.objectMapper = new ObjectMapper(); + objectMapper.setVisibility(objectMapper.getSerializationConfig().getDefaultVisibilityChecker() + .withFieldVisibility(JsonAutoDetect.Visibility.ANY) + .withGetterVisibility(JsonAutoDetect.Visibility.NONE) + .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE) + .withSetterVisibility(JsonAutoDetect.Visibility.NONE) + .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); } private Response makeRequest(String path, String method, Map> queryParameters, Object body) throws IOException { @@ -78,7 +87,7 @@ private Response makeRequest(String path, String method, Map T makeHttpCall(String path, String method, MapaccountTenure */ -@JsonAdapter(AccountTenure.Adapter.class) public enum AccountTenure { UNDECLARED(0), @@ -38,24 +32,12 @@ public static AccountTenure fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final AccountTenure enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AccountTenure read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return AccountTenure.fromValue(value); - } - } } 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 da91a48b..00c39728 100644 --- a/src/main/java/com/apple/itunes/storekit/model/AppTransaction.java +++ b/src/main/java/com/apple/itunes/storekit/model/AppTransaction.java @@ -1,8 +1,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Map; import java.util.Objects; import java.util.UUID; @@ -26,31 +28,33 @@ public class AppTransaction implements DecodedSignedData { private static final String SERIALIZED_NAME_DEVICE_VERIFICATION_NONCE = "deviceVerificationNonce"; private static final String SERIALIZED_NAME_PREORDER_DATE = "preorderDate"; - @SerializedName(SERIALIZED_NAME_RECEIPT_TYPE) + @JsonProperty(SERIALIZED_NAME_RECEIPT_TYPE) private String receiptType; - @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) + @JsonProperty(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; - @SerializedName(SERIALIZED_NAME_BUNDLE_ID) + @JsonProperty(SERIALIZED_NAME_BUNDLE_ID) private String bundleId; - @SerializedName(SERIALIZED_NAME_APPLICATION_VERSION) + @JsonProperty(SERIALIZED_NAME_APPLICATION_VERSION) private String applicationVersion; - @SerializedName(SERIALIZED_NAME_VERSION_EXTERNAL_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_VERSION_EXTERNAL_IDENTIFIER) private Long versionExternalIdentifier; - @SerializedName(SERIALIZED_NAME_RECEIPT_CREATION_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_RECEIPT_CREATION_DATE) + @JsonDeserialize(using = XcodeCompatibleTimestampDeserializer.class) private Long receiptCreationDate; - @SerializedName(SERIALIZED_NAME_ORIGINAL_PURCHASE_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_ORIGINAL_PURCHASE_DATE) + @JsonDeserialize(using = XcodeCompatibleTimestampDeserializer.class) private Long originalPurchaseDate; - @SerializedName(SERIALIZED_NAME_ORIGINAL_APPLICATION_VERSION) + @JsonProperty(SERIALIZED_NAME_ORIGINAL_APPLICATION_VERSION) private String originalApplicationVersion; - @SerializedName(SERIALIZED_NAME_DEVICE_VERIFICATION) + @JsonProperty(SERIALIZED_NAME_DEVICE_VERIFICATION) private String deviceVerification; - @SerializedName(SERIALIZED_NAME_DEVICE_VERIFICATION_NONCE) + @JsonProperty(SERIALIZED_NAME_DEVICE_VERIFICATION_NONCE) private UUID deviceVerificationNonce; - @SerializedName(SERIALIZED_NAME_PREORDER_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_PREORDER_DATE) + @JsonDeserialize(using = XcodeCompatibleTimestampDeserializer.class) private Long preorderDate; + @JsonAnySetter + private Map unknownFields; /** The server environment that signs the app transaction. @@ -140,7 +144,7 @@ public AppTransaction applicationVersion(String applicationVersion) { @see appVersionID */ - public Long versionExternalIdentifier() { + public Long getVersionExternalIdentifier() { return this.versionExternalIdentifier; } @@ -176,7 +180,7 @@ public AppTransaction receiptCreationDate(Long receiptCreationDate) { @see originalPurchaseDate */ - public Long originalPurchaseDate() { + public Long getOriginalPurchaseDate() { return this.originalPurchaseDate; } @@ -263,6 +267,24 @@ public AppTransaction preorderDate(Long preorderDate) { return this; } + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + + public AppTransaction unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + public Long getSignedDate() { return getReceiptCreationDate(); } @@ -272,12 +294,12 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AppTransaction that = (AppTransaction) o; - return Objects.equals(receiptType, that.receiptType) && Objects.equals(appAppleId, that.appAppleId) && Objects.equals(bundleId, that.bundleId) && Objects.equals(applicationVersion, that.applicationVersion) && Objects.equals(versionExternalIdentifier, that.versionExternalIdentifier) && Objects.equals(originalPurchaseDate, that.originalPurchaseDate) && Objects.equals(originalApplicationVersion, that.originalApplicationVersion) && Objects.equals(deviceVerification, that.deviceVerification) && Objects.equals(deviceVerificationNonce, that.deviceVerificationNonce) && Objects.equals(preorderDate, that.preorderDate); + return Objects.equals(receiptType, that.receiptType) && Objects.equals(appAppleId, that.appAppleId) && Objects.equals(bundleId, that.bundleId) && Objects.equals(applicationVersion, that.applicationVersion) && Objects.equals(versionExternalIdentifier, that.versionExternalIdentifier) && Objects.equals(originalPurchaseDate, that.originalPurchaseDate) && Objects.equals(originalApplicationVersion, that.originalApplicationVersion) && Objects.equals(deviceVerification, that.deviceVerification) && Objects.equals(deviceVerificationNonce, that.deviceVerificationNonce) && Objects.equals(preorderDate, that.preorderDate) && Objects.equals(unknownFields, that.unknownFields); } @Override public int hashCode() { - return Objects.hash(receiptType, appAppleId, bundleId, applicationVersion, versionExternalIdentifier, originalPurchaseDate, originalApplicationVersion, deviceVerification, deviceVerificationNonce, preorderDate); + return Objects.hash(receiptType, appAppleId, bundleId, applicationVersion, versionExternalIdentifier, originalPurchaseDate, originalApplicationVersion, deviceVerification, deviceVerificationNonce, preorderDate, unknownFields); } @Override @@ -288,11 +310,13 @@ public String toString() { ", bundleId='" + bundleId + '\'' + ", applicationVersion='" + applicationVersion + '\'' + ", versionExternalIdentifier=" + versionExternalIdentifier + + ", receiptCreationDate=" + receiptCreationDate + ", originalPurchaseDate=" + originalPurchaseDate + ", originalApplicationVersion='" + originalApplicationVersion + '\'' + ", deviceVerification='" + deviceVerification + '\'' + ", deviceVerificationNonce=" + deviceVerificationNonce + ", preorderDate=" + preorderDate + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/AutoRenewStatus.java b/src/main/java/com/apple/itunes/storekit/model/AutoRenewStatus.java index 40453cfa..180e8785 100644 --- a/src/main/java/com/apple/itunes/storekit/model/AutoRenewStatus.java +++ b/src/main/java/com/apple/itunes/storekit/model/AutoRenewStatus.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The renewal status for an auto-renewable subscription. * * @see autoRenewStatus */ -@JsonAdapter(AutoRenewStatus.Adapter.class) public enum AutoRenewStatus { OFF(0), @@ -32,9 +26,10 @@ public static AutoRenewStatus fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -43,18 +38,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final AutoRenewStatus enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AutoRenewStatus read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return AutoRenewStatus.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/CheckTestNotificationResponse.java b/src/main/java/com/apple/itunes/storekit/model/CheckTestNotificationResponse.java index b82e1a8c..61b9af56 100644 --- a/src/main/java/com/apple/itunes/storekit/model/CheckTestNotificationResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/CheckTestNotificationResponse.java @@ -2,9 +2,11 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -15,10 +17,12 @@ public class CheckTestNotificationResponse { private static final String SERIALIZED_NAME_SIGNED_PAYLOAD = "signedPayload"; private static final String SERIALIZED_NAME_SEND_ATTEMPTS = "sendAttempts"; - @SerializedName(SERIALIZED_NAME_SIGNED_PAYLOAD) + @JsonProperty(SERIALIZED_NAME_SIGNED_PAYLOAD) private String signedPayload; - @SerializedName(SERIALIZED_NAME_SEND_ATTEMPTS) + @JsonProperty(SERIALIZED_NAME_SEND_ATTEMPTS) private List sendAttempts; + @JsonAnySetter + private Map unknownFields; public CheckTestNotificationResponse() { @@ -62,6 +66,24 @@ public void setSendAttempts(List sendAttempts) { this.sendAttempts = sendAttempts; } + public CheckTestNotificationResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -72,19 +94,21 @@ public boolean equals(Object o) { } CheckTestNotificationResponse checkTestNotificationResponse = (CheckTestNotificationResponse) o; return Objects.equals(this.signedPayload, checkTestNotificationResponse.signedPayload) && - Objects.equals(this.sendAttempts, checkTestNotificationResponse.sendAttempts); + Objects.equals(this.sendAttempts, checkTestNotificationResponse.sendAttempts) && + Objects.equals(this.unknownFields, checkTestNotificationResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(signedPayload, sendAttempts); + return Objects.hash(signedPayload, sendAttempts, unknownFields); } @Override public String toString() { return "CheckTestNotificationResponse{" + "signedPayload='" + signedPayload + '\'' + - ", sendAttemptResult=" + sendAttempts + + ", sendAttempts=" + sendAttempts + + ", unknownFields=" + unknownFields + '}'; } } 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 0528b752..3540ed6e 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ConsumptionRequest.java +++ b/src/main/java/com/apple/itunes/storekit/model/ConsumptionRequest.java @@ -2,7 +2,7 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Objects; import java.util.UUID; @@ -24,27 +24,27 @@ public class ConsumptionRequest { private static final String SERIALIZED_NAME_LIFETIME_DOLLARS_REFUNDED = "lifetimeDollarsRefunded"; private static final String SERIALIZED_NAME_LIFETIME_DOLLARS_PURCHASED = "lifetimeDollarsPurchased"; private static final String SERIALIZED_NAME_USER_STATUS = "userStatus"; - @SerializedName(SERIALIZED_NAME_CUSTOMER_CONSENTED) + @JsonProperty(SERIALIZED_NAME_CUSTOMER_CONSENTED) private Boolean customerConsented; - @SerializedName(SERIALIZED_NAME_CONSUMPTION_STATUS) + @JsonProperty(SERIALIZED_NAME_CONSUMPTION_STATUS) private Integer consumptionStatus; - @SerializedName(SERIALIZED_NAME_PLATFORM) + @JsonProperty(SERIALIZED_NAME_PLATFORM) private Integer platform; - @SerializedName(SERIALIZED_NAME_SAMPLE_CONTENT_PROVIDED) + @JsonProperty(SERIALIZED_NAME_SAMPLE_CONTENT_PROVIDED) private Boolean sampleContentProvided; - @SerializedName(SERIALIZED_NAME_DELIVERY_STATUS) + @JsonProperty(SERIALIZED_NAME_DELIVERY_STATUS) private Integer deliveryStatus; - @SerializedName(SERIALIZED_NAME_APP_ACCOUNT_TOKEN) + @JsonProperty(SERIALIZED_NAME_APP_ACCOUNT_TOKEN) private UUID appAccountToken; - @SerializedName(SERIALIZED_NAME_ACCOUNT_TENURE) + @JsonProperty(SERIALIZED_NAME_ACCOUNT_TENURE) private Integer accountTenure; - @SerializedName(SERIALIZED_NAME_PLAY_TIME) + @JsonProperty(SERIALIZED_NAME_PLAY_TIME) private Integer playTime; - @SerializedName(SERIALIZED_NAME_LIFETIME_DOLLARS_REFUNDED) + @JsonProperty(SERIALIZED_NAME_LIFETIME_DOLLARS_REFUNDED) private Integer lifetimeDollarsRefunded; - @SerializedName(SERIALIZED_NAME_LIFETIME_DOLLARS_PURCHASED) + @JsonProperty(SERIALIZED_NAME_LIFETIME_DOLLARS_PURCHASED) private Integer lifetimeDollarsPurchased; - @SerializedName(SERIALIZED_NAME_USER_STATUS) + @JsonProperty(SERIALIZED_NAME_USER_STATUS) private Integer userStatus; diff --git a/src/main/java/com/apple/itunes/storekit/model/ConsumptionStatus.java b/src/main/java/com/apple/itunes/storekit/model/ConsumptionStatus.java index aaf5655f..de272ba8 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ConsumptionStatus.java +++ b/src/main/java/com/apple/itunes/storekit/model/ConsumptionStatus.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A value that indicates the extent to which the customer consumed the in-app purchase. * * @see consumptionStatus */ -@JsonAdapter(ConsumptionStatus.Adapter.class) public enum ConsumptionStatus { UNDECLARED(0), @@ -34,9 +28,10 @@ public static ConsumptionStatus fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -45,18 +40,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final ConsumptionStatus enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public ConsumptionStatus read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return ConsumptionStatus.fromValue(value); - } - } } 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 c04fcd4e..919c9a30 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Data.java +++ b/src/main/java/com/apple/itunes/storekit/model/Data.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -19,20 +21,22 @@ public class Data { private static final String SERIALIZED_NAME_SIGNED_TRANSACTION_INFO = "signedTransactionInfo"; private static final String SERIALIZED_NAME_SIGNED_RENEWAL_INFO = "signedRenewalInfo"; private static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + @JsonProperty(SERIALIZED_NAME_ENVIRONMENT) private String environment; - @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) + @JsonProperty(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; - @SerializedName(SERIALIZED_NAME_BUNDLE_ID) + @JsonProperty(SERIALIZED_NAME_BUNDLE_ID) private String bundleId; - @SerializedName(SERIALIZED_NAME_BUNDLE_VERSION) + @JsonProperty(SERIALIZED_NAME_BUNDLE_VERSION) private String bundleVersion; - @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO) + @JsonProperty(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO) private String signedTransactionInfo; - @SerializedName(SERIALIZED_NAME_SIGNED_RENEWAL_INFO) + @JsonProperty(SERIALIZED_NAME_SIGNED_RENEWAL_INFO) private String signedRenewalInfo; - @SerializedName(SERIALIZED_NAME_STATUS) + @JsonProperty(SERIALIZED_NAME_STATUS) private Integer status; + @JsonAnySetter + private Map unknownFields; public Data() { @@ -193,6 +197,24 @@ public void setRawStatus(Integer rawStatus) { this.status = rawStatus; } + public Data unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -208,24 +230,26 @@ public boolean equals(Object o) { Objects.equals(this.bundleVersion, data.bundleVersion) && Objects.equals(this.signedTransactionInfo, data.signedTransactionInfo) && Objects.equals(this.signedRenewalInfo, data.signedRenewalInfo) && - Objects.equals(this.status, data.status); + Objects.equals(this.status, data.status) && + Objects.equals(this.unknownFields, data.unknownFields); } @Override public int hashCode() { - return Objects.hash(environment, appAppleId, bundleId, bundleVersion, signedTransactionInfo, signedRenewalInfo, status); + return Objects.hash(environment, appAppleId, bundleId, bundleVersion, signedTransactionInfo, signedRenewalInfo, status, unknownFields); } @Override public String toString() { return "Data{" + - "environment=" + environment + + "environment='" + environment + '\'' + ", appAppleId=" + appAppleId + ", bundleId='" + bundleId + '\'' + ", bundleVersion='" + bundleVersion + '\'' + ", signedTransactionInfo='" + signedTransactionInfo + '\'' + ", signedRenewalInfo='" + signedRenewalInfo + '\'' + ", status=" + status + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/DeliveryStatus.java b/src/main/java/com/apple/itunes/storekit/model/DeliveryStatus.java index 7b7e7303..4b236068 100644 --- a/src/main/java/com/apple/itunes/storekit/model/DeliveryStatus.java +++ b/src/main/java/com/apple/itunes/storekit/model/DeliveryStatus.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A value that indicates whether the app successfully delivered an in-app purchase that works properly. * * @see deliveryStatus */ -@JsonAdapter(DeliveryStatus.Adapter.class) public enum DeliveryStatus { DELIVERED_AND_WORKING_PROPERLY(0), @@ -36,9 +30,10 @@ public static DeliveryStatus fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -47,18 +42,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final DeliveryStatus enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public DeliveryStatus read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return DeliveryStatus.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/Environment.java b/src/main/java/com/apple/itunes/storekit/model/Environment.java index a7c48c55..ed6ae8fa 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Environment.java +++ b/src/main/java/com/apple/itunes/storekit/model/Environment.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The server environment, either sandbox or production. * * @see environment */ -@JsonAdapter(Environment.Adapter.class) public enum Environment { SANDBOX("Sandbox"), @@ -34,9 +28,10 @@ public static Environment fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -45,18 +40,5 @@ public String getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final Environment enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public Environment read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return Environment.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/ErrorPayload.java b/src/main/java/com/apple/itunes/storekit/model/ErrorPayload.java index e534113e..329c54dc 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ErrorPayload.java +++ b/src/main/java/com/apple/itunes/storekit/model/ErrorPayload.java @@ -2,10 +2,17 @@ package com.apple.itunes.storekit.model; +import com.fasterxml.jackson.annotation.JsonProperty; + public class ErrorPayload { + @JsonProperty private long errorCode; + @JsonProperty private String errorMessage; + public ErrorPayload() { + } + public ErrorPayload(long errorCode, String errorMessage) { this.errorCode = errorCode; this.errorMessage = errorMessage; diff --git a/src/main/java/com/apple/itunes/storekit/model/ExpirationIntent.java b/src/main/java/com/apple/itunes/storekit/model/ExpirationIntent.java index 600f4ac5..b064a581 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ExpirationIntent.java +++ b/src/main/java/com/apple/itunes/storekit/model/ExpirationIntent.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The reason an auto-renewable subscription expired. * * @see expirationIntent */ -@JsonAdapter(ExpirationIntent.Adapter.class) public enum ExpirationIntent { CUSTOMER_CANCELLED(1), @@ -35,9 +29,10 @@ public static ExpirationIntent fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -46,18 +41,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final ExpirationIntent enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public ExpirationIntent read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return ExpirationIntent.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/ExtendReasonCode.java b/src/main/java/com/apple/itunes/storekit/model/ExtendReasonCode.java index 6186e43b..37260730 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ExtendReasonCode.java +++ b/src/main/java/com/apple/itunes/storekit/model/ExtendReasonCode.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The code that represents the reason for the subscription-renewal-date extension. * * @see extendReasonCode */ -@JsonAdapter(ExtendReasonCode.Adapter.class) public enum ExtendReasonCode { UNDECLARED(0), @@ -34,9 +28,10 @@ public static ExtendReasonCode fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -45,18 +40,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final ExtendReasonCode enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public ExtendReasonCode read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return ExtendReasonCode.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateRequest.java b/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateRequest.java index 2da3962e..f97bea35 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateRequest.java +++ b/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateRequest.java @@ -2,7 +2,7 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Objects; @@ -15,11 +15,11 @@ public class ExtendRenewalDateRequest { private static final String SERIALIZED_NAME_EXTEND_BY_DAYS = "extendByDays"; private static final String SERIALIZED_NAME_EXTEND_REASON_CODE = "extendReasonCode"; private static final String SERIALIZED_NAME_REQUEST_IDENTIFIER = "requestIdentifier"; - @SerializedName(SERIALIZED_NAME_EXTEND_BY_DAYS) + @JsonProperty(SERIALIZED_NAME_EXTEND_BY_DAYS) private Integer extendByDays; - @SerializedName(SERIALIZED_NAME_EXTEND_REASON_CODE) + @JsonProperty(SERIALIZED_NAME_EXTEND_REASON_CODE) private ExtendReasonCode extendReasonCode; - @SerializedName(SERIALIZED_NAME_REQUEST_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_REQUEST_IDENTIFIER) private String requestIdentifier; diff --git a/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateResponse.java b/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateResponse.java index 6009506b..73e61026 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/ExtendRenewalDateResponse.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -16,14 +18,16 @@ public class ExtendRenewalDateResponse { private static final String SERIALIZED_NAME_WEB_ORDER_LINE_ITEM_ID = "webOrderLineItemId"; private static final String SERIALIZED_NAME_SUCCESS = "success"; private static final String SERIALIZED_NAME_EFFECTIVE_DATE = "effectiveDate"; - @SerializedName(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) + @JsonProperty(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) private String originalTransactionId; - @SerializedName(SERIALIZED_NAME_WEB_ORDER_LINE_ITEM_ID) + @JsonProperty(SERIALIZED_NAME_WEB_ORDER_LINE_ITEM_ID) private String webOrderLineItemId; - @SerializedName(SERIALIZED_NAME_SUCCESS) + @JsonProperty(SERIALIZED_NAME_SUCCESS) private Boolean success; - @SerializedName(SERIALIZED_NAME_EFFECTIVE_DATE) + @JsonProperty(SERIALIZED_NAME_EFFECTIVE_DATE) private Long effectiveDate; + @JsonAnySetter + private Map unknownFields; public ExtendRenewalDateResponse() { @@ -105,6 +109,24 @@ public void setEffectiveDate(Long effectiveDate) { this.effectiveDate = effectiveDate; } + public ExtendRenewalDateResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -117,12 +139,13 @@ public boolean equals(Object o) { return Objects.equals(this.originalTransactionId, extendRenewalDateResponse.originalTransactionId) && Objects.equals(this.webOrderLineItemId, extendRenewalDateResponse.webOrderLineItemId) && Objects.equals(this.success, extendRenewalDateResponse.success) && - Objects.equals(this.effectiveDate, extendRenewalDateResponse.effectiveDate); + Objects.equals(this.effectiveDate, extendRenewalDateResponse.effectiveDate) && + Objects.equals(this.unknownFields, extendRenewalDateResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(originalTransactionId, webOrderLineItemId, success, effectiveDate); + return Objects.hash(originalTransactionId, webOrderLineItemId, success, effectiveDate, unknownFields); } @Override @@ -132,6 +155,7 @@ public String toString() { ", webOrderLineItemId='" + webOrderLineItemId + '\'' + ", success=" + success + ", effectiveDate=" + effectiveDate + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/FirstSendAttemptResult.java b/src/main/java/com/apple/itunes/storekit/model/FirstSendAttemptResult.java deleted file mode 100644 index 84b20ad3..00000000 --- a/src/main/java/com/apple/itunes/storekit/model/FirstSendAttemptResult.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2023 Apple Inc. Licensed under MIT License. - -package com.apple.itunes.storekit.model; - -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; - -/** - * An error or result that the App Store server receives when attempting to send an App Store server notification to your server. - * - * @see firstSendAttemptResult - */ -@JsonAdapter(FirstSendAttemptResult.Adapter.class) -public enum FirstSendAttemptResult { - - SUCCESS("SUCCESS"), - TIMED_OUT("TIMED_OUT"), - TLS_ISSUE("TLS_ISSUE"), - CIRCULAR_REDIRECT("CIRCULAR_REDIRECT"), - NO_RESPONSE("NO_RESPONSE"), - SOCKET_ISSUE("SOCKET_ISSUE"), - UNSUPPORTED_CHARSET("UNSUPPORTED_CHARSET"), - INVALID_RESPONSE("INVALID_RESPONSE"), - PREMATURE_CLOSE("PREMATURE_CLOSE"), - UNSUCCESSFUL_HTTP_RESPONSE_CODE("UNSUCCESSFUL_HTTP_RESPONSE_CODE"), - OTHER("OTHER"); - - private final String value; - - FirstSendAttemptResult(String value) { - this.value = value; - } - - public static FirstSendAttemptResult fromValue(String value) { - for (FirstSendAttemptResult b : FirstSendAttemptResult.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final FirstSendAttemptResult enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public FirstSendAttemptResult read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return FirstSendAttemptResult.fromValue(value); - } - } -} - 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 0e0b7a53..d16d4a8a 100644 --- a/src/main/java/com/apple/itunes/storekit/model/HistoryResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/HistoryResponse.java @@ -2,10 +2,12 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -20,18 +22,20 @@ public class HistoryResponse { private static final String SERIALIZED_NAME_APP_APPLE_ID = "appAppleId"; private static final String SERIALIZED_NAME_ENVIRONMENT = "environment"; private static final String SERIALIZED_NAME_SIGNED_TRANSACTIONS = "signedTransactions"; - @SerializedName(SERIALIZED_NAME_REVISION) + @JsonProperty(SERIALIZED_NAME_REVISION) private String revision; - @SerializedName(SERIALIZED_NAME_HAS_MORE) + @JsonProperty(SERIALIZED_NAME_HAS_MORE) private Boolean hasMore; - @SerializedName(SERIALIZED_NAME_BUNDLE_ID) + @JsonProperty(SERIALIZED_NAME_BUNDLE_ID) private String bundleId; - @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) + @JsonProperty(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; - @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + @JsonProperty(SERIALIZED_NAME_ENVIRONMENT) private String environment; - @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTIONS) + @JsonProperty(SERIALIZED_NAME_SIGNED_TRANSACTIONS) private List signedTransactions = null; + @JsonAnySetter + private Map unknownFields; public HistoryResponse() { @@ -170,6 +174,24 @@ public void setSignedTransactions(List signedTransactions) { this.signedTransactions = signedTransactions; } + public HistoryResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -184,12 +206,13 @@ public boolean equals(Object o) { Objects.equals(this.bundleId, historyResponse.bundleId) && Objects.equals(this.appAppleId, historyResponse.appAppleId) && Objects.equals(this.environment, historyResponse.environment) && - Objects.equals(this.signedTransactions, historyResponse.signedTransactions); + Objects.equals(this.signedTransactions, historyResponse.signedTransactions) && + Objects.equals(this.unknownFields, historyResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(revision, hasMore, bundleId, appAppleId, environment, signedTransactions); + return Objects.hash(revision, hasMore, bundleId, appAppleId, environment, signedTransactions, unknownFields); } @Override @@ -199,8 +222,9 @@ public String toString() { ", hasMore=" + hasMore + ", bundleId='" + bundleId + '\'' + ", appAppleId=" + appAppleId + - ", environment=" + environment + + ", environment='" + environment + '\'' + ", signedTransactions=" + signedTransactions + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/InAppOwnershipType.java b/src/main/java/com/apple/itunes/storekit/model/InAppOwnershipType.java index 9a571475..350c3062 100644 --- a/src/main/java/com/apple/itunes/storekit/model/InAppOwnershipType.java +++ b/src/main/java/com/apple/itunes/storekit/model/InAppOwnershipType.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The relationship of the user with the family-shared purchase to which they have access. * * @see inAppOwnershipType */ -@JsonAdapter(InAppOwnershipType.Adapter.class) public enum InAppOwnershipType { FAMILY_SHARED("FAMILY_SHARED"), @@ -32,9 +26,10 @@ public static InAppOwnershipType fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -43,18 +38,5 @@ public String getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final InAppOwnershipType enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public InAppOwnershipType read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return InAppOwnershipType.fromValue(value); - } - } } 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 efb4b456..994aef02 100644 --- a/src/main/java/com/apple/itunes/storekit/model/JWSRenewalInfoDecodedPayload.java +++ b/src/main/java/com/apple/itunes/storekit/model/JWSRenewalInfoDecodedPayload.java @@ -2,9 +2,11 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Map; import java.util.Objects; /** @@ -27,38 +29,40 @@ public class JWSRenewalInfoDecodedPayload implements DecodedSignedData { private static final String SERIALIZED_NAME_ENVIRONMENT = "environment"; 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) + @JsonProperty(SERIALIZED_NAME_EXPIRATION_INTENT) private Integer expirationIntent; - @SerializedName(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) + @JsonProperty(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) private String originalTransactionId; - @SerializedName(SERIALIZED_NAME_AUTO_RENEW_PRODUCT_ID) + @JsonProperty(SERIALIZED_NAME_AUTO_RENEW_PRODUCT_ID) private String autoRenewProductId; - @SerializedName(SERIALIZED_NAME_PRODUCT_ID) + @JsonProperty(SERIALIZED_NAME_PRODUCT_ID) private String productId; - @SerializedName(SERIALIZED_NAME_AUTO_RENEW_STATUS) + @JsonProperty(SERIALIZED_NAME_AUTO_RENEW_STATUS) private Integer autoRenewStatus; - @SerializedName(SERIALIZED_NAME_IS_IN_BILLING_RETRY_PERIOD) + @JsonProperty(SERIALIZED_NAME_IS_IN_BILLING_RETRY_PERIOD) private Boolean isInBillingRetryPeriod; - @SerializedName(SERIALIZED_NAME_PRICE_INCREASE_STATUS) + @JsonProperty(SERIALIZED_NAME_PRICE_INCREASE_STATUS) private Integer priceIncreaseStatus; - @SerializedName(SERIALIZED_NAME_GRACE_PERIOD_EXPIRES_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_GRACE_PERIOD_EXPIRES_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long gracePeriodExpiresDate; - @SerializedName(SERIALIZED_NAME_OFFER_TYPE) + @JsonProperty(SERIALIZED_NAME_OFFER_TYPE) private Integer offerType; - @SerializedName(SERIALIZED_NAME_OFFER_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_OFFER_IDENTIFIER) private String offerIdentifier; - @SerializedName(SERIALIZED_NAME_SIGNED_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_SIGNED_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long signedDate; - @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + @JsonProperty(SERIALIZED_NAME_ENVIRONMENT) private String environment; - @SerializedName(SERIALIZED_NAME_RECENT_SUBSCRIPTION_START_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_RECENT_SUBSCRIPTION_START_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long recentSubscriptionStartDate; - @SerializedName(SERIALIZED_NAME_RENEWAL_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_RENEWAL_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long renewalDate; + @JsonAnySetter + private Map unknownFields; public JWSRenewalInfoDecodedPayload() { @@ -385,6 +389,25 @@ public void setRenewalDate(Long renewalDate) { this.renewalDate = renewalDate; } + + public JWSRenewalInfoDecodedPayload unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -407,12 +430,13 @@ public boolean equals(Object o) { Objects.equals(this.signedDate, jwSRenewalInfoDecodedPayload.signedDate) && Objects.equals(this.environment, jwSRenewalInfoDecodedPayload.environment) && Objects.equals(this.recentSubscriptionStartDate, jwSRenewalInfoDecodedPayload.recentSubscriptionStartDate) && - Objects.equals(this.renewalDate, jwSRenewalInfoDecodedPayload.renewalDate); + Objects.equals(this.renewalDate, jwSRenewalInfoDecodedPayload.renewalDate) && + 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); + return Objects.hash(expirationIntent, originalTransactionId, autoRenewProductId, productId, autoRenewStatus, isInBillingRetryPeriod, priceIncreaseStatus, gracePeriodExpiresDate, offerType, offerIdentifier, signedDate, environment, recentSubscriptionStartDate, renewalDate, unknownFields); } @Override @@ -429,9 +453,10 @@ public String toString() { ", offerType=" + offerType + ", offerIdentifier='" + offerIdentifier + '\'' + ", signedDate=" + signedDate + - ", environment=" + environment + + ", environment='" + environment + '\'' + ", recentSubscriptionStartDate=" + recentSubscriptionStartDate + ", renewalDate=" + renewalDate + + ", unknownFields=" + unknownFields + '}'; } } 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 a5c4d0e6..66503a7e 100644 --- a/src/main/java/com/apple/itunes/storekit/model/JWSTransactionDecodedPayload.java +++ b/src/main/java/com/apple/itunes/storekit/model/JWSTransactionDecodedPayload.java @@ -2,9 +2,11 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Map; import java.util.Objects; import java.util.UUID; @@ -40,63 +42,65 @@ public class JWSTransactionDecodedPayload implements DecodedSignedData { private static final String SERIALIZED_NAME_PRICE = "price"; private static final String SERIALIZED_NAME_CURRENCY = "currency"; private static final String SERIALIZED_NAME_OFFER_DISCOUNT_TYPE = "offerDiscountType"; - @SerializedName(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) + @JsonProperty(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) private String originalTransactionId; - @SerializedName(SERIALIZED_NAME_TRANSACTION_ID) + @JsonProperty(SERIALIZED_NAME_TRANSACTION_ID) private String transactionId; - @SerializedName(SERIALIZED_NAME_WEB_ORDER_LINE_ITEM_ID) + @JsonProperty(SERIALIZED_NAME_WEB_ORDER_LINE_ITEM_ID) private String webOrderLineItemId; - @SerializedName(SERIALIZED_NAME_BUNDLE_ID) + @JsonProperty(SERIALIZED_NAME_BUNDLE_ID) private String bundleId; - @SerializedName(SERIALIZED_NAME_PRODUCT_ID) + @JsonProperty(SERIALIZED_NAME_PRODUCT_ID) private String productId; - @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_GROUP_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_SUBSCRIPTION_GROUP_IDENTIFIER) private String subscriptionGroupIdentifier; - @SerializedName(SERIALIZED_NAME_PURCHASE_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_PURCHASE_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long purchaseDate; - @SerializedName(SERIALIZED_NAME_ORIGINAL_PURCHASE_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_ORIGINAL_PURCHASE_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long originalPurchaseDate; - @SerializedName(SERIALIZED_NAME_EXPIRES_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_EXPIRES_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long expiresDate; - @SerializedName(SERIALIZED_NAME_QUANTITY) + @JsonProperty(SERIALIZED_NAME_QUANTITY) private Integer quantity; - @SerializedName(SERIALIZED_NAME_TYPE) + @JsonProperty(SERIALIZED_NAME_TYPE) private String type; - @SerializedName(SERIALIZED_NAME_APP_ACCOUNT_TOKEN) + @JsonProperty(SERIALIZED_NAME_APP_ACCOUNT_TOKEN) private UUID appAccountToken; - @SerializedName(SERIALIZED_NAME_IN_APP_OWNERSHIP_TYPE) + @JsonProperty(SERIALIZED_NAME_IN_APP_OWNERSHIP_TYPE) private String inAppOwnershipType; - @SerializedName(SERIALIZED_NAME_SIGNED_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_SIGNED_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long signedDate; - @SerializedName(SERIALIZED_NAME_REVOCATION_REASON) + @JsonProperty(SERIALIZED_NAME_REVOCATION_REASON) private Integer revocationReason; - @SerializedName(SERIALIZED_NAME_REVOCATION_DATE) - @JsonAdapter(XcodeCompatibleTimestampDeserializer.class) + @JsonProperty(SERIALIZED_NAME_REVOCATION_DATE) + @JsonDeserialize(using=XcodeCompatibleTimestampDeserializer.class) private Long revocationDate; - @SerializedName(SERIALIZED_NAME_IS_UPGRADED) + @JsonProperty(SERIALIZED_NAME_IS_UPGRADED) private Boolean isUpgraded; - @SerializedName(SERIALIZED_NAME_OFFER_TYPE) + @JsonProperty(SERIALIZED_NAME_OFFER_TYPE) private Integer offerType; - @SerializedName(SERIALIZED_NAME_OFFER_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_OFFER_IDENTIFIER) private String offerIdentifier; - @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + @JsonProperty(SERIALIZED_NAME_ENVIRONMENT) private String environment; - @SerializedName(SERIALIZED_NAME_STOREFRONT) + @JsonProperty(SERIALIZED_NAME_STOREFRONT) private String storefront; - @SerializedName(SERIALIZED_NAME_STOREFRONT_ID) + @JsonProperty(SERIALIZED_NAME_STOREFRONT_ID) private String storefrontId; - @SerializedName(SERIALIZED_NAME_TRANSACTION_REASON) + @JsonProperty(SERIALIZED_NAME_TRANSACTION_REASON) private String transactionReason; - @SerializedName(SERIALIZED_NAME_PRICE) + @JsonProperty(SERIALIZED_NAME_PRICE) private Integer price; - @SerializedName(SERIALIZED_NAME_CURRENCY) + @JsonProperty(SERIALIZED_NAME_CURRENCY) private String currency; - @SerializedName(SERIALIZED_NAME_OFFER_DISCOUNT_TYPE) + @JsonProperty(SERIALIZED_NAME_OFFER_DISCOUNT_TYPE) private String offerDiscountType; + @JsonAnySetter + private Map unknownFields; public JWSTransactionDecodedPayload() { @@ -673,6 +677,23 @@ public void setRawOfferDiscountType(String rawOfferDiscountType) { this.offerDiscountType = rawOfferDiscountType; } + public JWSTransactionDecodedPayload unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } @Override public boolean equals(Object o) { @@ -708,12 +729,13 @@ public boolean equals(Object o) { Objects.equals(this.transactionReason, jwSTransactionDecodedPayload.transactionReason) && Objects.equals(this.price, jwSTransactionDecodedPayload.price) && Objects.equals(this.currency, jwSTransactionDecodedPayload.currency) && - Objects.equals(this.offerDiscountType, jwSTransactionDecodedPayload.offerDiscountType); + Objects.equals(this.offerDiscountType, jwSTransactionDecodedPayload.offerDiscountType) && + Objects.equals(this.unknownFields, jwSTransactionDecodedPayload.unknownFields); } @Override public int hashCode() { - return Objects.hash(originalTransactionId, transactionId, webOrderLineItemId, bundleId, productId, subscriptionGroupIdentifier, purchaseDate, originalPurchaseDate, expiresDate, quantity, type, appAccountToken, inAppOwnershipType, signedDate, revocationReason, revocationDate, isUpgraded, offerType, offerIdentifier, environment, storefront, storefrontId, transactionReason, price, currency, offerDiscountType); + return Objects.hash(originalTransactionId, transactionId, webOrderLineItemId, bundleId, productId, subscriptionGroupIdentifier, purchaseDate, originalPurchaseDate, expiresDate, quantity, type, appAccountToken, inAppOwnershipType, signedDate, revocationReason, revocationDate, isUpgraded, offerType, offerIdentifier, environment, storefront, storefrontId, transactionReason, price, currency, offerDiscountType, unknownFields); } @Override @@ -729,22 +751,23 @@ public String toString() { ", originalPurchaseDate=" + originalPurchaseDate + ", expiresDate=" + expiresDate + ", quantity=" + quantity + - ", type=" + type + + ", type='" + type + '\'' + ", appAccountToken=" + appAccountToken + - ", inAppOwnershipType=" + inAppOwnershipType + + ", inAppOwnershipType='" + inAppOwnershipType + '\'' + ", signedDate=" + signedDate + ", revocationReason=" + revocationReason + ", revocationDate=" + revocationDate + ", isUpgraded=" + isUpgraded + ", offerType=" + offerType + ", offerIdentifier='" + offerIdentifier + '\'' + - ", environment=" + environment + + ", environment='" + environment + '\'' + ", storefront='" + storefront + '\'' + ", storefrontId='" + storefrontId + '\'' + - ", transactionReason=" + transactionReason + + ", transactionReason='" + transactionReason + '\'' + ", price=" + price + - ", currency'=" + currency + '\'' + - ", offerDiscountType=" + offerDiscountType + + ", currency='" + currency + '\'' + + ", offerDiscountType='" + offerDiscountType + '\'' + + ", unknownFields=" + unknownFields + '}'; } } 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 1517a0dd..cc2f6a16 100644 --- a/src/main/java/com/apple/itunes/storekit/model/LastTransactionsItem.java +++ b/src/main/java/com/apple/itunes/storekit/model/LastTransactionsItem.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -16,14 +18,16 @@ public class LastTransactionsItem { private static final String SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID = "originalTransactionId"; private static final String SERIALIZED_NAME_SIGNED_TRANSACTION_INFO = "signedTransactionInfo"; private static final String SERIALIZED_NAME_SIGNED_RENEWAL_INFO = "signedRenewalInfo"; - @SerializedName(SERIALIZED_NAME_STATUS) + @JsonProperty(SERIALIZED_NAME_STATUS) private Integer status; - @SerializedName(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) + @JsonProperty(SERIALIZED_NAME_ORIGINAL_TRANSACTION_ID) private String originalTransactionId; - @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO) + @JsonProperty(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO) private String signedTransactionInfo; - @SerializedName(SERIALIZED_NAME_SIGNED_RENEWAL_INFO) + @JsonProperty(SERIALIZED_NAME_SIGNED_RENEWAL_INFO) private String signedRenewalInfo; + @JsonAnySetter + private Map unknownFields; public LastTransactionsItem() { @@ -116,6 +120,24 @@ public void setSignedRenewalInfo(String signedRenewalInfo) { this.signedRenewalInfo = signedRenewalInfo; } + public LastTransactionsItem unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -128,12 +150,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, lastTransactionsItem.status) && Objects.equals(this.originalTransactionId, lastTransactionsItem.originalTransactionId) && Objects.equals(this.signedTransactionInfo, lastTransactionsItem.signedTransactionInfo) && - Objects.equals(this.signedRenewalInfo, lastTransactionsItem.signedRenewalInfo); + Objects.equals(this.signedRenewalInfo, lastTransactionsItem.signedRenewalInfo) && + Objects.equals(this.unknownFields, lastTransactionsItem.unknownFields); } @Override public int hashCode() { - return Objects.hash(status, originalTransactionId, signedTransactionInfo, signedRenewalInfo); + return Objects.hash(status, originalTransactionId, signedTransactionInfo, signedRenewalInfo, unknownFields); } @Override @@ -143,6 +166,7 @@ public String toString() { ", originalTransactionId='" + originalTransactionId + '\'' + ", signedTransactionInfo='" + signedTransactionInfo + '\'' + ", signedRenewalInfo='" + signedRenewalInfo + '\'' + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsPurchased.java b/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsPurchased.java index 672aa4d3..2ede5b3f 100644 --- a/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsPurchased.java +++ b/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsPurchased.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A value that indicates the total amount, in USD, of in-app purchases the customer has made in your app, across all platforms. * * @see lifetimeDollarsPurchased */ -@JsonAdapter(LifetimeDollarsPurchased.Adapter.class) public enum LifetimeDollarsPurchased { UNDECLARED(0), @@ -38,9 +32,10 @@ public static LifetimeDollarsPurchased fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -49,18 +44,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final LifetimeDollarsPurchased enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public LifetimeDollarsPurchased read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return LifetimeDollarsPurchased.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsRefunded.java b/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsRefunded.java index 5d5af0c2..ad62da60 100644 --- a/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsRefunded.java +++ b/src/main/java/com/apple/itunes/storekit/model/LifetimeDollarsRefunded.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A value that indicates the dollar amount of refunds the customer has received in your app, since purchasing the app, across all platforms. * * @see lifetimeDollarsRefunded */ -@JsonAdapter(LifetimeDollarsRefunded.Adapter.class) public enum LifetimeDollarsRefunded { UNDECLARED(0), @@ -38,9 +32,10 @@ public static LifetimeDollarsRefunded fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -49,18 +44,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final LifetimeDollarsRefunded enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public LifetimeDollarsRefunded read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return LifetimeDollarsRefunded.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateRequest.java b/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateRequest.java index 5f906e97..ab1be850 100644 --- a/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateRequest.java +++ b/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateRequest.java @@ -2,7 +2,7 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; @@ -19,15 +19,15 @@ public class MassExtendRenewalDateRequest { private static final String SERIALIZED_NAME_REQUEST_IDENTIFIER = "requestIdentifier"; private static final String SERIALIZED_NAME_STOREFRONT_COUNTRY_CODES = "storefrontCountryCodes"; private static final String SERIALIZED_NAME_PRODUCT_ID = "productId"; - @SerializedName(SERIALIZED_NAME_EXTEND_BY_DAYS) + @JsonProperty(SERIALIZED_NAME_EXTEND_BY_DAYS) private Integer extendByDays; - @SerializedName(SERIALIZED_NAME_EXTEND_REASON_CODE) + @JsonProperty(SERIALIZED_NAME_EXTEND_REASON_CODE) private ExtendReasonCode extendReasonCode; - @SerializedName(SERIALIZED_NAME_REQUEST_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_REQUEST_IDENTIFIER) private String requestIdentifier; - @SerializedName(SERIALIZED_NAME_STOREFRONT_COUNTRY_CODES) + @JsonProperty(SERIALIZED_NAME_STOREFRONT_COUNTRY_CODES) private List storefrontCountryCodes = null; - @SerializedName(SERIALIZED_NAME_PRODUCT_ID) + @JsonProperty(SERIALIZED_NAME_PRODUCT_ID) private String productId; diff --git a/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateResponse.java b/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateResponse.java index 32365644..ab73ef3f 100644 --- a/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateResponse.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -13,8 +15,10 @@ */ public class MassExtendRenewalDateResponse { private static final String SERIALIZED_NAME_REQUEST_IDENTIFIER = "requestIdentifier"; - @SerializedName(SERIALIZED_NAME_REQUEST_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_REQUEST_IDENTIFIER) private String requestIdentifier; + @JsonAnySetter + private Map unknownFields; public MassExtendRenewalDateResponse() { @@ -39,6 +43,25 @@ public void setRequestIdentifier(String requestIdentifier) { this.requestIdentifier = requestIdentifier; } + + public MassExtendRenewalDateResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -48,18 +71,20 @@ public boolean equals(Object o) { return false; } MassExtendRenewalDateResponse massExtendRenewalDateResponse = (MassExtendRenewalDateResponse) o; - return Objects.equals(this.requestIdentifier, massExtendRenewalDateResponse.requestIdentifier); + return Objects.equals(this.requestIdentifier, massExtendRenewalDateResponse.requestIdentifier) && + Objects.equals(this.unknownFields, massExtendRenewalDateResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(requestIdentifier); + return Objects.hash(requestIdentifier, unknownFields); } @Override public String toString() { return "MassExtendRenewalDateResponse{" + "requestIdentifier='" + requestIdentifier + '\'' + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateStatusResponse.java b/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateStatusResponse.java index db9767cf..67c105c3 100644 --- a/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateStatusResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/MassExtendRenewalDateStatusResponse.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -17,16 +19,18 @@ public class MassExtendRenewalDateStatusResponse { private static final String SERIALIZED_NAME_COMPLETE_DATE = "completeDate"; private static final String SERIALIZED_NAME_SUCCEEDED_COUNT = "succeededCount"; private static final String SERIALIZED_NAME_FAILED_COUNT = "failedCount"; - @SerializedName(SERIALIZED_NAME_REQUEST_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_REQUEST_IDENTIFIER) private String requestIdentifier; - @SerializedName(SERIALIZED_NAME_COMPLETE) + @JsonProperty(SERIALIZED_NAME_COMPLETE) private Boolean complete; - @SerializedName(SERIALIZED_NAME_COMPLETE_DATE) + @JsonProperty(SERIALIZED_NAME_COMPLETE_DATE) private Long completeDate; - @SerializedName(SERIALIZED_NAME_SUCCEEDED_COUNT) + @JsonProperty(SERIALIZED_NAME_SUCCEEDED_COUNT) private Long succeededCount; - @SerializedName(SERIALIZED_NAME_FAILED_COUNT) + @JsonProperty(SERIALIZED_NAME_FAILED_COUNT) private Long failedCount; + @JsonAnySetter + private Map unknownFields; public MassExtendRenewalDateStatusResponse() { @@ -127,6 +131,25 @@ public void setFailedCount(Long failedCount) { this.failedCount = failedCount; } + + public MassExtendRenewalDateStatusResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -140,12 +163,13 @@ public boolean equals(Object o) { Objects.equals(this.complete, massExtendRenewalDateStatusResponse.complete) && Objects.equals(this.completeDate, massExtendRenewalDateStatusResponse.completeDate) && Objects.equals(this.succeededCount, massExtendRenewalDateStatusResponse.succeededCount) && - Objects.equals(this.failedCount, massExtendRenewalDateStatusResponse.failedCount); + Objects.equals(this.failedCount, massExtendRenewalDateStatusResponse.failedCount) && + Objects.equals(this.unknownFields, massExtendRenewalDateStatusResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(requestIdentifier, complete, completeDate, succeededCount, failedCount); + return Objects.hash(requestIdentifier, complete, completeDate, succeededCount, failedCount, unknownFields); } @Override @@ -156,6 +180,7 @@ public String toString() { ", completeDate=" + completeDate + ", succeededCount=" + succeededCount + ", failedCount=" + failedCount + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryRequest.java b/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryRequest.java index d261b171..09a8faa7 100644 --- a/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryRequest.java +++ b/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryRequest.java @@ -2,7 +2,7 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Objects; @@ -18,17 +18,17 @@ public class NotificationHistoryRequest { private static final String SERIALIZED_NAME_NOTIFICATION_SUBTYPE = "notificationSubtype"; private static final String SERIALIZED_NAME_TRANSACTION_ID = "transactionId"; private static final String SERIALIZED_NAME_ONLY_FAILURES = "onlyFailures"; - @SerializedName(SERIALIZED_NAME_START_DATE) + @JsonProperty(SERIALIZED_NAME_START_DATE) private Long startDate; - @SerializedName(SERIALIZED_NAME_END_DATE) + @JsonProperty(SERIALIZED_NAME_END_DATE) private Long endDate; - @SerializedName(SERIALIZED_NAME_NOTIFICATION_TYPE) + @JsonProperty(SERIALIZED_NAME_NOTIFICATION_TYPE) private NotificationTypeV2 notificationType; - @SerializedName(SERIALIZED_NAME_NOTIFICATION_SUBTYPE) + @JsonProperty(SERIALIZED_NAME_NOTIFICATION_SUBTYPE) private Subtype notificationSubtype; - @SerializedName(SERIALIZED_NAME_TRANSACTION_ID) + @JsonProperty(SERIALIZED_NAME_TRANSACTION_ID) private String transactionId; - @SerializedName(SERIALIZED_NAME_ONLY_FAILURES) + @JsonProperty(SERIALIZED_NAME_ONLY_FAILURES) private Boolean onlyFailures; diff --git a/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponse.java b/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponse.java index f0f53ab0..4c098934 100644 --- a/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponse.java @@ -2,10 +2,12 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -17,12 +19,14 @@ public class NotificationHistoryResponse { private static final String SERIALIZED_NAME_PAGINATION_TOKEN = "paginationToken"; private static final String SERIALIZED_NAME_HAS_MORE = "hasMore"; private static final String SERIALIZED_NAME_NOTIFICATION_HISTORY = "notificationHistory"; - @SerializedName(SERIALIZED_NAME_PAGINATION_TOKEN) + @JsonProperty(SERIALIZED_NAME_PAGINATION_TOKEN) private String paginationToken; - @SerializedName(SERIALIZED_NAME_HAS_MORE) + @JsonProperty(SERIALIZED_NAME_HAS_MORE) private Boolean hasMore; - @SerializedName(SERIALIZED_NAME_NOTIFICATION_HISTORY) + @JsonProperty(SERIALIZED_NAME_NOTIFICATION_HISTORY) private List notificationHistory = null; + @JsonAnySetter + private Map unknownFields; public NotificationHistoryResponse() { @@ -92,6 +96,25 @@ public void setNotificationHistory(List notific this.notificationHistory = notificationHistory; } + + public NotificationHistoryResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -103,12 +126,13 @@ public boolean equals(Object o) { NotificationHistoryResponse notificationHistoryResponse = (NotificationHistoryResponse) o; return Objects.equals(this.paginationToken, notificationHistoryResponse.paginationToken) && Objects.equals(this.hasMore, notificationHistoryResponse.hasMore) && - Objects.equals(this.notificationHistory, notificationHistoryResponse.notificationHistory); + Objects.equals(this.notificationHistory, notificationHistoryResponse.notificationHistory) && + Objects.equals(this.unknownFields, notificationHistoryResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(paginationToken, hasMore, notificationHistory); + return Objects.hash(paginationToken, hasMore, notificationHistory, unknownFields); } @Override @@ -117,6 +141,7 @@ public String toString() { "paginationToken='" + paginationToken + '\'' + ", hasMore=" + hasMore + ", notificationHistory=" + notificationHistory + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponseItem.java b/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponseItem.java index a7f248a7..53f106ae 100644 --- a/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponseItem.java +++ b/src/main/java/com/apple/itunes/storekit/model/NotificationHistoryResponseItem.java @@ -2,9 +2,11 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -15,10 +17,12 @@ public class NotificationHistoryResponseItem { private static final String SERIALIZED_NAME_SIGNED_PAYLOAD = "signedPayload"; private static final String SERIALIZED_NAME_SEND_ATTEMPTS = "sendAttempts"; - @SerializedName(SERIALIZED_NAME_SIGNED_PAYLOAD) + @JsonProperty(SERIALIZED_NAME_SIGNED_PAYLOAD) private String signedPayload; - @SerializedName(SERIALIZED_NAME_SEND_ATTEMPTS) + @JsonProperty(SERIALIZED_NAME_SEND_ATTEMPTS) private List sendAttempts; + @JsonAnySetter + private Map unknownFields; public NotificationHistoryResponseItem() { @@ -62,6 +66,25 @@ public void setSendAttempts(List sendAttempts) { this.sendAttempts = sendAttempts; } + + public NotificationHistoryResponseItem unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -72,12 +95,13 @@ public boolean equals(Object o) { } NotificationHistoryResponseItem notificationHistoryResponseItem = (NotificationHistoryResponseItem) o; return Objects.equals(this.signedPayload, notificationHistoryResponseItem.signedPayload) && - Objects.equals(this.sendAttempts, notificationHistoryResponseItem.sendAttempts); + Objects.equals(this.sendAttempts, notificationHistoryResponseItem.sendAttempts) && + Objects.equals(this.unknownFields, notificationHistoryResponseItem.unknownFields); } @Override public int hashCode() { - return Objects.hash(signedPayload, sendAttempts); + return Objects.hash(signedPayload, sendAttempts, unknownFields); } @Override @@ -85,6 +109,7 @@ public String toString() { return "NotificationHistoryResponseItem{" + "signedPayload='" + signedPayload + '\'' + ", sendAttempts=" + sendAttempts + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/NotificationTypeV2.java b/src/main/java/com/apple/itunes/storekit/model/NotificationTypeV2.java index 31eaf324..2b030747 100644 --- a/src/main/java/com/apple/itunes/storekit/model/NotificationTypeV2.java +++ b/src/main/java/com/apple/itunes/storekit/model/NotificationTypeV2.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A notification type value that App Store Server Notifications V2 uses. * * @see notificationType */ -@JsonAdapter(NotificationTypeV2.Adapter.class) public enum NotificationTypeV2 { SUBSCRIBED("SUBSCRIBED"), @@ -47,9 +41,10 @@ public static NotificationTypeV2 fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -58,18 +53,5 @@ public String getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final NotificationTypeV2 enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public NotificationTypeV2 read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return NotificationTypeV2.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/OfferDiscountType.java b/src/main/java/com/apple/itunes/storekit/model/OfferDiscountType.java index d0c3b28e..59cc3295 100644 --- a/src/main/java/com/apple/itunes/storekit/model/OfferDiscountType.java +++ b/src/main/java/com/apple/itunes/storekit/model/OfferDiscountType.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription. * * @see offerDiscountType */ -@JsonAdapter(OfferDiscountType.Adapter.class) public enum OfferDiscountType { FREE_TRIAL("FREE_TRIAL"), @@ -33,9 +27,10 @@ public static OfferDiscountType fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -44,17 +39,4 @@ public String getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final OfferDiscountType enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public OfferDiscountType read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return OfferDiscountType.fromValue(value); - } - } } \ No newline at end of file diff --git a/src/main/java/com/apple/itunes/storekit/model/OfferType.java b/src/main/java/com/apple/itunes/storekit/model/OfferType.java index f3d6cd75..c3ee06d9 100644 --- a/src/main/java/com/apple/itunes/storekit/model/OfferType.java +++ b/src/main/java/com/apple/itunes/storekit/model/OfferType.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The type of subscription offer. * * @see offerType */ -@JsonAdapter(OfferType.Adapter.class) public enum OfferType { INTRODUCTORY_OFFER(1), @@ -33,9 +27,10 @@ public static OfferType fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -44,18 +39,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final OfferType enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public OfferType read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return OfferType.fromValue(value); - } - } } 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 d1283ad3..434b3dae 100644 --- a/src/main/java/com/apple/itunes/storekit/model/OrderLookupResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/OrderLookupResponse.java @@ -2,10 +2,12 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -16,10 +18,12 @@ public class OrderLookupResponse { private static final String SERIALIZED_NAME_STATUS = "status"; private static final String SERIALIZED_NAME_SIGNED_TRANSACTIONS = "signedTransactions"; - @SerializedName(SERIALIZED_NAME_STATUS) + @JsonProperty(SERIALIZED_NAME_STATUS) private Integer status; - @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTIONS) + @JsonProperty(SERIALIZED_NAME_SIGNED_TRANSACTIONS) private List signedTransactions = null; + @JsonAnySetter + private Map unknownFields; public OrderLookupResponse() { @@ -81,6 +85,25 @@ public void setSignedTransactions(List signedTransactions) { this.signedTransactions = signedTransactions; } + + public OrderLookupResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -91,12 +114,13 @@ public boolean equals(Object o) { } OrderLookupResponse orderLookupResponse = (OrderLookupResponse) o; return Objects.equals(this.status, orderLookupResponse.status) && - Objects.equals(this.signedTransactions, orderLookupResponse.signedTransactions); + Objects.equals(this.signedTransactions, orderLookupResponse.signedTransactions) && + Objects.equals(this.unknownFields, orderLookupResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(status, signedTransactions); + return Objects.hash(status, signedTransactions, unknownFields); } @Override @@ -104,6 +128,7 @@ public String toString() { return "OrderLookupResponse{" + "status=" + status + ", signedTransactions=" + signedTransactions + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/OrderLookupStatus.java b/src/main/java/com/apple/itunes/storekit/model/OrderLookupStatus.java index 27e4f403..e248f0d8 100644 --- a/src/main/java/com/apple/itunes/storekit/model/OrderLookupStatus.java +++ b/src/main/java/com/apple/itunes/storekit/model/OrderLookupStatus.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A value that indicates whether the order ID in the request is valid for your app. * * @see OrderLookupStatus */ -@JsonAdapter(OrderLookupStatus.Adapter.class) public enum OrderLookupStatus { VALID(0), @@ -32,9 +26,10 @@ public static OrderLookupStatus fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -43,18 +38,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final OrderLookupStatus enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public OrderLookupStatus read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return OrderLookupStatus.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/Platform.java b/src/main/java/com/apple/itunes/storekit/model/Platform.java index a8e9caaa..f6b36a5f 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Platform.java +++ b/src/main/java/com/apple/itunes/storekit/model/Platform.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The platform on which the customer consumed the in-app purchase. * * @see platform */ -@JsonAdapter(Platform.Adapter.class) public enum Platform { UNDECLARED(0), @@ -33,9 +27,10 @@ public static Platform fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -44,18 +39,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final Platform enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public Platform read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return Platform.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/PlayTime.java b/src/main/java/com/apple/itunes/storekit/model/PlayTime.java index ea8c7463..010b030a 100644 --- a/src/main/java/com/apple/itunes/storekit/model/PlayTime.java +++ b/src/main/java/com/apple/itunes/storekit/model/PlayTime.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A value that indicates the amount of time that the customer used the app. * * @see playTime */ -@JsonAdapter(PlayTime.Adapter.class) public enum PlayTime { UNDECLARED(0), @@ -38,9 +32,10 @@ public static PlayTime fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -49,18 +44,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final PlayTime enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public PlayTime read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return PlayTime.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/PriceIncreaseStatus.java b/src/main/java/com/apple/itunes/storekit/model/PriceIncreaseStatus.java index fcc0115e..9edee6e9 100644 --- a/src/main/java/com/apple/itunes/storekit/model/PriceIncreaseStatus.java +++ b/src/main/java/com/apple/itunes/storekit/model/PriceIncreaseStatus.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The status that indicates whether an auto-renewable subscription is subject to a price increase. * * @see priceIncreaseStatus */ -@JsonAdapter(PriceIncreaseStatus.Adapter.class) public enum PriceIncreaseStatus { CUSTOMER_HAS_NOT_RESPONDED(0), @@ -32,9 +26,10 @@ public static PriceIncreaseStatus fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -43,18 +38,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final PriceIncreaseStatus enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public PriceIncreaseStatus read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return PriceIncreaseStatus.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/RefundHistoryResponse.java b/src/main/java/com/apple/itunes/storekit/model/RefundHistoryResponse.java index babf04ce..807502a6 100644 --- a/src/main/java/com/apple/itunes/storekit/model/RefundHistoryResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/RefundHistoryResponse.java @@ -2,10 +2,12 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -17,12 +19,14 @@ public class RefundHistoryResponse { private static final String SERIALIZED_NAME_SIGNED_TRANSACTIONS = "signedTransactions"; private static final String SERIALIZED_NAME_REVISION = "revision"; private static final String SERIALIZED_NAME_HAS_MORE = "hasMore"; - @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTIONS) + @JsonProperty(SERIALIZED_NAME_SIGNED_TRANSACTIONS) private List signedTransactions = null; - @SerializedName(SERIALIZED_NAME_REVISION) + @JsonProperty(SERIALIZED_NAME_REVISION) private String revision; - @SerializedName(SERIALIZED_NAME_HAS_MORE) + @JsonProperty(SERIALIZED_NAME_HAS_MORE) private Boolean hasMore; + @JsonAnySetter + private Map unknownFields; public RefundHistoryResponse() { } @@ -91,6 +95,25 @@ public void setHasMore(Boolean hasMore) { this.hasMore = hasMore; } + + public RefundHistoryResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -102,12 +125,13 @@ public boolean equals(Object o) { RefundHistoryResponse refundHistoryResponse = (RefundHistoryResponse) o; return Objects.equals(this.signedTransactions, refundHistoryResponse.signedTransactions) && Objects.equals(this.revision, refundHistoryResponse.revision) && - Objects.equals(this.hasMore, refundHistoryResponse.hasMore); + Objects.equals(this.hasMore, refundHistoryResponse.hasMore) && + Objects.equals(this.unknownFields, refundHistoryResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(signedTransactions, revision, hasMore); + return Objects.hash(signedTransactions, revision, hasMore, unknownFields); } @Override @@ -116,6 +140,7 @@ public String toString() { "signedTransactions=" + signedTransactions + ", revision='" + revision + '\'' + ", hasMore=" + hasMore + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2.java b/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2.java index 427f6430..81fdfc16 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2.java +++ b/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -13,8 +15,10 @@ */ public class ResponseBodyV2 { private static final String SERIALIZED_NAME_SIGNED_PAYLOAD = "signedPayload"; - @SerializedName(SERIALIZED_NAME_SIGNED_PAYLOAD) + @JsonProperty(SERIALIZED_NAME_SIGNED_PAYLOAD) private String signedPayload; + @JsonAnySetter + private Map unknownFields; public ResponseBodyV2() { @@ -39,6 +43,25 @@ public void setSignedPayload(String signedPayload) { this.signedPayload = signedPayload; } + + public ResponseBodyV2 unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -48,18 +71,20 @@ public boolean equals(Object o) { return false; } ResponseBodyV2 responseBodyV2 = (ResponseBodyV2) o; - return Objects.equals(this.signedPayload, responseBodyV2.signedPayload); + return Objects.equals(this.signedPayload, responseBodyV2.signedPayload) && + Objects.equals(this.unknownFields, responseBodyV2.unknownFields); } @Override public int hashCode() { - return Objects.hash(signedPayload); + return Objects.hash(signedPayload, unknownFields); } @Override public String toString() { return "ResponseBodyV2{" + "signedPayload='" + signedPayload + '\'' + + ", unknownFields=" + unknownFields + '}'; } } 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 ef5bde10..6cf9ae1b 100644 --- a/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2DecodedPayload.java +++ b/src/main/java/com/apple/itunes/storekit/model/ResponseBodyV2DecodedPayload.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -19,20 +21,22 @@ public class ResponseBodyV2DecodedPayload implements DecodedSignedData { private static final String SERIALIZED_NAME_VERSION = "version"; private static final String SERIALIZED_NAME_SIGNED_DATE = "signedDate"; private static final String SERIALIZED_NAME_SUMMARY = "summary"; - @SerializedName(SERIALIZED_NAME_NOTIFICATION_TYPE) + @JsonProperty(SERIALIZED_NAME_NOTIFICATION_TYPE) private String notificationType; - @SerializedName(SERIALIZED_NAME_SUBTYPE) + @JsonProperty(SERIALIZED_NAME_SUBTYPE) private String subtype; - @SerializedName(SERIALIZED_NAME_NOTIFICATION_U_U_I_D) + @JsonProperty(SERIALIZED_NAME_NOTIFICATION_U_U_I_D) private String notificationUUID; - @SerializedName(SERIALIZED_NAME_DATA) + @JsonProperty(SERIALIZED_NAME_DATA) private Data data; - @SerializedName(SERIALIZED_NAME_VERSION) + @JsonProperty(SERIALIZED_NAME_VERSION) private String version; - @SerializedName(SERIALIZED_NAME_SIGNED_DATE) + @JsonProperty(SERIALIZED_NAME_SIGNED_DATE) private Long signedDate; - @SerializedName(SERIALIZED_NAME_SUMMARY) + @JsonProperty(SERIALIZED_NAME_SUMMARY) private Summary summary; + @JsonAnySetter + private Map unknownFields; public ResponseBodyV2DecodedPayload() { @@ -195,6 +199,25 @@ public void setSummary(Summary summary) { this.summary = summary; } + + public ResponseBodyV2DecodedPayload unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -210,24 +233,26 @@ public boolean equals(Object o) { Objects.equals(this.data, responseBodyV2DecodedPayload.data) && Objects.equals(this.version, responseBodyV2DecodedPayload.version) && Objects.equals(this.signedDate, responseBodyV2DecodedPayload.signedDate) && - Objects.equals(this.summary, responseBodyV2DecodedPayload.summary); + Objects.equals(this.summary, responseBodyV2DecodedPayload.summary) && + Objects.equals(this.unknownFields, responseBodyV2DecodedPayload.unknownFields); } @Override public int hashCode() { - return Objects.hash(notificationType, subtype, notificationUUID, data, version, signedDate, summary); + return Objects.hash(notificationType, subtype, notificationUUID, data, version, signedDate, summary, unknownFields); } @Override public String toString() { return "ResponseBodyV2DecodedPayload{" + - "notificationType=" + notificationType + - ", subtype=" + subtype + + "notificationType='" + notificationType + '\'' + + ", subtype='" + subtype + '\'' + ", notificationUUID='" + notificationUUID + '\'' + ", data=" + data + ", version='" + version + '\'' + ", signedDate=" + signedDate + ", summary=" + summary + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/RevocationReason.java b/src/main/java/com/apple/itunes/storekit/model/RevocationReason.java index f5a5ad22..92b3b40f 100644 --- a/src/main/java/com/apple/itunes/storekit/model/RevocationReason.java +++ b/src/main/java/com/apple/itunes/storekit/model/RevocationReason.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The reason for a refunded transaction. * * @see revocationReason */ -@JsonAdapter(RevocationReason.Adapter.class) public enum RevocationReason { REFUNDED_DUE_TO_ISSUE(1), @@ -32,9 +26,10 @@ public static RevocationReason fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -43,18 +38,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final RevocationReason enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public RevocationReason read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return RevocationReason.fromValue(value); - } - } } 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 d60b5270..ec070181 100644 --- a/src/main/java/com/apple/itunes/storekit/model/SendAttemptItem.java +++ b/src/main/java/com/apple/itunes/storekit/model/SendAttemptItem.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -14,10 +16,12 @@ public class SendAttemptItem { private static final String SERIALIZED_NAME_ATTEMPT_DATE = "attemptDate"; private static final String SERIALIZED_NAME_SEND_ATTEMPT_RESULT = "sendAttemptResult"; - @SerializedName(SERIALIZED_NAME_ATTEMPT_DATE) + @JsonProperty(SERIALIZED_NAME_ATTEMPT_DATE) private Long attemptDate; - @SerializedName(SERIALIZED_NAME_SEND_ATTEMPT_RESULT) + @JsonProperty(SERIALIZED_NAME_SEND_ATTEMPT_RESULT) private String sendAttemptResult; + @JsonAnySetter + private Map unknownFields; public SendAttemptItem() { } @@ -71,6 +75,25 @@ public void setRawSendAttemptResult(String rawSendAttemptResult) { this.sendAttemptResult = rawSendAttemptResult; } + + public SendAttemptItem unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -81,19 +104,21 @@ public boolean equals(Object o) { } SendAttemptItem sendAttemptItem = (SendAttemptItem) o; return Objects.equals(this.attemptDate, sendAttemptItem.attemptDate) && - Objects.equals(this.sendAttemptResult, sendAttemptItem.sendAttemptResult); + Objects.equals(this.sendAttemptResult, sendAttemptItem.sendAttemptResult) && + Objects.equals(this.unknownFields, sendAttemptItem.unknownFields); } @Override public int hashCode() { - return Objects.hash(attemptDate, sendAttemptResult); + return Objects.hash(attemptDate, sendAttemptResult, unknownFields); } @Override public String toString() { - return "TransactionInfoResponse{" + + return "SendAttemptItem{" + "attemptDate=" + attemptDate + - ", sendAttemptResult=" + sendAttemptResult + + ", sendAttemptResult='" + sendAttemptResult + '\'' + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/SendAttemptResult.java b/src/main/java/com/apple/itunes/storekit/model/SendAttemptResult.java index 839c6501..a01a0d3f 100644 --- a/src/main/java/com/apple/itunes/storekit/model/SendAttemptResult.java +++ b/src/main/java/com/apple/itunes/storekit/model/SendAttemptResult.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The success or error information the App Store server records when it attempts to send an App Store server notification to your server. * * @see sendAttemptResult */ -@JsonAdapter(SendAttemptResult.Adapter.class) public enum SendAttemptResult { SUCCESS("SUCCESS"), @@ -41,9 +35,10 @@ public static SendAttemptResult fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -52,18 +47,5 @@ public String getValue() { public String toString() { return value; } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final SendAttemptResult enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public SendAttemptResult read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return SendAttemptResult.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/SendTestNotificationResponse.java b/src/main/java/com/apple/itunes/storekit/model/SendTestNotificationResponse.java index 37e77fcc..a9f2d320 100644 --- a/src/main/java/com/apple/itunes/storekit/model/SendTestNotificationResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/SendTestNotificationResponse.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -13,8 +15,10 @@ */ public class SendTestNotificationResponse { private static final String SERIALIZED_NAME_TEST_NOTIFICATION_TOKEN = "testNotificationToken"; - @SerializedName(SERIALIZED_NAME_TEST_NOTIFICATION_TOKEN) + @JsonProperty(SERIALIZED_NAME_TEST_NOTIFICATION_TOKEN) private String testNotificationToken; + @JsonAnySetter + private Map unknownFields; public SendTestNotificationResponse() { @@ -39,6 +43,25 @@ public void setTestNotificationToken(String testNotificationToken) { this.testNotificationToken = testNotificationToken; } + + public SendTestNotificationResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -48,18 +71,20 @@ public boolean equals(Object o) { return false; } SendTestNotificationResponse sendTestNotificationResponse = (SendTestNotificationResponse) o; - return Objects.equals(this.testNotificationToken, sendTestNotificationResponse.testNotificationToken); + return Objects.equals(this.testNotificationToken, sendTestNotificationResponse.testNotificationToken) && + Objects.equals(this.unknownFields, sendTestNotificationResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(testNotificationToken); + return Objects.hash(testNotificationToken, unknownFields); } @Override public String toString() { return "SendTestNotificationResponse{" + "testNotificationToken='" + testNotificationToken + '\'' + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/Status.java b/src/main/java/com/apple/itunes/storekit/model/Status.java index db5e5f25..9879984b 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Status.java +++ b/src/main/java/com/apple/itunes/storekit/model/Status.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The status of an auto-renewable subscription. * * @see status */ -@JsonAdapter(Status.Adapter.class) public enum Status { ACTIVE(1), @@ -35,9 +29,10 @@ public static Status fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -46,18 +41,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final Status enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public Status read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return Status.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/StatusResponse.java b/src/main/java/com/apple/itunes/storekit/model/StatusResponse.java index 00cce787..c00e2d01 100644 --- a/src/main/java/com/apple/itunes/storekit/model/StatusResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/StatusResponse.java @@ -2,10 +2,12 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -18,14 +20,16 @@ public class StatusResponse { private static final String SERIALIZED_NAME_BUNDLE_ID = "bundleId"; private static final String SERIALIZED_NAME_APP_APPLE_ID = "appAppleId"; private static final String SERIALIZED_NAME_DATA = "data"; - @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + @JsonProperty(SERIALIZED_NAME_ENVIRONMENT) private String environment; - @SerializedName(SERIALIZED_NAME_BUNDLE_ID) + @JsonProperty(SERIALIZED_NAME_BUNDLE_ID) private String bundleId; - @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) + @JsonProperty(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; - @SerializedName(SERIALIZED_NAME_DATA) + @JsonProperty(SERIALIZED_NAME_DATA) private List data = null; + @JsonAnySetter + private Map unknownFields; public StatusResponse() { @@ -125,6 +129,25 @@ public void setData(List data) { this.data = data; } + + public StatusResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -137,21 +160,23 @@ public boolean equals(Object o) { return Objects.equals(this.environment, statusResponse.environment) && Objects.equals(this.bundleId, statusResponse.bundleId) && Objects.equals(this.appAppleId, statusResponse.appAppleId) && - Objects.equals(this.data, statusResponse.data); + Objects.equals(this.data, statusResponse.data) && + Objects.equals(this.unknownFields, statusResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(environment, bundleId, appAppleId, data); + return Objects.hash(environment, bundleId, appAppleId, data, unknownFields); } @Override public String toString() { return "StatusResponse{" + - "environment=" + environment + + "environment='" + environment + '\'' + ", bundleId='" + bundleId + '\'' + ", appAppleId=" + appAppleId + ", data=" + data + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/SubscriptionGroupIdentifierItem.java b/src/main/java/com/apple/itunes/storekit/model/SubscriptionGroupIdentifierItem.java index d83a2eb7..de8e46e0 100644 --- a/src/main/java/com/apple/itunes/storekit/model/SubscriptionGroupIdentifierItem.java +++ b/src/main/java/com/apple/itunes/storekit/model/SubscriptionGroupIdentifierItem.java @@ -2,10 +2,12 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -16,10 +18,12 @@ public class SubscriptionGroupIdentifierItem { private static final String SERIALIZED_NAME_SUBSCRIPTION_GROUP_IDENTIFIER = "subscriptionGroupIdentifier"; private static final String SERIALIZED_NAME_LAST_TRANSACTIONS = "lastTransactions"; - @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_GROUP_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_SUBSCRIPTION_GROUP_IDENTIFIER) private String subscriptionGroupIdentifier; - @SerializedName(SERIALIZED_NAME_LAST_TRANSACTIONS) + @JsonProperty(SERIALIZED_NAME_LAST_TRANSACTIONS) private List lastTransactions = null; + @JsonAnySetter + private Map unknownFields; public SubscriptionGroupIdentifierItem() { @@ -70,6 +74,25 @@ public void setLastTransactions(List lastTransactions) { this.lastTransactions = lastTransactions; } + + public SubscriptionGroupIdentifierItem unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -80,12 +103,13 @@ public boolean equals(Object o) { } SubscriptionGroupIdentifierItem subscriptionGroupIdentifierItem = (SubscriptionGroupIdentifierItem) o; return Objects.equals(this.subscriptionGroupIdentifier, subscriptionGroupIdentifierItem.subscriptionGroupIdentifier) && - Objects.equals(this.lastTransactions, subscriptionGroupIdentifierItem.lastTransactions); + Objects.equals(this.lastTransactions, subscriptionGroupIdentifierItem.lastTransactions) && + Objects.equals(this.unknownFields, subscriptionGroupIdentifierItem.unknownFields); } @Override public int hashCode() { - return Objects.hash(subscriptionGroupIdentifier, lastTransactions); + return Objects.hash(subscriptionGroupIdentifier, lastTransactions, unknownFields); } @Override @@ -93,6 +117,7 @@ public String toString() { return "SubscriptionGroupIdentifierItem{" + "subscriptionGroupIdentifier='" + subscriptionGroupIdentifier + '\'' + ", lastTransactions=" + lastTransactions + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/Subtype.java b/src/main/java/com/apple/itunes/storekit/model/Subtype.java index d84090ce..7c0ec447 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Subtype.java +++ b/src/main/java/com/apple/itunes/storekit/model/Subtype.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * A notification subtype value that App Store Server Notifications 2 uses. * * @see notificationSubtype */ -@JsonAdapter(Subtype.Adapter.class) public enum Subtype { INITIAL_BUY("INITIAL_BUY"), @@ -46,9 +40,10 @@ public static Subtype fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -57,18 +52,5 @@ public String getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final Subtype enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public Subtype read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return Subtype.fromValue(value); - } - } } 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 dfd41596..77b259ed 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Summary.java +++ b/src/main/java/com/apple/itunes/storekit/model/Summary.java @@ -2,10 +2,12 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -22,22 +24,24 @@ public class Summary { private static final String SERIALIZED_NAME_STOREFRONT_COUNTRY_CODES = "storefrontCountryCodes"; private static final String SERIALIZED_NAME_SUCCEEDED_COUNT = "succeededCount"; private static final String SERIALIZED_NAME_FAILED_COUNT = "failedCount"; - @SerializedName(SERIALIZED_NAME_ENVIRONMENT) + @JsonProperty(SERIALIZED_NAME_ENVIRONMENT) private String environment; - @SerializedName(SERIALIZED_NAME_APP_APPLE_ID) + @JsonProperty(SERIALIZED_NAME_APP_APPLE_ID) private Long appAppleId; - @SerializedName(SERIALIZED_NAME_BUNDLE_ID) + @JsonProperty(SERIALIZED_NAME_BUNDLE_ID) private String bundleId; - @SerializedName(SERIALIZED_NAME_PRODUCT_ID) + @JsonProperty(SERIALIZED_NAME_PRODUCT_ID) private String productId; - @SerializedName(SERIALIZED_NAME_REQUEST_IDENTIFIER) + @JsonProperty(SERIALIZED_NAME_REQUEST_IDENTIFIER) private String requestIdentifier; - @SerializedName(SERIALIZED_NAME_STOREFRONT_COUNTRY_CODES) + @JsonProperty(SERIALIZED_NAME_STOREFRONT_COUNTRY_CODES) private List storefrontCountryCodes; - @SerializedName(SERIALIZED_NAME_SUCCEEDED_COUNT) + @JsonProperty(SERIALIZED_NAME_SUCCEEDED_COUNT) private Long succeededCount; - @SerializedName(SERIALIZED_NAME_FAILED_COUNT) + @JsonProperty(SERIALIZED_NAME_FAILED_COUNT) private Long failedCount; + @JsonAnySetter + private Map unknownFields; public Summary() { @@ -214,6 +218,25 @@ public void setFailedCount(Long failedCount) { this.failedCount = failedCount; } + + public Summary unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -230,18 +253,19 @@ public boolean equals(Object o) { Objects.equals(this.requestIdentifier, summary.requestIdentifier) && Objects.equals(this.storefrontCountryCodes, summary.storefrontCountryCodes) && Objects.equals(this.succeededCount, summary.succeededCount) && - Objects.equals(this.failedCount, summary.failedCount); + Objects.equals(this.failedCount, summary.failedCount) && + Objects.equals(this.unknownFields, summary.unknownFields); } @Override public int hashCode() { - return Objects.hash(environment, appAppleId, bundleId, productId, requestIdentifier, storefrontCountryCodes, succeededCount, failedCount); + return Objects.hash(environment, appAppleId, bundleId, productId, requestIdentifier, storefrontCountryCodes, succeededCount, failedCount, unknownFields); } @Override public String toString() { return "Summary{" + - "environment=" + environment + + "environment='" + environment + '\'' + ", appAppleId=" + appAppleId + ", bundleId='" + bundleId + '\'' + ", productId='" + productId + '\'' + @@ -249,6 +273,7 @@ public String toString() { ", storefrontCountryCodes=" + storefrontCountryCodes + ", succeededCount=" + succeededCount + ", failedCount=" + failedCount + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/TransactionInfoResponse.java b/src/main/java/com/apple/itunes/storekit/model/TransactionInfoResponse.java index 2420489b..91c76bf2 100644 --- a/src/main/java/com/apple/itunes/storekit/model/TransactionInfoResponse.java +++ b/src/main/java/com/apple/itunes/storekit/model/TransactionInfoResponse.java @@ -2,8 +2,10 @@ package com.apple.itunes.storekit.model; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; import java.util.Objects; /** @@ -13,8 +15,10 @@ */ public class TransactionInfoResponse { private static final String SERIALIZED_NAME_SIGNED_TRANSACTION_INFO = "signedTransactionInfo"; - @SerializedName(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO) + @JsonProperty(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO) private String signedTransactionInfo; + @JsonAnySetter + private Map unknownFields; public TransactionInfoResponse() { @@ -39,6 +43,25 @@ public void setSignedTransactionInfo(String signedTransactionInfo) { this.signedTransactionInfo = signedTransactionInfo; } + + public TransactionInfoResponse unknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + return this; + } + + /** + Fields that are not recognized for this object + + @return A map of JSON keys to objects + */ + public Map getUnknownFields() { + return unknownFields; + } + + public void setUnknownFields(Map unknownFields) { + this.unknownFields = unknownFields; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -48,18 +71,20 @@ public boolean equals(Object o) { return false; } TransactionInfoResponse transactionInfoResponse = (TransactionInfoResponse) o; - return Objects.equals(this.signedTransactionInfo, transactionInfoResponse.signedTransactionInfo); + return Objects.equals(this.signedTransactionInfo, transactionInfoResponse.signedTransactionInfo) && + Objects.equals(this.unknownFields, transactionInfoResponse.unknownFields); } @Override public int hashCode() { - return Objects.hash(signedTransactionInfo); + return Objects.hash(signedTransactionInfo, unknownFields); } @Override public String toString() { return "TransactionInfoResponse{" + "signedTransactionInfo='" + signedTransactionInfo + '\'' + + ", unknownFields=" + unknownFields + '}'; } } diff --git a/src/main/java/com/apple/itunes/storekit/model/TransactionReason.java b/src/main/java/com/apple/itunes/storekit/model/TransactionReason.java index 86365764..1d3e57d3 100644 --- a/src/main/java/com/apple/itunes/storekit/model/TransactionReason.java +++ b/src/main/java/com/apple/itunes/storekit/model/TransactionReason.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The cause of a purchase transaction, which indicates whether it’s a customer’s purchase or a renewal for an auto-renewable subscription that the system initiates. * * @see transactionReason */ -@JsonAdapter(TransactionReason.Adapter.class) public enum TransactionReason { PURCHASE("PURCHASE"), @@ -32,9 +26,10 @@ public static TransactionReason fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -43,18 +38,5 @@ public String getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TransactionReason enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TransactionReason read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TransactionReason.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/Type.java b/src/main/java/com/apple/itunes/storekit/model/Type.java index 05fdf843..c37046ea 100644 --- a/src/main/java/com/apple/itunes/storekit/model/Type.java +++ b/src/main/java/com/apple/itunes/storekit/model/Type.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The type of in-app purchase products you can offer in your app. * * @see type */ -@JsonAdapter(Type.Adapter.class) public enum Type { AUTO_RENEWABLE_SUBSCRIPTION("Auto-Renewable Subscription"), @@ -34,9 +28,10 @@ public static Type fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public String getValue() { return value; } @@ -45,18 +40,5 @@ public String getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final Type enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public Type read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return Type.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/UserStatus.java b/src/main/java/com/apple/itunes/storekit/model/UserStatus.java index d36546b5..3fa784dd 100644 --- a/src/main/java/com/apple/itunes/storekit/model/UserStatus.java +++ b/src/main/java/com/apple/itunes/storekit/model/UserStatus.java @@ -2,19 +2,13 @@ package com.apple.itunes.storekit.model; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonValue; /** * The status of a customer’s account within your app. * * @see userStatus */ -@JsonAdapter(UserStatus.Adapter.class) public enum UserStatus { UNDECLARED(0), @@ -35,9 +29,10 @@ public static UserStatus fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } + @JsonValue public Integer getValue() { return value; } @@ -46,18 +41,5 @@ public Integer getValue() { public String toString() { return String.valueOf(value); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final UserStatus enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public UserStatus read(final JsonReader jsonReader) throws IOException { - Integer value = jsonReader.nextInt(); - return UserStatus.fromValue(value); - } - } } diff --git a/src/main/java/com/apple/itunes/storekit/model/XcodeCompatibleTimestampDeserializer.java b/src/main/java/com/apple/itunes/storekit/model/XcodeCompatibleTimestampDeserializer.java index ced0186b..1cf8bf39 100644 --- a/src/main/java/com/apple/itunes/storekit/model/XcodeCompatibleTimestampDeserializer.java +++ b/src/main/java/com/apple/itunes/storekit/model/XcodeCompatibleTimestampDeserializer.java @@ -2,19 +2,20 @@ package com.apple.itunes.storekit.model; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; -import java.lang.reflect.Type; +import java.io.IOException; /** * Xcode may sometimes return timestamps as floating point numbers not integers. This class allows parsing those receipts */ -class XcodeCompatibleTimestampDeserializer implements JsonDeserializer { +class XcodeCompatibleTimestampDeserializer extends JsonDeserializer { + @Override - public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - return json.getAsJsonPrimitive().getAsNumber().longValue(); + public Long deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException { + return p.getLongValue(); } } diff --git a/src/main/java/com/apple/itunes/storekit/verification/SignedDataVerifier.java b/src/main/java/com/apple/itunes/storekit/verification/SignedDataVerifier.java index a992995b..95263bcb 100644 --- a/src/main/java/com/apple/itunes/storekit/verification/SignedDataVerifier.java +++ b/src/main/java/com/apple/itunes/storekit/verification/SignedDataVerifier.java @@ -11,7 +11,9 @@ import com.auth0.jwt.JWT; import com.auth0.jwt.algorithms.Algorithm; import com.auth0.jwt.interfaces.DecodedJWT; -import com.google.gson.Gson; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.InputStream; import java.security.PublicKey; @@ -30,7 +32,7 @@ public class SignedDataVerifier { private final Environment environment; private final ChainVerifier chainVerifier; private final boolean enableOnlineChecks; - private final Gson gson; + private final ObjectMapper objectMapper; /** * @@ -46,7 +48,13 @@ public SignedDataVerifier(Set rootCertificates, String bundleId, Lo this.environment = environment; this.chainVerifier = new ChainVerifier(rootCertificates); this.enableOnlineChecks = enableOnlineChecks; - this.gson = new Gson(); + this.objectMapper = new ObjectMapper(); + objectMapper.setVisibility(objectMapper.getSerializationConfig().getDefaultVisibilityChecker() + .withFieldVisibility(JsonAutoDetect.Visibility.ANY) + .withGetterVisibility(JsonAutoDetect.Visibility.NONE) + .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE) + .withSetterVisibility(JsonAutoDetect.Visibility.NONE) + .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); } /** @@ -149,8 +157,12 @@ protected T decodeSignedObject(String signedObject } } - protected T parseJWTPayload(Class clazz, DecodedJWT jwt) { + protected T parseJWTPayload(Class clazz, DecodedJWT jwt) throws VerificationException { String payload = new String(Base64.getUrlDecoder().decode(jwt.getPayload())); - return gson.fromJson(payload, clazz); + try { + return objectMapper.readValue(payload, clazz); + } catch (JsonProcessingException e) { + throw new VerificationException(Status.VERIFICATION_FAILURE, e); + } } } diff --git a/src/test/java/com/apple/itunes/storekit/client/AppStoreServerAPIClientTest.java b/src/test/java/com/apple/itunes/storekit/client/AppStoreServerAPIClientTest.java index 4f71772a..50172970 100644 --- a/src/test/java/com/apple/itunes/storekit/client/AppStoreServerAPIClientTest.java +++ b/src/test/java/com/apple/itunes/storekit/client/AppStoreServerAPIClientTest.java @@ -41,7 +41,8 @@ import com.apple.itunes.storekit.util.TestingUtility; import com.auth0.jwt.JWT; import com.auth0.jwt.interfaces.DecodedJWT; -import com.google.gson.Gson; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import okhttp3.MediaType; import okhttp3.Protocol; import okhttp3.Request; @@ -77,7 +78,12 @@ public void testExtendRenewalDateForAllActiveSubscribers() throws IOException, A } catch (IOException e) { throw new RuntimeException(e); } - Map root = new Gson().fromJson(buffer.readUtf8(), Map.class); + Map root = null; + try { + root = new ObjectMapper().readValue(buffer.readUtf8(), Map.class); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } Assertions.assertEquals(45, ((Number) root.get("extendByDays")).intValue()); Assertions.assertEquals(1, ((Number) root.get("extendReasonCode")).intValue()); Assertions.assertEquals("fdf964a4-233b-486c-aac1-97d8d52688ac", root.get("requestIdentifier")); @@ -112,7 +118,12 @@ public void testExtendSubscriptionRenewalDate() throws IOException, APIException } catch (IOException e) { throw new RuntimeException(e); } - Map root = new Gson().fromJson(buffer.readUtf8(), Map.class); + Map root = null; + try { + root = new ObjectMapper().readValue(buffer.readUtf8(), Map.class); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } Assertions.assertEquals(45, ((Number) root.get("extendByDays")).intValue()); Assertions.assertEquals(1, ((Number) root.get("extendReasonCode")).intValue()); Assertions.assertEquals("fdf964a4-233b-486c-aac1-97d8d52688ac", root.get("requestIdentifier")); @@ -248,7 +259,12 @@ public void testGetNotificationHistory() throws APIException, IOException { } catch (IOException e) { throw new RuntimeException(e); } - Map root = new Gson().fromJson(buffer.readUtf8(), Map.class); + Map root = null; + try { + root = new ObjectMapper().readValue(buffer.readUtf8(), Map.class); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } Assertions.assertEquals(1698148900000L, ((Number) root.get("startDate")).longValue()); Assertions.assertEquals(1698148950000L, ((Number) root.get("endDate")).longValue()); Assertions.assertEquals("SUBSCRIBED", root.get("notificationType")); @@ -396,7 +412,12 @@ public void testSendConsumptionData() throws APIException, IOException { } catch (IOException e) { throw new RuntimeException(e); } - Map root = new Gson().fromJson(buffer.readUtf8(), Map.class); + Map root = null; + try { + root = new ObjectMapper().readValue(buffer.readUtf8(), Map.class); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } Assertions.assertTrue((Boolean) root.get("customerConsented")); Assertions.assertEquals(1, ((Number) root.get("consumptionStatus")).intValue()); Assertions.assertEquals(2, ((Number) root.get("platform")).intValue()); @@ -451,7 +472,7 @@ public void testAPIError() throws IOException { try { client.getTransactionInfo("1234"); } catch (APIException e) { - Assertions.assertEquals(500 , e.getHttpStatusCode()); + Assertions.assertEquals(500, e.getHttpStatusCode()); Assertions.assertEquals(APIError.GENERAL_INTERNAL, e.getApiError()); Assertions.assertEquals(5000000L, e.getRawApiError()); return; @@ -466,7 +487,7 @@ public void testAPITooManyRequests() throws IOException { try { client.getTransactionInfo("1234"); } catch (APIException e) { - Assertions.assertEquals(429 , e.getHttpStatusCode()); + Assertions.assertEquals(429, e.getHttpStatusCode()); Assertions.assertEquals(APIError.RATE_LIMIT_EXCEEDED, e.getApiError()); Assertions.assertEquals(4290000L, e.getRawApiError()); return; @@ -481,7 +502,7 @@ public void testAPIUnknownError() throws IOException { try { client.getTransactionInfo("1234"); } catch (APIException e) { - Assertions.assertEquals(400 , e.getHttpStatusCode()); + Assertions.assertEquals(400, e.getHttpStatusCode()); Assertions.assertNull(e.getApiError()); Assertions.assertEquals(9990000L, e.getRawApiError()); return; @@ -489,6 +510,50 @@ public void testAPIUnknownError() throws IOException { Assertions.fail(); } + @Test + public void testDecodingWithUnknownEnumValue() throws IOException, APIException { + String body = TestingUtility.readFile("models/transactionHistoryResponseWithMalformedEnvironment.json"); + AppStoreServerAPIClient client = getAppStoreServerAPIClient(body, request -> {}, 200); + + TransactionHistoryRequest request = new TransactionHistoryRequest() + .sort(TransactionHistoryRequest.Order.ASCENDING) + .productTypes(List.of(TransactionHistoryRequest.ProductType.CONSUMABLE, TransactionHistoryRequest.ProductType.AUTO_RENEWABLE)) + .endDate(123456L) + .startDate(123455L) + .revoked(false) + .inAppOwnershipType(InAppOwnershipType.FAMILY_SHARED) + .productIds(List.of("com.example.1", "com.example.2")) + .subscriptionGroupIdentifiers(List.of("sub_group_id", "sub_group_id_2")); + + HistoryResponse historyResponse = client.getTransactionHistory("1234", "revision_input", request); + + Assertions.assertNull(historyResponse.getEnvironment()); + Assertions.assertEquals("LocalTestingxxx", historyResponse.getRawEnvironment()); + } + + @Test + public void testDecodingWithMalformedJson() throws IOException { + String body = TestingUtility.readFile("models/transactionHistoryResponseWithMalformedAppAppleId.json"); + AppStoreServerAPIClient client = getAppStoreServerAPIClient(body, request -> {}, 200); + + TransactionHistoryRequest request = new TransactionHistoryRequest() + .sort(TransactionHistoryRequest.Order.ASCENDING) + .productTypes(List.of(TransactionHistoryRequest.ProductType.CONSUMABLE, TransactionHistoryRequest.ProductType.AUTO_RENEWABLE)) + .endDate(123456L) + .startDate(123455L) + .revoked(false) + .inAppOwnershipType(InAppOwnershipType.FAMILY_SHARED) + .productIds(List.of("com.example.1", "com.example.2")) + .subscriptionGroupIdentifiers(List.of("sub_group_id", "sub_group_id_2")); + + try { + client.getTransactionHistory("1234", "revision_input", request); + } catch (APIException e) { + return; + } + Assertions.fail(); + } + public AppStoreServerAPIClient getClientWithBody(String path, Consumer requestVerifier) throws IOException { String body = TestingUtility.readFile(path); return getAppStoreServerAPIClient(body, requestVerifier); diff --git a/src/test/java/com/apple/itunes/storekit/model/AppTransactionTest.java b/src/test/java/com/apple/itunes/storekit/model/AppTransactionTest.java index 760a2ec7..3cd0d05d 100644 --- a/src/test/java/com/apple/itunes/storekit/model/AppTransactionTest.java +++ b/src/test/java/com/apple/itunes/storekit/model/AppTransactionTest.java @@ -11,7 +11,6 @@ import java.io.IOException; import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; import java.util.UUID; public class AppTransactionTest { @@ -27,9 +26,9 @@ public void testAppTransactionDecoding() throws IOException, NoSuchAlgorithmExce Assertions.assertEquals(531412, appTransaction.getAppAppleId()); Assertions.assertEquals("com.example", appTransaction.getBundleId()); Assertions.assertEquals("1.2.3", appTransaction.getApplicationVersion()); - Assertions.assertEquals(512, appTransaction.versionExternalIdentifier()); + Assertions.assertEquals(512, appTransaction.getVersionExternalIdentifier()); Assertions.assertEquals(1698148900000L, appTransaction.getReceiptCreationDate()); - Assertions.assertEquals(1698148800000L, appTransaction.originalPurchaseDate()); + Assertions.assertEquals(1698148800000L, appTransaction.getOriginalPurchaseDate()); Assertions.assertEquals("1.1.2", appTransaction.getOriginalApplicationVersion()); Assertions.assertEquals("device_verification_value", appTransaction.getDeviceVerification()); Assertions.assertEquals(UUID.fromString("48ccfa42-7431-4f22-9908-7e88983e105a"), appTransaction.getDeviceVerificationNonce()); diff --git a/src/test/java/com/apple/itunes/storekit/verification/XcodeSignedDataVerifierTest.java b/src/test/java/com/apple/itunes/storekit/verification/XcodeSignedDataVerifierTest.java index ef1f3e0a..5cb63409 100644 --- a/src/test/java/com/apple/itunes/storekit/verification/XcodeSignedDataVerifierTest.java +++ b/src/test/java/com/apple/itunes/storekit/verification/XcodeSignedDataVerifierTest.java @@ -33,8 +33,8 @@ public void testXcodeSignedAppTransaction() throws IOException, VerificationExce Assertions.assertNull(appTransaction.getAppAppleId()); Assertions.assertEquals(XCODE_BUNDLE_ID, appTransaction.getBundleId()); Assertions.assertEquals("1", appTransaction.getApplicationVersion()); - Assertions.assertNull(appTransaction.versionExternalIdentifier()); - Assertions.assertEquals(-62135769600000L, appTransaction.originalPurchaseDate()); + Assertions.assertNull(appTransaction.getVersionExternalIdentifier()); + Assertions.assertEquals(-62135769600000L, appTransaction.getOriginalPurchaseDate()); Assertions.assertEquals("1", appTransaction.getOriginalApplicationVersion()); Assertions.assertEquals("cYUsXc53EbYc0pOeXG5d6/31LGHeVGf84sqSN0OrJi5u/j2H89WWKgS8N0hMsMlf", appTransaction.getDeviceVerification()); Assertions.assertEquals(UUID.fromString("48c8b92d-ce0d-4229-bedf-e61b4f9cfc92"), appTransaction.getDeviceVerificationNonce()); @@ -78,6 +78,7 @@ public void testXcodeSignedTransaction() throws IOException, VerificationExcepti Assertions.assertEquals("143441", transaction.getStorefrontId()); Assertions.assertEquals(TransactionReason.PURCHASE, transaction.getTransactionReason()); Assertions.assertEquals("PURCHASE", transaction.getRawTransactionReason()); + Assertions.assertTrue(transaction.getUnknownFields().containsKey("deviceVerificationNonce")); } @Test diff --git a/src/test/resources/models/transactionHistoryResponseWithMalformedAppAppleId.json b/src/test/resources/models/transactionHistoryResponseWithMalformedAppAppleId.json new file mode 100644 index 00000000..29cd990c --- /dev/null +++ b/src/test/resources/models/transactionHistoryResponseWithMalformedAppAppleId.json @@ -0,0 +1,11 @@ +{ + "revision": "revision_output", + "hasMore": 1, + "bundleId": "com.example", + "appAppleId": "hi", + "environment": "LocalTesting", + "signedTransactions": [ + "signed_transaction_value", + "signed_transaction_value2" + ] + } \ No newline at end of file diff --git a/src/test/resources/models/transactionHistoryResponseWithMalformedEnvironment.json b/src/test/resources/models/transactionHistoryResponseWithMalformedEnvironment.json new file mode 100644 index 00000000..9d5d56db --- /dev/null +++ b/src/test/resources/models/transactionHistoryResponseWithMalformedEnvironment.json @@ -0,0 +1,11 @@ +{ + "revision": "revision_output", + "hasMore": true, + "bundleId": "com.example", + "appAppleId": 323232, + "environment": "LocalTestingxxx", + "signedTransactions": [ + "signed_transaction_value", + "signed_transaction_value2" + ] + } \ No newline at end of file