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)
| 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. |
| 217 | func (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 |
nothing calls this directly
no test coverage detected