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

Method GetTransactionByRef

api/transactions.go:244–259  ·  view source on GitHub ↗

GetTransactionByRef retrieves a transaction by its reference. It returns the transaction details if found. If the reference is not provided or an error occurs while retrieving the transaction, it responds with an appropriate error message. Parameters: - c: The Gin context containing the request and

(c *gin.Context)

Source from the content-addressed store, hash-verified

242// - 400 Bad Request: If there's an error in retrieving the transaction or the reference is missing.
243// - 200 OK: If the transaction is successfully retrieved.
244func (a Api) GetTransactionByRef(c *gin.Context) {
245 reference, passed := c.Params.Get("reference")
246
247 if !passed {
248 c.JSON(http.StatusBadRequest, gin.H{"error": "reference is required. pass reference in the route /ref/:reference"})
249 return
250 }
251
252 resp, err := a.ledgerforge.GetTransactionByRef(c.Request.Context(), reference)
253 if err != nil {
254 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
255 return
256 }
257
258 c.JSON(http.StatusOK, transformTransaction(&resp))
259}
260
261// GetAllTransactions retrieves all transactions with pagination and optional filtering.
262// Supports advanced filtering via query parameters in the format: field_operator=value

Callers

nothing calls this directly

Calls 4

transformTransactionFunction · 0.85
GetMethod · 0.65
GetTransactionByRefMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected