@@ -42,6 +42,7 @@ func GetOrgSettingsApi(c *gin.Context) {
4242 "drift_enabled" : org .DriftEnabled ,
4343 "drift_cron_tab" : org .DriftCronTab ,
4444 "drift_webhook_url" : org .DriftWebhookUrl ,
45+ "billing_plan" : org .BillingPlan ,
4546 })
4647}
4748
@@ -62,9 +63,11 @@ func UpdateOrgSettingsApi(c *gin.Context) {
6263 return
6364 }
6465 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"`
6871 }
6972 err = json .NewDecoder (c .Request .Body ).Decode (& reqBody )
7073 if err != nil {
@@ -73,9 +76,26 @@ func UpdateOrgSettingsApi(c *gin.Context) {
7376 return
7477 }
7578
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+
7999 err = models .DB .GormDB .Save (& org ).Error
80100 if err != nil {
81101 slog .Error ("Error saving organisation" , "organisationId" , organisationId , "source" , organisationSource , "error" , err )
0 commit comments