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

Method GetBalanceByIndicator

api/balance.go:453–473  ·  view source on GitHub ↗

GetBalanceByIndicator retrieves a balance by its indicator and currency. It extracts the indicator and currency from the route parameters. If either parameter is missing or there's an error retrieving the balance, it responds with an appropriate error message. Parameters: - c: The Gin context conta

(c *gin.Context)

Source from the content-addressed store, hash-verified

451// - 400 Bad Request: If indicator or currency is missing or there's an error retrieving the balance.
452// - 200 OK: If the balance is successfully retrieved.
453func (a Api) GetBalanceByIndicator(c *gin.Context) {
454 indicator, indicatorPassed := c.Params.Get("indicator")
455 if !indicatorPassed {
456 c.JSON(http.StatusBadRequest, gin.H{"error": "indicator is required. pass indicator in the route /indicator/:indicator"})
457 return
458 }
459
460 currency, currencyPassed := c.Params.Get("currency")
461 if !currencyPassed {
462 c.JSON(http.StatusBadRequest, gin.H{"error": "currency is required. pass currency in the route /currency/:currency"})
463 return
464 }
465
466 resp, err := a.ledgerforge.GetBalanceByIndicator(c.Request.Context(), indicator, currency)
467 if err != nil {
468 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
469 return
470 }
471
472 c.JSON(http.StatusOK, resp)
473}
474
475// UpdateBalanceIdentity updates only the identity_id field of a balance.
476// Expected JSON payload: {"identity_id": "id_123"}

Callers

nothing calls this directly

Calls 3

GetMethod · 0.65
GetBalanceByIndicatorMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected