From 7fe5fbfe2da937fb3fd89fff9859a9d2ac192e29 Mon Sep 17 00:00:00 2001 From: Doron Galambos <15026706+dgalambos@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:31:34 -0400 Subject: [PATCH] Add missing subscription fields (#14) * Add missing subscription struct fields Add missing fields from subscription struct: AutoResumeDate, GracePeriodExpiresDate, RefundedAt, OwnershipType, StoreTransactionID. Also add OwnershipType type to be consistent with rest of code. * Fix preexisting typo in Store type comment fix preexisting type in Store type comment --- subscribers.go | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/subscribers.go b/subscribers.go index b69d8ca..e81e308 100644 --- a/subscribers.go +++ b/subscribers.go @@ -28,14 +28,19 @@ type Entitlement struct { // https://docs.revenuecat.com/reference#the-subscription-object type Subscription struct { - ExpiresDate *time.Time `json:"expires_date"` - PurchaseDate time.Time `json:"purchase_date"` - OriginalPurchaseDate time.Time `json:"original_purchase_date"` - PeriodType PeriodType `json:"period_type"` - Store Store `json:"store"` - IsSandbox bool `json:"is_sandbox"` - UnsubscribeDetectedAt *time.Time `json:"unsubscribe_detected_at"` - BillingIssuesDetectedAt *time.Time `json:"billing_issues_detected_at"` + ExpiresDate *time.Time `json:"expires_date"` + PurchaseDate time.Time `json:"purchase_date"` + OriginalPurchaseDate time.Time `json:"original_purchase_date"` + PeriodType PeriodType `json:"period_type"` + Store Store `json:"store"` + IsSandbox bool `json:"is_sandbox"` + UnsubscribeDetectedAt *time.Time `json:"unsubscribe_detected_at"` + BillingIssuesDetectedAt *time.Time `json:"billing_issues_detected_at"` + AutoResumeDate *time.Time `json:"auto_resume_date"` + GracePeriodExpiresDate *time.Time `json:"grace_period_expires_date"` + RefundedAt *time.Time `json:"refunded_at"` + OwnershipType OwnershipType `json:"ownership_type"` + StoreTransactionID string `json:"store_transaction_id"` } // https://docs.revenuecat.com/reference#section-the-non-subscription-object @@ -62,7 +67,15 @@ const ( IntroPeriodType PeriodType = "intro" ) -// PeriodType holds the predefined values for a store. +// OwnershipType holds the predefined values for a subscription ownership type. +type OwnershipType string + +const ( + PurchasedOwnershipType OwnershipType = "PURCHASED" + FamilySharedOwnershipType OwnershipType = "FAMILY_SHARED" +) + +// Store holds the predefined values for a store. type Store string // https://docs.revenuecat.com/reference#the-subscription-object