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

Method GetBalance

api/balance.go:73–93  ·  view source on GitHub ↗

GetBalance retrieves a balance record by its ID. It extracts the ID from the route parameters and the 'include' query parameter to fetch additional related information. If the ID is missing or there's an error retrieving the balance, it responds with an appropriate error message. Parameters: - c: T

(c *gin.Context)

Source from the content-addressed store, hash-verified

71// - 400 Bad Request: If the ID is missing or there's an error retrieving the balance.
72// - 200 OK: If the balance is successfully retrieved.
73func (a Api) GetBalance(c *gin.Context) {
74 id, passed := c.Params.Get("id")
75 if !passed {
76 c.JSON(http.StatusBadRequest, gin.H{"error": "id is required. pass id in the route /:id"})
77 return
78 }
79
80 // Extract 'include' parameter from the query
81 includes := c.QueryArray("include")
82
83 // Extract 'with_queued' parameter from the query, default to false
84 withQueued := c.DefaultQuery("with_queued", "false") == "true"
85
86 resp, err := a.ledgerforge.GetBalanceByID(c.Request.Context(), id, includes, withQueued)
87 if err != nil {
88 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
89 return
90 }
91
92 c.JSON(http.StatusOK, resp)
93}
94
95// GetBalances retrieves a list of balance records with pagination.
96// It extracts the 'limit' and 'offset' query parameters to control pagination,

Callers

nothing calls this directly

Calls 3

GetMethod · 0.65
GetBalanceByIDMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected