FilterBalances filters balances using a JSON request body. This endpoint accepts a POST request with filters specified in JSON format. Request body format: { "filters": [ {"field": "currency", "operator": "eq", "value": "USD"}, {"field": "ledger_id", "operator": "in", "values": ["ldg
(c *gin.Context)
| 171 | // - 400 Bad Request: If there's an error parsing the filters or retrieving balances. |
| 172 | // - 200 OK: If the balances are successfully retrieved. |
| 173 | func (a Api) FilterBalances(c *gin.Context) { |
| 174 | filters, opts, limit, offset, err := ParseFiltersFromBody(c, "balances") |
| 175 | if err != nil { |
| 176 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 177 | return |
| 178 | } |
| 179 | |
| 180 | resp, count, err := a.ledgerforge.GetAllBalancesWithFilterAndOptions(c.Request.Context(), filters, opts, limit, offset) |
| 181 | if err != nil { |
| 182 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 183 | return |
| 184 | } |
| 185 | |
| 186 | if opts.IncludeCount { |
| 187 | c.JSON(http.StatusOK, FilterResponse{Data: resp, TotalCount: count}) |
| 188 | } else { |
| 189 | c.JSON(http.StatusOK, resp) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // CreateBalanceMonitor creates a new balance monitor record in the system. |
| 194 | // It binds the incoming JSON request to a CreateBalanceMonitor object, validates it, |
nothing calls this directly
no test coverage detected