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)
| 168 | // - 400 Bad Request: If there's an error parsing the filters or retrieving ledgers. |
| 169 | // - 200 OK: If the ledgers are successfully retrieved. |
| 170 | func (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, |
nothing calls this directly
no test coverage detected