MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / UpdateBalanceMonitor

Method UpdateBalanceMonitor

api/balance.go:309–330  ·  view source on GitHub ↗

UpdateBalanceMonitor updates an existing balance monitor record by its ID. It binds the incoming JSON request to a BalanceMonitor object, updates the record, and responds with a success message. If any errors occur during binding, validation, or update, it responds with an appropriate error message.

(c *gin.Context)

Source from the content-addressed store, hash-verified

307// - 400 Bad Request: If there's an error in binding JSON, validating the balance monitor, or updating the record.
308// - 200 OK: If the balance monitor is successfully updated.
309func (a Api) UpdateBalanceMonitor(c *gin.Context) {
310 var monitor model.BalanceMonitor
311 id, passed := c.Params.Get("id")
312 if !passed {
313 c.JSON(http.StatusBadRequest, gin.H{"error": "id is required. pass id in the route /:id"})
314 return
315 }
316
317 if err := c.ShouldBindJSON(&monitor); err != nil {
318 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
319 return
320 }
321
322 monitor.MonitorID = id
323 err := a.ledgerforge.UpdateMonitor(c.Request.Context(), &monitor)
324 if err != nil {
325 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
326 return
327 }
328
329 c.JSON(http.StatusOK, gin.H{"message": "BalanceMonitor updated successfully"})
330}
331
332// DeleteBalanceMonitor deletes an existing balance monitor record by its ID.
333// It extracts the ID from the route parameters and deletes the record. If the ID is missing

Callers

nothing calls this directly

Calls 3

GetMethod · 0.65
UpdateMonitorMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected