Skip to content

Commit 5569336

Browse files
author
Riyaz Panjwani
committed
Add POJOs for Advanced Commerce API
1 parent 6260d10 commit 5569336

File tree

47 files changed

+4856
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4856
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Apple App Store Server Java Library
2-
The Java server library for the [App Store Server API](https://developer.apple.com/documentation/appstoreserverapi) and [App Store Server Notifications](https://developer.apple.com/documentation/appstoreservernotifications). Also available in [Swift](https://github.com/apple/app-store-server-library-swift), [Python](https://github.com/apple/app-store-server-library-python), and [Node.js](https://github.com/apple/app-store-server-library-node).
2+
The Java server library for the [App Store Server API](https://developer.apple.com/documentation/appstoreserverapi), [App Store Server Notifications](https://developer.apple.com/documentation/appstoreservernotifications), and [Advanced Commerce API](https://developer.apple.com/documentation/AdvancedCommerceAPI). Also available in [Swift](https://github.com/apple/app-store-server-library-swift), [Python](https://github.com/apple/app-store-server-library-python), and [Node.js](https://github.com/apple/app-store-server-library-node).
33

44
## Table of Contents
55
1. [Installation](#installation)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
package com.apple.itunes.storekit.model;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import java.util.Objects;
8+
9+
public abstract class AbstractAdvancedCommerceInAppRequest<T extends AbstractAdvancedCommerceInAppRequest<T>> extends AdvancedCommerceRequest<T> implements AdvancedCommerceInAppRequest {
10+
11+
private static final String SERIALIZED_NAME_OPERATION = "operation";
12+
private static final String SERIALIZED_NAME_VERSION = "version";
13+
14+
@JsonProperty(value = SERIALIZED_NAME_OPERATION, required = true)
15+
private String operation;
16+
@JsonProperty(value = SERIALIZED_NAME_VERSION, required = true)
17+
private String version;
18+
19+
protected AbstractAdvancedCommerceInAppRequest() {}
20+
21+
protected AbstractAdvancedCommerceInAppRequest(String operation, String version, AdvancedCommerceRequestInfo requestInfo) {
22+
super(requestInfo);
23+
this.operation = operation;
24+
this.version = version;
25+
}
26+
27+
@Override
28+
public boolean equals(Object o) {
29+
if (this == o) return true;
30+
if (o == null || getClass() != o.getClass()) return false;
31+
if (!super.equals(o)) return false;
32+
AbstractAdvancedCommerceInAppRequest<?> that = (AbstractAdvancedCommerceInAppRequest<?>) o;
33+
return Objects.equals(operation, that.operation) && Objects.equals(version, that.version);
34+
}
35+
36+
@Override
37+
public int hashCode() {
38+
return Objects.hash(super.hashCode(), operation, version);
39+
}
40+
41+
protected abstract T self();
42+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
3+
package com.apple.itunes.storekit.model;
4+
5+
import com.fasterxml.jackson.annotation.JsonAnySetter;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
import java.util.Map;
9+
import java.util.Objects;
10+
11+
public abstract class AbstractAdvancedCommerceItem {
12+
private static final String SERIALIZED_NAME_SKU = "SKU";
13+
private static final String SERIALIZED_NAME_DESCRIPTION = "description";
14+
private static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";
15+
private static final int MAXIMUM_SKU_LENGTH = 128;
16+
17+
@JsonProperty(value = SERIALIZED_NAME_SKU, required = true)
18+
protected String sku;
19+
@JsonProperty(value = SERIALIZED_NAME_DESCRIPTION, required = true)
20+
protected String description;
21+
@JsonProperty(value = SERIALIZED_NAME_DISPLAY_NAME, required = true)
22+
protected String displayName;
23+
@JsonAnySetter
24+
protected Map<String, Object> unknownFields;
25+
26+
protected AbstractAdvancedCommerceItem() {}
27+
28+
protected AbstractAdvancedCommerceItem(String sku, String description, String displayName) {
29+
this.sku = validateSku(sku);
30+
Objects.requireNonNull(description, "Description cannot be null");
31+
this.description = AdvancedCommerceValidationUtils.validateDescription(description);
32+
Objects.requireNonNull(displayName, "Display name cannot be null");
33+
this.displayName = AdvancedCommerceValidationUtils.validateDisplayName(displayName);
34+
}
35+
36+
public abstract AbstractAdvancedCommerceItem self();
37+
38+
public AbstractAdvancedCommerceItem sku(String sku) {
39+
this.sku = validateSku(sku);
40+
return self();
41+
}
42+
43+
/**
44+
* The product identifier of an in-app purchase product you manage in your own system.
45+
*
46+
* @return SKU
47+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/sku">SKU</a>
48+
**/
49+
public String getSku() {
50+
return sku;
51+
}
52+
53+
public void setSku(String sku) {
54+
this.sku = validateSku(sku);
55+
}
56+
57+
protected String validateSku(String sku) {
58+
Objects.requireNonNull(sku);
59+
if (sku.length() > MAXIMUM_SKU_LENGTH) {
60+
throw new IllegalArgumentException("sku length longer than maximum allowed");
61+
}
62+
return sku;
63+
}
64+
65+
public AbstractAdvancedCommerceItem description(String description) {
66+
Objects.requireNonNull(description, "Description cannot be null");
67+
this.description = AdvancedCommerceValidationUtils.validateDescription(description);
68+
return self();
69+
}
70+
71+
/**
72+
* A string you provide that describes a SKU.
73+
*
74+
* @return description
75+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/description">Description</a>
76+
**/
77+
public String getDescription() {
78+
return description;
79+
}
80+
81+
public void setDescription(String description) {
82+
Objects.requireNonNull(description, "Description cannot be null");
83+
this.description = AdvancedCommerceValidationUtils.validateDescription(description);
84+
}
85+
86+
public AbstractAdvancedCommerceItem displayName(String displayName) {
87+
Objects.requireNonNull(displayName, "Display name cannot be null");
88+
this.displayName = AdvancedCommerceValidationUtils.validateDisplayName(displayName);
89+
return self();
90+
}
91+
92+
/**
93+
* A string with a product name that you can localize and is suitable for display to customers.
94+
*
95+
* @return displayName
96+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/displayname">DisplayName</a>
97+
**/
98+
public String getDisplayName() {
99+
return displayName;
100+
}
101+
102+
public void setDisplayName(String displayName) {
103+
Objects.requireNonNull(displayName, "Display name cannot be null");
104+
this.displayName = AdvancedCommerceValidationUtils.validateDisplayName(displayName);
105+
}
106+
107+
public AbstractAdvancedCommerceItem unknownFields(Map<String, Object> unknownFields) {
108+
this.unknownFields = unknownFields;
109+
return self();
110+
}
111+
112+
public Map<String, Object> getUnknownFields() {
113+
return unknownFields;
114+
}
115+
116+
public void setUnknownFields(Map<String, Object> unknownFields) {
117+
this.unknownFields = unknownFields;
118+
}
119+
120+
@Override
121+
public boolean equals(Object o) {
122+
if (this == o) {
123+
return true;
124+
}
125+
if (o == null || getClass() != o.getClass()) {
126+
return false;
127+
}
128+
AbstractAdvancedCommerceItem that = (AbstractAdvancedCommerceItem) o;
129+
return Objects.equals(this.sku, that.sku) &&
130+
Objects.equals(this.description, that.description) &&
131+
Objects.equals(this.displayName, that.displayName) &&
132+
Objects.equals(this.unknownFields, that.unknownFields);
133+
}
134+
135+
@Override
136+
public int hashCode() {
137+
return Objects.hash(sku, description, displayName, unknownFields);
138+
}
139+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
package com.apple.itunes.storekit.model;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import java.util.Objects;
8+
9+
public abstract class AbstractAdvancedCommerceResponse {
10+
11+
private static final String SERIALIZED_NAME_SIGNED_RENEWAL_INFO = "signedRenewalInfo";
12+
private static final String SERIALIZED_NAME_SIGNED_TRANSACTION_INFO = "signedTransactionInfo";
13+
14+
@JsonProperty(SERIALIZED_NAME_SIGNED_RENEWAL_INFO)
15+
private String signedRenewalInfo;
16+
@JsonProperty(SERIALIZED_NAME_SIGNED_TRANSACTION_INFO)
17+
private String signedTransactionInfo;
18+
19+
protected AbstractAdvancedCommerceResponse() {}
20+
21+
protected AbstractAdvancedCommerceResponse(String signedRenewalInfo, String signedTransactionInfo) {
22+
this.signedRenewalInfo = signedRenewalInfo;
23+
this.signedTransactionInfo = signedTransactionInfo;
24+
}
25+
26+
/**
27+
* A response that contains signed renewal and transaction information after a subscription successfully migrates to the Advanced Commerce API.
28+
*
29+
* @return signedRenewalInfo
30+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfo">JWSRenewalInfo</a>
31+
**/
32+
public String getSignedRenewalInfo() {
33+
return signedRenewalInfo;
34+
}
35+
36+
public void setSignedRenewalInfo(String signedRenewalInfo) {
37+
this.signedRenewalInfo = signedRenewalInfo;
38+
}
39+
40+
/**
41+
* Transaction information signed by the App Store, in JSON Web Signature (JWS) Compact Serialization format.
42+
*
43+
* @return signedTransactionInfo
44+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/jwstransaction">JWSTransaction</a>
45+
**/
46+
public String getSignedTransactionInfo() {
47+
return signedTransactionInfo;
48+
}
49+
50+
public void setSignedTransactionInfo(String signedTransactionInfo) {
51+
this.signedTransactionInfo = signedTransactionInfo;
52+
}
53+
54+
@Override
55+
public boolean equals(Object o) {
56+
if (this == o) return true;
57+
if (o == null || getClass() != o.getClass()) return false;
58+
AbstractAdvancedCommerceResponse that = (AbstractAdvancedCommerceResponse) o;
59+
return Objects.equals(signedRenewalInfo, that.signedRenewalInfo) && Objects.equals(signedTransactionInfo, that.signedTransactionInfo);
60+
}
61+
62+
@Override
63+
public int hashCode() {
64+
return Objects.hash(signedRenewalInfo, signedTransactionInfo);
65+
}
66+
67+
@Override
68+
public String toString() {
69+
return getClass().getSimpleName() + "{" +
70+
"signedRenewalInfo='" + signedRenewalInfo + '\'' +
71+
", signedTransactionInfo='" + signedTransactionInfo + '\'' +
72+
'}';
73+
}
74+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
package com.apple.itunes.storekit.model;
4+
5+
import com.fasterxml.jackson.annotation.JsonAnySetter;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
import java.util.Map;
9+
import java.util.Objects;
10+
11+
/**
12+
* The description and display name of the subscription to migrate to that you manage.
13+
*/
14+
public class AdvancedCommerceDescriptors {
15+
private static final String SERIALIZED_NAME_DESCRIPTION = "description";
16+
private static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";
17+
18+
@JsonProperty(SERIALIZED_NAME_DESCRIPTION)
19+
private String description;
20+
@JsonProperty(SERIALIZED_NAME_DISPLAY_NAME)
21+
private String displayName;
22+
@JsonAnySetter
23+
private Map<String, Object> unknownFields;
24+
25+
public AdvancedCommerceDescriptors() {}
26+
27+
public AdvancedCommerceDescriptors description(String description) {
28+
Objects.requireNonNull(description, "Description cannot be null");
29+
this.description = AdvancedCommerceValidationUtils.validateDescription(description);
30+
return this;
31+
}
32+
33+
/**
34+
* A string you provide that describes a SKU.
35+
*
36+
* @return description
37+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/description">Description</a>
38+
**/
39+
public String getDescription() {
40+
return description;
41+
}
42+
43+
public void setDescription(String description) {
44+
Objects.requireNonNull(description, "Description cannot be null");
45+
this.description = AdvancedCommerceValidationUtils.validateDescription(description);
46+
}
47+
48+
public AdvancedCommerceDescriptors displayName(String displayName) {
49+
Objects.requireNonNull(displayName, "Display name cannot be null");
50+
this.displayName = AdvancedCommerceValidationUtils.validateDisplayName(displayName);
51+
return this;
52+
}
53+
54+
/**
55+
* A string with a product name that you can localize and is suitable for display to customers.
56+
*
57+
* @return displayName
58+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/displayname">DisplayName</a>
59+
**/
60+
public String getDisplayName() {
61+
return displayName;
62+
}
63+
64+
public void setDisplayName(String displayName) {
65+
Objects.requireNonNull(displayName, "Display name cannot be null");
66+
this.displayName = AdvancedCommerceValidationUtils.validateDisplayName(displayName);
67+
}
68+
69+
public AdvancedCommerceDescriptors unknownFields(Map<String, Object> unknownFields) {
70+
this.unknownFields = unknownFields;
71+
return this;
72+
}
73+
74+
public Map<String, Object> getUnknownFields() {
75+
return unknownFields;
76+
}
77+
78+
public void setUnknownFields(Map<String, Object> unknownFields) {
79+
this.unknownFields = unknownFields;
80+
}
81+
82+
@Override
83+
public boolean equals(Object o) {
84+
if (this == o) return true;
85+
if (o == null || getClass() != o.getClass()) return false;
86+
AdvancedCommerceDescriptors that = (AdvancedCommerceDescriptors) o;
87+
return Objects.equals(description, that.description) && Objects.equals(displayName, that.displayName) && Objects.equals(unknownFields, that.unknownFields);
88+
}
89+
90+
@Override
91+
public int hashCode() {
92+
return Objects.hash(description, displayName, unknownFields);
93+
}
94+
95+
@Override
96+
public String toString() {
97+
return "AdvancedCommerceDescriptors{" +
98+
"description='" + description + '\'' +
99+
", displayName='" + displayName + '\'' +
100+
", unknownFields=" + unknownFields +
101+
'}';
102+
}
103+
}

0 commit comments

Comments
 (0)