Skip to content

Commit

Permalink
🔄 Sync from monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
mojo-machine[bot] committed May 23, 2024
1 parent f6a82c5 commit 7b667c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/revenuecat/revenuecat.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (
"net/url"
"time"

"github.com/samber/lo"

Check failure on line 9 in lib/revenuecat/revenuecat.go

View workflow job for this annotation

GitHub Actions / build

no required module provides package github.com/samber/lo; to add it:
"github.com/wearemojo/mojo-public-go/lib/httpclient"
"github.com/wearemojo/mojo-public-go/lib/jsonclient"
"github.com/wearemojo/mojo-public-go/lib/secret"
"golang.org/x/exp/maps"

Check failure on line 13 in lib/revenuecat/revenuecat.go

View workflow job for this annotation

GitHub Actions / build

missing go.sum entry for module providing package golang.org/x/exp/maps (imported by github.com/wearemojo/mojo-public-go/lib/revenuecat); to add:
)

const baseURL = "https://api.revenuecat.com/v1"
Expand Down Expand Up @@ -50,6 +52,7 @@ type Subscription struct {
PeriodType PeriodType `json:"period_type"`
UnsubscribeDetectedAt *time.Time `json:"unsubscribe_detected_at"`
Store StoreType `json:"store"`
ExpiresDate *time.Time `json:"expires_date"`
}

type NonSubscription struct {
Expand Down Expand Up @@ -89,12 +92,12 @@ func (c *Client) GetOrCreateSubscriberInfo(ctx context.Context, appUserID string
}

func (s *Subscriber) ActiveSubscriptionCount() int {
activeNonSubCount := len(s.NonSubscriptions) // always active
activeNonSubCount := len(lo.Flatten(maps.Values(s.NonSubscriptions))) // always active
activeSubCount := 0
now := time.Now()

for _, e := range s.Entitlements {
if e.ExpiresDate != nil && e.ExpiresDate.Before(now) {
for _, sub := range s.Subscriptions {
if sub.ExpiresDate != nil && sub.ExpiresDate.Before(now) {
continue
}

Expand Down

0 comments on commit 7b667c8

Please sign in to comment.