-
Notifications
You must be signed in to change notification settings - Fork 248
/
model.go
237 lines (206 loc) · 11.4 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package api
import "github.com/awa/go-iap/appstore"
// OrderLookupResponse https://developer.apple.com/documentation/appstoreserverapi/orderlookupresponse
type OrderLookupResponse struct {
Status int `json:"status"`
SignedTransactions []string `json:"signedTransactions"`
}
type Environment string
// Environment https://developer.apple.com/documentation/appstoreserverapi/environment
const (
Sandbox Environment = "Sandbox"
Production Environment = "Production"
)
// HistoryResponse https://developer.apple.com/documentation/appstoreserverapi/historyresponse
type HistoryResponse struct {
AppAppleId int64 `json:"appAppleId"`
BundleId string `json:"bundleId"`
Environment Environment `json:"environment"`
HasMore bool `json:"hasMore"`
Revision string `json:"revision"`
SignedTransactions []string `json:"signedTransactions"`
}
// TransactionInfoResponse https://developer.apple.com/documentation/appstoreserverapi/transactioninforesponse
type TransactionInfoResponse struct {
SignedTransactionInfo string `json:"signedTransactionInfo"`
}
// RefundLookupResponse same as the RefundHistoryResponse https://developer.apple.com/documentation/appstoreserverapi/refundhistoryresponse
type RefundLookupResponse struct {
HasMore bool `json:"hasMore"`
Revision string `json:"revision"`
SignedTransactions []string `json:"signedTransactions"`
}
// StatusResponse https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
type StatusResponse struct {
Environment Environment `json:"environment"`
AppAppleId int64 `json:"appAppleId"`
BundleId string `json:"bundleId"`
Data []SubscriptionGroupIdentifierItem `json:"data"`
}
type SubscriptionGroupIdentifierItem struct {
SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier"`
LastTransactions []LastTransactionsItem `json:"lastTransactions"`
}
type LastTransactionsItem struct {
OriginalTransactionId string `json:"originalTransactionId"`
Status int32 `json:"status"`
SignedRenewalInfo string `json:"signedRenewalInfo"`
SignedTransactionInfo string `json:"signedTransactionInfo"`
}
// MassExtendRenewalDateRequest https://developer.apple.com/documentation/appstoreserverapi/massextendrenewaldaterequest
type MassExtendRenewalDateRequest struct {
RequestIdentifier string `json:"requestIdentifier"`
ExtendByDays int32 `json:"extendByDays"`
ExtendReasonCode int32 `json:"extendReasonCode"`
ProductId string `json:"productId"`
StorefrontCountryCodes []string `json:"storefrontCountryCodes"`
}
// ConsumptionRequestBody https://developer.apple.com/documentation/appstoreserverapi/consumptionrequest
type ConsumptionRequestBody struct {
AccountTenure int32 `json:"accountTenure"`
AppAccountToken string `json:"appAccountToken"`
ConsumptionStatus int32 `json:"consumptionStatus"`
CustomerConsented bool `json:"customerConsented"`
DeliveryStatus int32 `json:"deliveryStatus"`
LifetimeDollarsPurchased int32 `json:"lifetimeDollarsPurchased"`
LifetimeDollarsRefunded int32 `json:"lifetimeDollarsRefunded"`
Platform int32 `json:"platform"`
PlayTime int32 `json:"playTime"`
SampleContentProvided bool `json:"sampleContentProvided"`
UserStatus int32 `json:"userStatus"`
}
// JWSRenewalInfoDecodedPayload https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfodecodedpayload
type JWSRenewalInfoDecodedPayload struct {
AutoRenewProductId string `json:"autoRenewProductId"`
AutoRenewStatus int32 `json:"autoRenewStatus"`
Environment Environment `json:"environment"`
ExpirationIntent int32 `json:"expirationIntent"`
GracePeriodExpiresDate int64 `json:"gracePeriodExpiresDate"`
IsInBillingRetryPeriod bool `json:"isInBillingRetryPeriod"`
OfferIdentifier string `json:"offerIdentifier"`
OfferType string `json:"offerType"`
OriginalTransactionId string `json:"originalTransactionId"`
PriceIncreaseStatus int32 `json:"priceIncreaseStatus"`
ProductId string `json:"productId"`
RecentSubscriptionStartDate int64 `json:"recentSubscriptionStartDate"`
RenewalDate int64 `json:"renewalDate"`
SignedDate int64 `json:"signedDate"`
}
// JWSDecodedHeader https://developer.apple.com/documentation/appstoreserverapi/jwsdecodedheader
type JWSDecodedHeader struct {
Alg string `json:"alg,omitempty"`
Kid string `json:"kid,omitempty"`
X5C []string `json:"x5c,omitempty"`
}
// TransactionReason indicates the cause of a purchase transaction,
// https://developer.apple.com/documentation/appstoreservernotifications/transactionreason
type TransactionReason string
const (
TransactionReasonPurchase = "PURCHASE"
TransactionReasonRenewal = "RENEWAL"
)
// IAPType https://developer.apple.com/documentation/appstoreserverapi/type
type IAPType string
const (
AutoRenewable IAPType = "Auto-Renewable Subscription"
NonConsumable IAPType = "Non-Consumable"
Consumable IAPType = "Consumable"
NonRenewable IAPType = "Non-Renewing Subscription"
)
// JWSTransaction https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
type JWSTransaction struct {
TransactionID string `json:"transactionId,omitempty"`
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"`
BundleID string `json:"bundleId,omitempty"`
ProductID string `json:"productId,omitempty"`
SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"`
PurchaseDate int64 `json:"purchaseDate,omitempty"`
OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"`
ExpiresDate int64 `json:"expiresDate,omitempty"`
Quantity int32 `json:"quantity,omitempty"`
Type IAPType `json:"type,omitempty"`
AppAccountToken string `json:"appAccountToken,omitempty"`
InAppOwnershipType string `json:"inAppOwnershipType,omitempty"`
SignedDate int64 `json:"signedDate,omitempty"`
OfferType int32 `json:"offerType,omitempty"`
OfferIdentifier string `json:"offerIdentifier,omitempty"`
RevocationDate int64 `json:"revocationDate,omitempty"`
RevocationReason int32 `json:"revocationReason,omitempty"`
IsUpgraded bool `json:"isUpgraded,omitempty"`
Storefront string `json:"storefront,omitempty"`
StorefrontId string `json:"storefrontId,omitempty"`
TransactionReason TransactionReason `json:"transactionReason,omitempty"`
Environment Environment `json:"environment,omitempty"`
}
func (J JWSTransaction) Valid() error {
return nil
}
// https://developer.apple.com/documentation/appstoreserverapi/extendreasoncode
type ExtendReasonCode int32
const (
UndeclaredExtendReasonCode = iota
CustomerSatisfaction
OtherReasons
ServiceIssueOrOutage
)
// ExtendRenewalDateRequest https://developer.apple.com/documentation/appstoreserverapi/extendrenewaldaterequest
type ExtendRenewalDateRequest struct {
ExtendByDays int32 `json:"extendByDays"`
ExtendReasonCode ExtendReasonCode `json:"extendReasonCode"`
RequestIdentifier string `json:"requestIdentifier"`
}
// MassExtendRenewalDateStatusResponse https://developer.apple.com/documentation/appstoreserverapi/massextendrenewaldatestatusresponse
type MassExtendRenewalDateStatusResponse struct {
RequestIdentifier string `json:"requestIdentifier"`
Complete bool `json:"complete"`
CompleteDate int64 `json:"completeDate,omitempty"`
FailedCount int64 `json:"failedCount,omitempty"`
SucceededCount int64 `json:"succeededCount,omitempty"`
}
// NotificationHistoryRequest https://developer.apple.com/documentation/appstoreserverapi/notificationhistoryrequest
type NotificationHistoryRequest struct {
StartDate int64 `json:"startDate"`
EndDate int64 `json:"endDate"`
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
NotificationType appstore.NotificationTypeV2 `json:"notificationType,omitempty"`
NotificationSubtype appstore.SubtypeV2 `json:"notificationSubtype,omitempty"`
OnlyFailures bool `json:"onlyFailures"`
TransactionId string `json:"transactionId"`
}
// NotificationHistoryResponses https://developer.apple.com/documentation/appstoreserverapi/notificationhistoryresponse
type NotificationHistoryResponses struct {
HasMore bool `json:"hasMore"`
PaginationToken string `json:"paginationToken"`
NotificationHistory []NotificationHistoryResponseItem `json:"notificationHistory"`
}
// NotificationHistoryResponseItem https://developer.apple.com/documentation/appstoreserverapi/notificationhistoryresponseitem
type NotificationHistoryResponseItem struct {
SignedPayload string `json:"signedPayload"`
FirstSendAttemptResult FirstSendAttemptResult `json:"firstSendAttemptResult"`
SendAttempts []SendAttemptItem `json:"sendAttempts"`
}
// SendAttemptItem https://developer.apple.com/documentation/appstoreserverapi/sendattemptitem
type SendAttemptItem struct {
AttemptDate int64 `json:"attemptDate"`
SendAttemptResult FirstSendAttemptResult `json:"sendAttemptResult"`
}
// https://developer.apple.com/documentation/appstoreserverapi/firstsendattemptresult
type FirstSendAttemptResult string
const (
FirstSendAttemptResultSuccess FirstSendAttemptResult = "SUCCESS"
FirstSendAttemptResultCircularRedirect FirstSendAttemptResult = "CIRCULAR_REDIRECT"
FirstSendAttemptResultInvalidResponse FirstSendAttemptResult = "INVALID_RESPONSE"
FirstSendAttemptResultNoResponse FirstSendAttemptResult = "NO_RESPONSE"
FirstSendAttemptResultOther FirstSendAttemptResult = "OTHER"
FirstSendAttemptResultPrematureClose FirstSendAttemptResult = "PREMATURE_CLOSE"
FirstSendAttemptResultSocketIssue FirstSendAttemptResult = "SOCKET_ISSUE"
FirstSendAttemptResultTimedOut FirstSendAttemptResult = "TIMED_OUT"
FirstSendAttemptResultTlsIssue FirstSendAttemptResult = "TLS_ISSUE"
FirstSendAttemptResultUnsupportedCharset FirstSendAttemptResult = "UNSUPPORTED_CHARSET"
FirstSendAttemptResultUnsupportedHTTPRESPONSECODE FirstSendAttemptResult = "UNSUCCESSFUL_HTTP_RESPONSE_CODE"
)
// SendTestNotificationResponse https://developer.apple.com/documentation/appstoreserverapi/sendtestnotificationresponse
type SendTestNotificationResponse struct {
TestNotificationToken string `json:"testNotificationToken"`
}