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

Method FilterLedgers

api/ledger.go:170–188  ·  view source on GitHub ↗

FilterLedgers filters ledgers using a JSON request body. This endpoint accepts a POST request with filters specified in JSON format. Request body format: { "filters": [ {"field": "name", "operator": "ilike", "value": "%savings%"} ], "limit": 20, "offset": 0 } Parameters: - c: T

(c *gin.Context)

Source from the content-addressed store, hash-verified

168// - 400 Bad Request: If there's an error parsing the filters or retrieving ledgers.
169// - 200 OK: If the ledgers are successfully retrieved.
170func (a Api) FilterLedgers(c *gin.Context) {
171 filters, opts, limit, offset, err := ParseFiltersFromBody(c, "ledgers")
172 if err != nil {
173 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
174 return
175 }
176
177 resp, count, err := a.ledgerforge.GetAllLedgersWithFilterAndOptions(c.Request.Context(), filters, opts, limit, offset)
178 if err != nil {
179 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
180 return
181 }
182
183 if opts.IncludeCount {
184 c.JSON(http.StatusOK, FilterResponse{Data: resp, TotalCount: count})
185 } else {
186 c.JSON(http.StatusOK, resp)
187 }
188}
189
190// UpdateLedger updates an existing ledger's name.
191// It binds the incoming JSON request to an UpdateLedger object, validates it,

Callers

nothing calls this directly

Calls 3

ParseFiltersFromBodyFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected