@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) { |
| 185 | 185 | return string(ns.BillingProvider), nil |
| 186 | 186 | } |
| 187 | 187 | |
| 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 | + |
| 188 | 230 | type BillingSubscriptionStatus string |
| 189 | 231 | |
| 190 | 232 | const ( |
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) { |
| 1401 | 1443 | return string(ns.TrendingScope), nil |
| 1402 | 1444 | } |
| 1403 | 1445 | |
| 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 | + |
| 1404 | 1488 | type WatchLevel string |
| 1405 | 1489 | |
| 1406 | 1490 | const ( |
@@ -1863,7 +1947,7 @@ type AuthThrottle struct { |
| 1863 | 1947 | |
| 1864 | 1948 | type BillingInvoice struct { |
| 1865 | 1949 | ID int64 |
| 1866 | | - OrgID int64 |
| 1950 | + OrgID pgtype.Int8 |
| 1867 | 1951 | Provider BillingProvider |
| 1868 | 1952 | StripeInvoiceID string |
| 1869 | 1953 | StripeCustomerID string |
@@ -1883,6 +1967,8 @@ type BillingInvoice struct { |
| 1883 | 1967 | VoidedAt pgtype.Timestamptz |
| 1884 | 1968 | CreatedAt pgtype.Timestamptz |
| 1885 | 1969 | UpdatedAt pgtype.Timestamptz |
| 1970 | + SubjectKind BillingSubjectKind |
| 1971 | + SubjectID int64 |
| 1886 | 1972 | } |
| 1887 | 1973 | |
| 1888 | 1974 | type BillingSeatSnapshot struct { |
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct { |
| 1907 | 1993 | ProcessedAt pgtype.Timestamptz |
| 1908 | 1994 | ProcessError string |
| 1909 | 1995 | ProcessingAttempts int32 |
| 1996 | + SubjectKind NullBillingSubjectKind |
| 1997 | + SubjectID pgtype.Int8 |
| 1910 | 1998 | } |
| 1911 | 1999 | |
| 1912 | 2000 | type BranchProtectionRule struct { |
@@ -2627,6 +2715,29 @@ type User struct { |
| 2627 | 2715 | SessionEpoch int32 |
| 2628 | 2716 | IsSiteAdmin bool |
| 2629 | 2717 | 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 |
| 2630 | 2741 | } |
| 2631 | 2742 | |
| 2632 | 2743 | type UserEmail struct { |