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