tenseleyflow/shithub / 067862b

Browse files

policy/sqlc: regenerate models with billing_subject_kind + user_plan + user_billing_states

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
067862bd750482a4c21cc0d0dfcd4b4692560c7a
Parents
d49f96c
Tree
685c7c9

1 changed file

StatusFile+-
M internal/auth/policy/sqlc/models.go 112 1
internal/auth/policy/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {