Skip to content

feat(appstore): add summary field to v2 response of app store notific… #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions appstore/notification_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,26 @@ type (
// SubscriptionNotificationV2DecodedPayload is struct
// https://developer.apple.com/documentation/appstoreservernotifications/responsebodyv2decodedpayload
SubscriptionNotificationV2DecodedPayload struct {
NotificationType NotificationTypeV2 `json:"notificationType"`
Subtype SubtypeV2 `json:"subtype"`
NotificationUUID string `json:"notificationUUID"`
NotificationVersion string `json:"version"`
SignedDate int64 `json:"signedDate"`
Data SubscriptionNotificationV2Data `json:"data"`
NotificationType NotificationTypeV2 `json:"notificationType"`
Subtype SubtypeV2 `json:"subtype"`
NotificationUUID string `json:"notificationUUID"`
NotificationVersion string `json:"version"`
SignedDate int64 `json:"signedDate"`
Data SubscriptionNotificationV2Data `json:"data,omitempty"`
Summary SubscriptionNotificationV2Summary `json:"summary,omitempty"`
}

// SubscriptionNotificationV2Summary is struct
// https://developer.apple.com/documentation/appstoreservernotifications/summary
SubscriptionNotificationV2Summary struct {
RequestIdentifier string `json:"requestIdentifier"`
Environment string `json:"environment"`
AppAppleId int64 `json:"appAppleId"`
BundleID string `json:"bundleId"`
ProductID string `json:"productId"`
StorefrontCountryCodes string `json:"storefrontCountryCodes"`
FailedCount int64 `json:"failedCount"`
SucceededCount int64 `json:"succeededCount"`
}

// SubscriptionNotificationV2Data is struct
Expand Down
14 changes: 7 additions & 7 deletions playstore/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestNewDefaultTokenSourceClient(t *testing.T) {
func TestAcknowledgeSubscription(t *testing.T) {
t.Parallel()
// Exception scenario
expected := "googleapi: Error 400: Invalid Value, invalid"
expected := "googleapi: Error 404: No application was found for the given package name., applicationNotFound"

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

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

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

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

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

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

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