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

Method FilterTransactions

api/transactions.go:355–379  ·  view source on GitHub ↗

FilterTransactions filters transactions using a JSON request body. This endpoint accepts a POST request with filters specified in JSON format, providing more flexibility than query parameter filters. Request body format: { "filters": [ {"field": "status", "operator": "eq", "value": "APPLI

(c *gin.Context)

Source from the content-addressed store, hash-verified

353// - 400 Bad Request: If there's an error parsing the filters or retrieving transactions.
354// - 200 OK: If the transactions are successfully retrieved.
355func (a Api) FilterTransactions(c *gin.Context) {
356 filters, opts, limit, offset, err := ParseFiltersFromBody(c, "transactions")
357 if err != nil {
358 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
359 return
360 }
361
362 transactions, count, err := a.ledgerforge.GetAllTransactionsWithFilterAndOptions(c.Request.Context(), filters, opts, limit, offset)
363 if err != nil {
364 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
365 return
366 }
367
368 // Transform each transaction for response
369 result := make([]*model.Transaction, len(transactions))
370 for i := range transactions {
371 result[i] = transformTransaction(&transactions[i])
372 }
373
374 if opts.IncludeCount {
375 c.JSON(http.StatusOK, FilterResponse{Data: result, TotalCount: count})
376 } else {
377 c.JSON(http.StatusOK, result)
378 }
379}
380
381// UpdateInflightStatus updates the status of an inflight transaction based on the provided ID and status.
382// It processes the transaction in batches according to the specified status (commit or void).

Callers

nothing calls this directly

Calls 4

ParseFiltersFromBodyFunction · 0.85
transformTransactionFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected