From 5076c87b5098acdebf65d8d57aba8d258bead0d8 Mon Sep 17 00:00:00 2001 From: JB Gosselin <1536838+jbgosselin@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:36:23 -0500 Subject: [PATCH 1/3] Rename numericString to NumericString to make it publicly available --- appstore/model.go | 16 ++++++++-------- appstore/model_test.go | 2 +- appstore/notification.go | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/appstore/model.go b/appstore/model.go index df3956c..92b3abc 100644 --- a/appstore/model.go +++ b/appstore/model.go @@ -2,14 +2,14 @@ package appstore import "encoding/json" -type numericString string +type NumericString string -func (n *numericString) UnmarshalJSON(b []byte) error { +func (n *NumericString) UnmarshalJSON(b []byte) error { var number json.Number if err := json.Unmarshal(b, &number); err != nil { return err } - *n = numericString(number.String()) + *n = NumericString(number.String()) return nil } @@ -131,11 +131,11 @@ type ( Receipt struct { ReceiptType string `json:"receipt_type"` AdamID int64 `json:"adam_id"` - AppItemID numericString `json:"app_item_id"` + AppItemID NumericString `json:"app_item_id"` BundleID string `json:"bundle_id"` ApplicationVersion string `json:"application_version"` DownloadID int64 `json:"download_id"` - VersionExternalIdentifier numericString `json:"version_external_identifier"` + VersionExternalIdentifier NumericString `json:"version_external_identifier"` OriginalApplicationVersion string `json:"original_application_version"` InApp []InApp `json:"in_app"` ReceiptCreationDate @@ -201,7 +201,7 @@ type ( // ReceiptForIOS6 is struct ReceiptForIOS6 struct { - AppItemID numericString `json:"app_item_id"` + AppItemID NumericString `json:"app_item_id"` BID string `json:"bid"` BVRS string `json:"bvrs"` CancellationDate @@ -211,13 +211,13 @@ type ( ItemID string `json:"item_id"` ProductID string `json:"product_id"` PurchaseDate - OriginalTransactionID numericString `json:"original_transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id"` OriginalPurchaseDate Quantity string `json:"quantity"` TransactionID string `json:"transaction_id"` UniqueIdentifier string `json:"unique_identifier"` UniqueVendorIdentifier string `json:"unique_vendor_identifier"` - VersionExternalIdentifier numericString `json:"version_external_identifier,omitempty"` + VersionExternalIdentifier NumericString `json:"version_external_identifier,omitempty"` WebOrderLineItemID string `json:"web_order_line_item_id"` } ) diff --git a/appstore/model_test.go b/appstore/model_test.go index 8b0fb5e..1a73a9d 100644 --- a/appstore/model_test.go +++ b/appstore/model_test.go @@ -9,7 +9,7 @@ import ( func TestNumericString_UnmarshalJSON(t *testing.T) { type foo struct { - ID numericString + ID NumericString } tests := []struct { diff --git a/appstore/notification.go b/appstore/notification.go index 13c3d46..086c236 100644 --- a/appstore/notification.go +++ b/appstore/notification.go @@ -66,7 +66,7 @@ type NotificationReceipt struct { BID string `json:"bid"` BVRS string `json:"bvrs"` TransactionID string `json:"transaction_id"` - OriginalTransactionID numericString `json:"original_transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id"` IsTrialPeriod string `json:"is_trial_period"` IsInIntroOfferPeriod string `json:"is_in_intro_offer_period"` @@ -94,7 +94,7 @@ type SubscriptionNotification struct { // Not show in raw notify body Password string `json:"password"` - OriginalTransactionID numericString `json:"original_transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id"` AutoRenewAdamID string `json:"auto_renew_adam_id"` // The primary key for identifying a subscription purchase. @@ -103,7 +103,7 @@ type SubscriptionNotification struct { // This is the same as the Subscription Expiration Intent in the receipt. // Posted only if notification_type is RENEWAL or INTERACTIVE_RENEWAL. - ExpirationIntent numericString `json:"expiration_intent"` + ExpirationIntent NumericString `json:"expiration_intent"` // Auto renew info AutoRenewStatus string `json:"auto_renew_status"` // false or true From ac857ab190d14a1e27a053b806fa92d440dbfa24 Mon Sep 17 00:00:00 2001 From: JB Gosselin <1536838+jbgosselin@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:55:22 -0500 Subject: [PATCH 2/3] Make InApp.OriginalTransactionID a NumericString --- appstore/model.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/appstore/model.go b/appstore/model.go index 92b3abc..f8b7ffe 100644 --- a/appstore/model.go +++ b/appstore/model.go @@ -102,15 +102,15 @@ type ( // The InApp type has the receipt attributes InApp struct { - Quantity string `json:"quantity"` - ProductID string `json:"product_id"` - TransactionID string `json:"transaction_id"` - OriginalTransactionID string `json:"original_transaction_id"` // this field is string - WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"` - PromotionalOfferID string `json:"promotional_offer_id"` - SubscriptionGroupIdentifier string `json:"subscription_group_identifier"` - OfferCodeRefName string `json:"offer_code_ref_name,omitempty"` - AppAccountToken string `json:"app_account_token,omitempty"` + Quantity string `json:"quantity"` + ProductID string `json:"product_id"` + TransactionID string `json:"transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id"` + WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"` + PromotionalOfferID string `json:"promotional_offer_id"` + SubscriptionGroupIdentifier string `json:"subscription_group_identifier"` + OfferCodeRefName string `json:"offer_code_ref_name,omitempty"` + AppAccountToken string `json:"app_account_token,omitempty"` IsTrialPeriod string `json:"is_trial_period"` IsInIntroOfferPeriod string `json:"is_in_intro_offer_period,omitempty"` From bee0f17209932dab53b405fbb7117d7fd9714fea Mon Sep 17 00:00:00 2001 From: JB Gosselin <1536838+jbgosselin@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:56:44 -0500 Subject: [PATCH 3/3] Fix marshalling for OriginalTransactionID with omitempty --- appstore/model.go | 4 ++-- appstore/notification.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appstore/model.go b/appstore/model.go index f8b7ffe..f9c7e8c 100644 --- a/appstore/model.go +++ b/appstore/model.go @@ -105,7 +105,7 @@ type ( Quantity string `json:"quantity"` ProductID string `json:"product_id"` TransactionID string `json:"transaction_id"` - OriginalTransactionID NumericString `json:"original_transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id,omitempty"` WebOrderLineItemID string `json:"web_order_line_item_id,omitempty"` PromotionalOfferID string `json:"promotional_offer_id"` SubscriptionGroupIdentifier string `json:"subscription_group_identifier"` @@ -211,7 +211,7 @@ type ( ItemID string `json:"item_id"` ProductID string `json:"product_id"` PurchaseDate - OriginalTransactionID NumericString `json:"original_transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id,omitempty"` OriginalPurchaseDate Quantity string `json:"quantity"` TransactionID string `json:"transaction_id"` diff --git a/appstore/notification.go b/appstore/notification.go index 086c236..70b4a22 100644 --- a/appstore/notification.go +++ b/appstore/notification.go @@ -66,7 +66,7 @@ type NotificationReceipt struct { BID string `json:"bid"` BVRS string `json:"bvrs"` TransactionID string `json:"transaction_id"` - OriginalTransactionID NumericString `json:"original_transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id,omitempty"` IsTrialPeriod string `json:"is_trial_period"` IsInIntroOfferPeriod string `json:"is_in_intro_offer_period"` @@ -94,7 +94,7 @@ type SubscriptionNotification struct { // Not show in raw notify body Password string `json:"password"` - OriginalTransactionID NumericString `json:"original_transaction_id"` + OriginalTransactionID NumericString `json:"original_transaction_id,omitempty"` AutoRenewAdamID string `json:"auto_renew_adam_id"` // The primary key for identifying a subscription purchase.