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

Method GetTransaction

api/transactions.go:217–232  ·  view source on GitHub ↗

GetTransaction retrieves a transaction by its ID. It returns the transaction details if found. If the ID 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 response. Respons

(c *gin.Context)

Source from the content-addressed store, hash-verified

215// - 400 Bad Request: If there's an error in retrieving the transaction or the ID is missing.
216// - 200 OK: If the transaction is successfully retrieved.
217func (a Api) GetTransaction(c *gin.Context) {
218 id, passed := c.Params.Get("id")
219
220 if !passed {
221 c.JSON(http.StatusBadRequest, gin.H{"error": "id is required. pass id in the route /:id"})
222 return
223 }
224
225 resp, err := a.ledgerforge.GetTransaction(c.Request.Context(), id)
226 if err != nil {
227 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
228 return
229 }
230
231 c.JSON(http.StatusOK, transformTransaction(resp))
232}
233
234// GetTransactionByRef retrieves a transaction by its reference.
235// It returns the transaction details if found. If the reference is not provided or an error

Callers

nothing calls this directly

Calls 4

transformTransactionFunction · 0.85
GetMethod · 0.65
GetTransactionMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected