Skip to content

Commit 67d9114

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

File tree

48 files changed

+5153
-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.

48 files changed

+5153
-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: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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_DESCRIPTION_LENGTH = 45;
16+
private static final int MAXIMUM_DISPLAY_NAME_LENGTH = 30;
17+
private static final int MAXIMUM_SKU_LENGTH = 128;
18+
19+
@JsonProperty(value = SERIALIZED_NAME_SKU, required = true)
20+
protected String sku;
21+
@JsonProperty(value = SERIALIZED_NAME_DESCRIPTION, required = true)
22+
protected String description;
23+
@JsonProperty(value = SERIALIZED_NAME_DISPLAY_NAME, required = true)
24+
protected String displayName;
25+
@JsonAnySetter
26+
protected Map<String, Object> unknownFields;
27+
28+
protected AbstractAdvancedCommerceItem() {}
29+
30+
protected AbstractAdvancedCommerceItem(String sku, String description, String displayName) {
31+
this.sku = validateSku(sku);
32+
this.description = validateDescription(description);
33+
this.displayName = 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+
this.description = validateDescription(description);
67+
return self();
68+
}
69+
70+
/**
71+
* A string you provide that describes a SKU.
72+
*
73+
* @return description
74+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/description">Description</a>
75+
**/
76+
public String getDescription() {
77+
return description;
78+
}
79+
80+
public void setDescription(String description) {
81+
this.description = validateDescription(description);
82+
}
83+
84+
protected String validateDescription(String description) {
85+
Objects.requireNonNull(description);
86+
if (description.length() > MAXIMUM_DESCRIPTION_LENGTH) {
87+
throw new IllegalArgumentException("description length longer than maximum allowed");
88+
}
89+
return description;
90+
}
91+
92+
public AbstractAdvancedCommerceItem displayName(String displayName) {
93+
this.displayName = validateDisplayName(displayName);
94+
return self();
95+
}
96+
97+
/**
98+
* A string with a product name that you can localize and is suitable for display to customers.
99+
*
100+
* @return displayName
101+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/displayname">DisplayName</a>
102+
**/
103+
public String getDisplayName() {
104+
return displayName;
105+
}
106+
107+
public void setDisplayName(String displayName) {
108+
this.displayName = validateDisplayName(displayName);
109+
}
110+
111+
protected String validateDisplayName(String displayName) {
112+
Objects.requireNonNull(displayName);
113+
if (displayName.length() > MAXIMUM_DISPLAY_NAME_LENGTH) {
114+
throw new IllegalArgumentException("displayName length longer than maximum allowed");
115+
}
116+
return displayName;
117+
}
118+
119+
public AbstractAdvancedCommerceItem unknownFields(Map<String, Object> unknownFields) {
120+
this.unknownFields = unknownFields;
121+
return self();
122+
}
123+
124+
public Map<String, Object> getUnknownFields() {
125+
return unknownFields;
126+
}
127+
128+
public void setUnknownFields(Map<String, Object> unknownFields) {
129+
this.unknownFields = unknownFields;
130+
}
131+
132+
@Override
133+
public boolean equals(Object o) {
134+
if (this == o) {
135+
return true;
136+
}
137+
if (o == null || getClass() != o.getClass()) {
138+
return false;
139+
}
140+
AbstractAdvancedCommerceItem that = (AbstractAdvancedCommerceItem) o;
141+
return Objects.equals(this.sku, that.sku) &&
142+
Objects.equals(this.description, that.description) &&
143+
Objects.equals(this.displayName, that.displayName) &&
144+
Objects.equals(this.unknownFields, that.unknownFields);
145+
}
146+
147+
@Override
148+
public int hashCode() {
149+
return Objects.hash(sku, description, displayName, unknownFields);
150+
}
151+
}
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: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
private static final int MAXIMUM_DESCRIPTION_LENGTH = 45;
18+
private static final int MAXIMUM_DISPLAY_NAME_LENGTH = 30;
19+
20+
@JsonProperty(SERIALIZED_NAME_DESCRIPTION)
21+
private String description;
22+
@JsonProperty(SERIALIZED_NAME_DISPLAY_NAME)
23+
private String displayName;
24+
@JsonAnySetter
25+
private Map<String, Object> unknownFields;
26+
27+
public AdvancedCommerceDescriptors() {}
28+
29+
public AdvancedCommerceDescriptors description(String description) {
30+
this.description = validateDescription(description);
31+
return this;
32+
}
33+
34+
/**
35+
* A string you provide that describes a SKU.
36+
*
37+
* @return description
38+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/description">Description</a>
39+
**/
40+
public String getDescription() {
41+
return description;
42+
}
43+
44+
public void setDescription(String description) {
45+
this.description = validateDescription(description);
46+
}
47+
48+
private String validateDescription(String description) {
49+
Objects.requireNonNull(description);
50+
if (description.length() > MAXIMUM_DESCRIPTION_LENGTH) {
51+
throw new IllegalArgumentException("description length longer than maximum allowed");
52+
}
53+
return description;
54+
}
55+
56+
public AdvancedCommerceDescriptors displayName(String displayName) {
57+
this.displayName = validateDisplayName(displayName);
58+
return this;
59+
}
60+
61+
/**
62+
* A string with a product name that you can localize and is suitable for display to customers.
63+
*
64+
* @return displayName
65+
* @see <a href="https://developer.apple.com/documentation/appstoreserverapi/displayname">DisplayName</a>
66+
**/
67+
public String getDisplayName() {
68+
return displayName;
69+
}
70+
71+
public void setDisplayName(String displayName) {
72+
this.displayName = validateDisplayName(displayName);
73+
}
74+
75+
private String validateDisplayName(String displayName) {
76+
Objects.requireNonNull(displayName);
77+
if (displayName.length() > MAXIMUM_DISPLAY_NAME_LENGTH) {
78+
throw new IllegalArgumentException("displayName length longer than maximum allowed");
79+
}
80+
return displayName;
81+
}
82+
83+
public AdvancedCommerceDescriptors unknownFields(Map<String, Object> unknownFields) {
84+
this.unknownFields = unknownFields;
85+
return this;
86+
}
87+
88+
public Map<String, Object> getUnknownFields() {
89+
return unknownFields;
90+
}
91+
92+
public void setUnknownFields(Map<String, Object> unknownFields) {
93+
this.unknownFields = unknownFields;
94+
}
95+
96+
@Override
97+
public boolean equals(Object o) {
98+
if (this == o) return true;
99+
if (o == null || getClass() != o.getClass()) return false;
100+
AdvancedCommerceDescriptors that = (AdvancedCommerceDescriptors) o;
101+
return Objects.equals(description, that.description) && Objects.equals(displayName, that.displayName) && Objects.equals(unknownFields, that.unknownFields);
102+
}
103+
104+
@Override
105+
public int hashCode() {
106+
return Objects.hash(description, displayName, unknownFields);
107+
}
108+
109+
@Override
110+
public String toString() {
111+
return "AdvancedCommerceDescriptors{" +
112+
"description='" + description + '\'' +
113+
", displayName='" + displayName + '\'' +
114+
", unknownFields=" + unknownFields +
115+
'}';
116+
}
117+
}

0 commit comments

Comments
 (0)