types.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // +build ee
  2. package billing
  3. type Team struct {
  4. ID string `json:"id"`
  5. ProviderID string `json:"provider_id"`
  6. Name string `json:"name"`
  7. Members []Teammate `json:"members"`
  8. Subscription Subscription `json:"subscription"`
  9. }
  10. type RoleEnum string
  11. const (
  12. RoleEnumOwner RoleEnum = "owner"
  13. RoleEnumMember RoleEnum = "member"
  14. )
  15. type Teammate struct {
  16. ID string `json:"id"`
  17. CustomerID string `json:"customer_id"`
  18. Role RoleEnum `json:"role"`
  19. Email string `json:"email"`
  20. }
  21. type Subscription struct {
  22. ID string `json:"id"`
  23. Plan Plan `json:"plan"`
  24. IsActive bool `json:"is_active"`
  25. }
  26. type Plan struct {
  27. ID string `json:"id"`
  28. ProviderID string `json:"string"`
  29. Name string `json:"name"`
  30. IsActive bool `json:"is_active"`
  31. Features []PlanFeature `json:"features"`
  32. }
  33. type CreatePlanRequest struct {
  34. Name string `json:"name"`
  35. IsActive bool `json:"is_active"`
  36. IsPublic bool `json:"is_public"`
  37. IsTrialAllowed bool `json:"is_trial_allowed"`
  38. PerMonthPriceCents uint `json:"per_month_price_cents"`
  39. PerYearPriceCents uint `json:"per_year_price_cents"`
  40. ReplacePlanID *string `json:"replace_plan_id"`
  41. Features []*CreatePlanFeature `json:"features"`
  42. TeamsAccess []*CreatePlanTeamsAccess `json:"teams_access"`
  43. }
  44. type CreatePlanFeature struct {
  45. FeatureID string `json:"feature_id"`
  46. SpecID string `json:"spec_id"`
  47. Display string `json:"display"`
  48. Sort uint `json:"sort"`
  49. IsActive bool `json:"is_active"`
  50. }
  51. type CreatePlanTeamsAccess struct {
  52. TeamID string `json:"team_id"`
  53. Revoke bool `json:"revoke"`
  54. }
  55. type CreateFeatureSpecRequest struct {
  56. Name string `json:"name"`
  57. RecordPeriod string `json:"record_period"`
  58. Aggregation string `json:"aggregation"`
  59. MaxLimit uint `json:"max_limit"`
  60. UnitPrice uint `json:"unit_price"`
  61. UnitsIncluded uint `json:"units_included"`
  62. }
  63. type CreateFeaturespecResponse struct {
  64. *CreateFeatureSpecRequest
  65. ID string `json:"id"`
  66. }
  67. type ListFeaturesResponse struct {
  68. Results []Feature `json:"results"`
  69. }
  70. type ListPlansResponse struct {
  71. Results []Plan `json:"results"`
  72. }
  73. type PlanFeature struct {
  74. ID string `json:"id"`
  75. IsActive bool `json:"is_active"`
  76. Feature Feature `json:"feature"`
  77. FeatureSpec FeatureSpec `json:"spec"`
  78. }
  79. type Feature struct {
  80. ID string `json:"id"`
  81. Slug string `json:"slug"`
  82. }
  83. type FeatureSpec struct {
  84. ID string `json:"id"`
  85. Name string `json:"name"`
  86. MaxLimit int64 `json:"max_limit"`
  87. ProviderID string `json:"provider_id"`
  88. }
  89. type CreateTeamRequest struct {
  90. Name string `json:"name"`
  91. }
  92. type AddTeammateRequest struct {
  93. Role RoleEnum `json:"role"`
  94. Email string `json:"email"`
  95. SourceID string `json:"source_id"`
  96. TeamID string `json:"team_id"`
  97. }
  98. type UpdateTeammateRequest struct {
  99. Role RoleEnum `json:"role"`
  100. }
  101. type CreateIDTokenRequest struct {
  102. Email string `json:"customer_email"`
  103. UserID string `json:"customer_source_id"`
  104. }
  105. type CreateIDTokenResponse struct {
  106. Token string `json:"token"`
  107. }
  108. type SubscriptionWebhookRequest struct {
  109. EventType string `json:"event_type"`
  110. TeamID string `json:"team_id"`
  111. Plan Plan `json:"plan"`
  112. }
  113. type CreateSubscriptionRequest struct {
  114. PlanID string `json:"plan_id"`
  115. TeamID string `json:"team_id"`
  116. IsPaused bool `json:"is_paused"`
  117. NextPlanID string `json:"next_plan_id"`
  118. }