@@ -42,6 +42,7 @@ func GetOrgSettingsApi(c *gin.Context) {
42
42
"drift_enabled" : org .DriftEnabled ,
43
43
"drift_cron_tab" : org .DriftCronTab ,
44
44
"drift_webhook_url" : org .DriftWebhookUrl ,
45
+ "billing_plan" : org .BillingPlan ,
45
46
})
46
47
}
47
48
@@ -62,9 +63,11 @@ func UpdateOrgSettingsApi(c *gin.Context) {
62
63
return
63
64
}
64
65
var reqBody struct {
65
- DriftEnabled bool `json:"drift_enabled"`
66
- DriftCronTab string `json:"drift_cron_tab"`
67
- DriftWebhookUrl string `json:"drift_webhook_url"`
66
+ DriftEnabled * bool `json:"drift_enabled,omitempty"`
67
+ DriftCronTab * string `json:"drift_cron_tab,omitempty"`
68
+ DriftWebhookUrl * string `json:"drift_webhook_url,omitempty"`
69
+ BillingPlan * string `json:"billing_plan,omitempty"`
70
+ BillingStripeSubscriptionId * string `json:"billing_stripe_subscription_id,omitempty"`
68
71
}
69
72
err = json .NewDecoder (c .Request .Body ).Decode (& reqBody )
70
73
if err != nil {
@@ -73,9 +76,26 @@ func UpdateOrgSettingsApi(c *gin.Context) {
73
76
return
74
77
}
75
78
76
- org .DriftEnabled = reqBody .DriftEnabled
77
- org .DriftCronTab = reqBody .DriftCronTab
78
- org .DriftWebhookUrl = reqBody .DriftWebhookUrl
79
+ if reqBody .DriftEnabled != nil {
80
+ org .DriftEnabled = * reqBody .DriftEnabled
81
+ }
82
+
83
+ if reqBody .DriftCronTab != nil {
84
+ org .DriftCronTab = * reqBody .DriftCronTab
85
+ }
86
+
87
+ if reqBody .DriftWebhookUrl != nil {
88
+ org .DriftWebhookUrl = * reqBody .DriftWebhookUrl
89
+ }
90
+
91
+ if reqBody .BillingPlan != nil {
92
+ org .BillingPlan = models .BillingPlan (* reqBody .BillingPlan )
93
+ }
94
+
95
+ if reqBody .BillingStripeSubscriptionId != nil {
96
+ org .BillingStripeSubscriptionId = * reqBody .BillingStripeSubscriptionId
97
+ }
98
+
79
99
err = models .DB .GormDB .Save (& org ).Error
80
100
if err != nil {
81
101
slog .Error ("Error saving organisation" , "organisationId" , organisationId , "source" , organisationSource , "error" , err )
0 commit comments