@@ -185,15 +185,19 @@ func (s *UsageService) GetCostCenter(ctx context.Context, in *v1.GetCostCenterRe
185
185
return nil , err
186
186
}
187
187
return & v1.GetCostCenterResponse {
188
- CostCenter : & v1.CostCenter {
189
- AttributionId : string (result .ID ),
190
- SpendingLimit : result .SpendingLimit ,
191
- BillingStrategy : convertBillingStrategyToAPI (result .BillingStrategy ),
192
- NextBillingTime : timestamppb .New (result .NextBillingTime .Time ()),
193
- },
188
+ CostCenter : dbCostCenterToAPI (result ),
194
189
}, nil
195
190
}
196
191
192
+ func dbCostCenterToAPI (c db.CostCenter ) * v1.CostCenter {
193
+ return & v1.CostCenter {
194
+ AttributionId : string (c .ID ),
195
+ SpendingLimit : c .SpendingLimit ,
196
+ BillingStrategy : convertBillingStrategyToAPI (c .BillingStrategy ),
197
+ NextBillingTime : timestamppb .New (c .NextBillingTime .Time ()),
198
+ }
199
+ }
200
+
197
201
func convertBillingStrategyToDB (in v1.CostCenter_BillingStrategy ) db.BillingStrategy {
198
202
if in == v1 .CostCenter_BILLING_STRATEGY_STRIPE {
199
203
return db .CostCenter_Stripe
@@ -223,11 +227,13 @@ func (s *UsageService) SetCostCenter(ctx context.Context, in *v1.SetCostCenterRe
223
227
SpendingLimit : in .CostCenter .SpendingLimit ,
224
228
BillingStrategy : convertBillingStrategyToDB (in .CostCenter .BillingStrategy ),
225
229
}
226
- _ , err = s .costCenterManager .UpdateCostCenter (ctx , costCenter )
230
+ result , err : = s .costCenterManager .UpdateCostCenter (ctx , costCenter )
227
231
if err != nil {
228
232
return nil , err
229
233
}
230
- return & v1.SetCostCenterResponse {}, nil
234
+ return & v1.SetCostCenterResponse {
235
+ CostCenter : dbCostCenterToAPI (result ),
236
+ }, nil
231
237
}
232
238
233
239
func (s * UsageService ) ReconcileUsage (ctx context.Context , req * v1.ReconcileUsageRequest ) (* v1.ReconcileUsageResponse , error ) {
0 commit comments