Skip to content

Commit c1eb125

Browse files
committed
feat(api): add more fields per the latest document
1 parent 5e35708 commit c1eb125

File tree

1 file changed

+118
-43
lines changed

1 file changed

+118
-43
lines changed

model.go

+118-43
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
package appstore
22

3-
import "github.com/golang-jwt/jwt/v4"
3+
import (
4+
"github.com/golang-jwt/jwt/v4"
5+
)
46

57
// OrderLookupResponse https://developer.apple.com/documentation/appstoreserverapi/orderlookupresponse
68
type OrderLookupResponse struct {
79
Status int `json:"status"`
810
SignedTransactions []string `json:"signedTransactions"`
911
}
1012

11-
// TransactionInfoResponse https://developer.apple.com/documentation/appstoreserverapi/transactioninforesponse
12-
type TransactionInfoResponse struct {
13-
SignedTransactionInfo string `json:"signedTransactionInfo"`
14-
}
13+
type Environment string
14+
15+
// Environment https://developer.apple.com/documentation/appstoreserverapi/environment
16+
const (
17+
Sandbox Environment = "Sandbox"
18+
Production Environment = "Production"
19+
)
1520

1621
// HistoryResponse https://developer.apple.com/documentation/appstoreserverapi/historyresponse
1722
type HistoryResponse struct {
18-
AppAppleId int `json:"appAppleId"`
19-
BundleId string `json:"bundleId"`
20-
Environment string `json:"environment"`
21-
HasMore bool `json:"hasMore"`
22-
Revision string `json:"revision"`
23-
SignedTransactions []string `json:"signedTransactions"`
23+
AppAppleId int64 `json:"appAppleId"`
24+
BundleId string `json:"bundleId"`
25+
Environment Environment `json:"environment"`
26+
HasMore bool `json:"hasMore"`
27+
Revision string `json:"revision"`
28+
SignedTransactions []string `json:"signedTransactions"`
29+
}
30+
31+
// TransactionInfoResponse https://developer.apple.com/documentation/appstoreserverapi/transactioninforesponse
32+
type TransactionInfoResponse struct {
33+
SignedTransactionInfo string `json:"signedTransactionInfo"`
2434
}
2535

26-
// RefundLookupResponse https://developer.apple.com/documentation/appstoreserverapi/refundlookupresponse
36+
// RefundLookupResponse same as the RefundHistoryResponse https://developer.apple.com/documentation/appstoreserverapi/refundhistoryresponse
2737
type RefundLookupResponse struct {
2838
HasMore bool `json:"hasMore"`
2939
Revision string `json:"revision"`
@@ -32,8 +42,8 @@ type RefundLookupResponse struct {
3242

3343
// StatusResponse https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
3444
type StatusResponse struct {
35-
Environment string `json:"environment"`
36-
AppAppleId int `json:"appAppleId"`
45+
Environment Environment `json:"environment"`
46+
AppAppleId int64 `json:"appAppleId"`
3747
BundleId string `json:"bundleId"`
3848
Data []SubscriptionGroupIdentifierItem `json:"data"`
3949
}
@@ -45,27 +55,51 @@ type SubscriptionGroupIdentifierItem struct {
4555

4656
type LastTransactionsItem struct {
4757
OriginalTransactionId string `json:"originalTransactionId"`
48-
Status int `json:"status"`
58+
Status int32 `json:"status"`
4959
SignedRenewalInfo string `json:"signedRenewalInfo"`
5060
SignedTransactionInfo string `json:"signedTransactionInfo"`
5161
}
5262

63+
// MassExtendRenewalDateRequest https://developer.apple.com/documentation/appstoreserverapi/massextendrenewaldaterequest
64+
type MassExtendRenewalDateRequest struct {
65+
RequestIdentifier string `json:"requestIdentifier"`
66+
ExtendByDays int32 `json:"extendByDays"`
67+
ExtendReasonCode int32 `json:"extendReasonCode"`
68+
ProductId string `json:"productId"`
69+
StorefrontCountryCodes []string `json:"storefrontCountryCodes"`
70+
}
71+
5372
// ConsumptionRequestBody https://developer.apple.com/documentation/appstoreserverapi/consumptionrequest
5473
type ConsumptionRequestBody struct {
55-
AccountTenure int `json:"accountTenure"`
74+
AccountTenure int32 `json:"accountTenure"`
5675
AppAccountToken string `json:"appAccountToken"`
57-
ConsumptionStatus int `json:"consumptionStatus"`
76+
ConsumptionStatus int32 `json:"consumptionStatus"`
5877
CustomerConsented bool `json:"customerConsented"`
59-
DeliveryStatus int `json:"deliveryStatus"`
60-
LifetimeDollarsPurchased int `json:"lifetimeDollarsPurchased"`
61-
LifetimeDollarsRefunded int `json:"lifetimeDollarsRefunded"`
62-
Platform int `json:"platform"`
63-
PlayTime int `json:"playTime"`
78+
DeliveryStatus int32 `json:"deliveryStatus"`
79+
LifetimeDollarsPurchased int32 `json:"lifetimeDollarsPurchased"`
80+
LifetimeDollarsRefunded int32 `json:"lifetimeDollarsRefunded"`
81+
Platform int32 `json:"platform"`
82+
PlayTime int32 `json:"playTime"`
6483
SampleContentProvided bool `json:"sampleContentProvided"`
65-
UserStatus int `json:"userStatus"`
84+
UserStatus int32 `json:"userStatus"`
6685
}
6786

87+
// JWSRenewalInfoDecodedPayload https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfodecodedpayload
6888
type JWSRenewalInfoDecodedPayload struct {
89+
AutoRenewProductId string `json:"autoRenewProductId"`
90+
AutoRenewStatus int32 `json:"autoRenewStatus"`
91+
Environment Environment `json:"environment"`
92+
ExpirationIntent int32 `json:"expirationIntent"`
93+
GracePeriodExpiresDate int64 `json:"gracePeriodExpiresDate"`
94+
IsInBillingRetryPeriod bool `json:"isInBillingRetryPeriod"`
95+
OfferIdentifier string `json:"offerIdentifier"`
96+
OfferType string `json:"offerType"`
97+
OriginalTransactionId string `json:"originalTransactionId"`
98+
PriceIncreaseStatus int32 `json:"priceIncreaseStatus"`
99+
ProductId string `json:"productId"`
100+
RecentSubscriptionStartDate int64 `json:"recentSubscriptionStartDate"`
101+
RenewalDate int64 `json:"renewalDate"`
102+
SignedDate int64 `json:"signedDate"`
69103
}
70104

71105
// JWSDecodedHeader https://developer.apple.com/documentation/appstoreserverapi/jwsdecodedheader
@@ -75,27 +109,50 @@ type JWSDecodedHeader struct {
75109
X5C []string `json:"x5c,omitempty"`
76110
}
77111

112+
// TransactionReason indicates the cause of a purchase transaction,
113+
// https://developer.apple.com/documentation/appstoreservernotifications/transactionreason
114+
type TransactionReason string
115+
116+
const (
117+
TransactionReasonPurchase = "PURCHASE"
118+
TransactionReasonRenewal = "RENEWAL"
119+
)
120+
121+
// IAPType https://developer.apple.com/documentation/appstoreserverapi/type
122+
type IAPType string
123+
124+
const (
125+
AutoRenewable IAPType = "Auto-Renewable Subscription"
126+
NonConsumable IAPType = "Non-Consumable"
127+
Consumable IAPType = "Consumable"
128+
NonRenewable IAPType = "Non-Renewing Subscription"
129+
)
130+
78131
// JWSTransaction https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
79132
type JWSTransaction struct {
80-
TransactionID string `json:"transactionId,omitempty"`
81-
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
82-
WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"`
83-
BundleID string `json:"bundleId,omitempty"`
84-
ProductID string `json:"productId,omitempty"`
85-
SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"`
86-
PurchaseDate int64 `json:"purchaseDate,omitempty"`
87-
OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"`
88-
ExpiresDate int64 `json:"expiresDate,omitempty"`
89-
Quantity int64 `json:"quantity,omitempty"`
90-
Type string `json:"type,omitempty"`
91-
AppAccountToken string `json:"appAccountToken,omitempty"`
92-
InAppOwnershipType string `json:"inAppOwnershipType,omitempty"`
93-
SignedDate int64 `json:"signedDate,omitempty"`
94-
OfferType int64 `json:"offerType,omitempty"`
95-
OfferIdentifier string `json:"offerIdentifier,omitempty"`
96-
RevocationDate int64 `json:"revocationDate,omitempty"`
97-
RevocationReason int `json:"revocationReason,omitempty"`
98-
IsUpgraded bool `json:"isUpgraded,omitempty"`
133+
TransactionID string `json:"transactionId,omitempty"`
134+
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
135+
WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"`
136+
BundleID string `json:"bundleId,omitempty"`
137+
ProductID string `json:"productId,omitempty"`
138+
SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"`
139+
PurchaseDate int64 `json:"purchaseDate,omitempty"`
140+
OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"`
141+
ExpiresDate int64 `json:"expiresDate,omitempty"`
142+
Quantity int32 `json:"quantity,omitempty"`
143+
Type IAPType `json:"type,omitempty"`
144+
AppAccountToken string `json:"appAccountToken,omitempty"`
145+
InAppOwnershipType string `json:"inAppOwnershipType,omitempty"`
146+
SignedDate int64 `json:"signedDate,omitempty"`
147+
OfferType int32 `json:"offerType,omitempty"`
148+
OfferIdentifier string `json:"offerIdentifier,omitempty"`
149+
RevocationDate int64 `json:"revocationDate,omitempty"`
150+
RevocationReason int32 `json:"revocationReason,omitempty"`
151+
IsUpgraded bool `json:"isUpgraded,omitempty"`
152+
Storefront string `json:"storefront,omitempty"`
153+
StorefrontId string `json:"storefrontId,omitempty"`
154+
TransactionReason TransactionReason `json:"transactionReason,omitempty"`
155+
Environment Environment `json:"environment,omitempty"`
99156
}
100157

101158
func (J JWSTransaction) Valid() error {
@@ -114,18 +171,29 @@ const (
114171

115172
// ExtendRenewalDateRequest https://developer.apple.com/documentation/appstoreserverapi/extendrenewaldaterequest
116173
type ExtendRenewalDateRequest struct {
117-
ExtendByDays int `json:"extendByDays"`
174+
ExtendByDays int32 `json:"extendByDays"`
118175
ExtendReasonCode ExtendReasonCode `json:"extendReasonCode"`
119176
RequestIdentifier string `json:"requestIdentifier"`
120177
}
121178

179+
// MassExtendRenewalDateStatusResponse https://developer.apple.com/documentation/appstoreserverapi/massextendrenewaldatestatusresponse
180+
type MassExtendRenewalDateStatusResponse struct {
181+
RequestIdentifier string `json:"requestIdentifier"`
182+
Complete bool `json:"complete"`
183+
CompleteDate int64 `json:"completeDate,omitempty"`
184+
FailedCount int64 `json:"failedCount,omitempty"`
185+
SucceededCount int64 `json:"succeededCount,omitempty"`
186+
}
187+
122188
// NotificationHistoryRequest https://developer.apple.com/documentation/appstoreserverapi/notificationhistoryrequest
123189
type NotificationHistoryRequest struct {
124190
StartDate int64 `json:"startDate"`
125191
EndDate int64 `json:"endDate"`
126192
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
127193
NotificationType NotificationTypeV2 `json:"notificationType,omitempty"`
128194
NotificationSubtype SubtypeV2 `json:"notificationSubtype,omitempty"`
195+
OnlyFailures bool `json:"onlyFailures"`
196+
TransactionId string `json:"transactionId"`
129197
}
130198

131199
type NotificationTypeV2 string
@@ -181,6 +249,13 @@ type NotificationHistoryResponses struct {
181249
type NotificationHistoryResponseItem struct {
182250
SignedPayload string `json:"signedPayload"`
183251
FirstSendAttemptResult FirstSendAttemptResult `json:"firstSendAttemptResult"`
252+
SendAttempts []SendAttemptItem `json:"sendAttempts"`
253+
}
254+
255+
// SendAttemptItem https://developer.apple.com/documentation/appstoreserverapi/sendattemptitem
256+
type SendAttemptItem struct {
257+
AttemptDate int64 `json:"attemptDate"`
258+
SendAttemptResult FirstSendAttemptResult `json:"sendAttemptResult"`
184259
}
185260

186261
// https://developer.apple.com/documentation/appstoreserverapi/firstsendattemptresult

0 commit comments

Comments
 (0)