Skip to content

Commit aa730a7

Browse files
authored
Merge pull request #199 from richzw/master
feat(appstore): add summary field to v2 response of app store notific…
2 parents f2d7270 + 7354ffc commit aa730a7

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

appstore/notification_v2.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,26 @@ type (
106106
// SubscriptionNotificationV2DecodedPayload is struct
107107
// https://developer.apple.com/documentation/appstoreservernotifications/responsebodyv2decodedpayload
108108
SubscriptionNotificationV2DecodedPayload struct {
109-
NotificationType NotificationTypeV2 `json:"notificationType"`
110-
Subtype SubtypeV2 `json:"subtype"`
111-
NotificationUUID string `json:"notificationUUID"`
112-
NotificationVersion string `json:"version"`
113-
SignedDate int64 `json:"signedDate"`
114-
Data SubscriptionNotificationV2Data `json:"data"`
109+
NotificationType NotificationTypeV2 `json:"notificationType"`
110+
Subtype SubtypeV2 `json:"subtype"`
111+
NotificationUUID string `json:"notificationUUID"`
112+
NotificationVersion string `json:"version"`
113+
SignedDate int64 `json:"signedDate"`
114+
Data SubscriptionNotificationV2Data `json:"data,omitempty"`
115+
Summary SubscriptionNotificationV2Summary `json:"summary,omitempty"`
116+
}
117+
118+
// SubscriptionNotificationV2Summary is struct
119+
// https://developer.apple.com/documentation/appstoreservernotifications/summary
120+
SubscriptionNotificationV2Summary struct {
121+
RequestIdentifier string `json:"requestIdentifier"`
122+
Environment string `json:"environment"`
123+
AppAppleId int64 `json:"appAppleId"`
124+
BundleID string `json:"bundleId"`
125+
ProductID string `json:"productId"`
126+
StorefrontCountryCodes string `json:"storefrontCountryCodes"`
127+
FailedCount int64 `json:"failedCount"`
128+
SucceededCount int64 `json:"succeededCount"`
115129
}
116130

117131
// SubscriptionNotificationV2Data is struct

playstore/validator_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func TestNewDefaultTokenSourceClient(t *testing.T) {
9696
func TestAcknowledgeSubscription(t *testing.T) {
9797
t.Parallel()
9898
// Exception scenario
99-
expected := "googleapi: Error 400: Invalid Value, invalid"
99+
expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"
100100

101101
client, _ := New(jsonKey)
102102
ctx := context.Background()
@@ -115,7 +115,7 @@ func TestAcknowledgeSubscription(t *testing.T) {
115115
func TestVerifySubscription(t *testing.T) {
116116
t.Parallel()
117117
// Exception scenario
118-
expected := "googleapi: Error 400: Invalid Value, invalid"
118+
expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"
119119

120120
client, _ := New(jsonKey)
121121
ctx := context.Background()
@@ -131,7 +131,7 @@ func TestVerifySubscription(t *testing.T) {
131131
func TestVerifySubscriptionV2(t *testing.T) {
132132
t.Parallel()
133133
// Exception scenario
134-
expected := "googleapi: Error 400: Invalid Value, invalid"
134+
expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"
135135

136136
client, _ := New(jsonKey)
137137
ctx := context.Background()
@@ -147,7 +147,7 @@ func TestVerifySubscriptionV2(t *testing.T) {
147147
func TestVerifyProduct(t *testing.T) {
148148
t.Parallel()
149149
// Exception scenario
150-
expected := "googleapi: Error 400: Invalid Value, invalid"
150+
expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"
151151

152152
client, _ := New(jsonKey)
153153
ctx := context.Background()
@@ -163,7 +163,7 @@ func TestVerifyProduct(t *testing.T) {
163163
func TestAcknowledgeProduct(t *testing.T) {
164164
t.Parallel()
165165
// Exception scenario
166-
expected := "googleapi: Error 400: Invalid Value, invalid"
166+
expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"
167167

168168
client, _ := New(jsonKey)
169169
ctx := context.Background()
@@ -179,7 +179,7 @@ func TestAcknowledgeProduct(t *testing.T) {
179179
func TestConsumeProduct(t *testing.T) {
180180
t.Parallel()
181181
// Exception scenario
182-
expected := "googleapi: Error 400: Invalid Value, invalid"
182+
expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"
183183

184184
client, _ := New(jsonKey)
185185
ctx := context.Background()
@@ -212,7 +212,7 @@ func TestCancelSubscription(t *testing.T) {
212212
t.Parallel()
213213
ctx := context.Background()
214214
client, _ := New(jsonKey)
215-
expectedStr := "googleapi: Error 400: Invalid Value, invalid"
215+
expectedStr := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"
216216
actual := client.CancelSubscription(ctx, "package", "productID", "purchaseToken")
217217

218218
if actual == nil || actual.Error() != expectedStr {

0 commit comments

Comments
 (0)