UpdateMatchingRule updates an existing matching rule identified by its ID. It returns the updated matching rule. Parameters: - c: The Gin context containing the request and response. Responses: - 400 Bad Request: If the Matching Rule ID is missing or the request body is invalid. - 500 Internal Ser
(c *gin.Context)
| 216 | // - 500 Internal Server Error: If there is an error updating the matching rule. |
| 217 | // - 200 OK: If the matching rule is successfully updated. |
| 218 | func (a Api) UpdateMatchingRule(c *gin.Context) { |
| 219 | ruleID := c.Param("id") |
| 220 | if ruleID == "" { |
| 221 | c.JSON(http.StatusBadRequest, gin.H{"error": "Matching Rule ID is required"}) |
| 222 | return |
| 223 | } |
| 224 | |
| 225 | var rule model.MatchingRule |
| 226 | if err := c.ShouldBindJSON(&rule); err != nil { |
| 227 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 228 | return |
| 229 | } |
| 230 | |
| 231 | rule.RuleID = ruleID |
| 232 | updatedRule, err := a.ledgerforge.UpdateMatchingRule(c.Request.Context(), rule) |
| 233 | if err != nil { |
| 234 | logrus.Error(err) |
| 235 | c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to update matching rule"}) |
| 236 | return |
| 237 | } |
| 238 | |
| 239 | c.JSON(http.StatusOK, updatedRule) |
| 240 | } |
| 241 | |
| 242 | // DeleteMatchingRule deletes a matching rule identified by its ID. |
| 243 | // It confirms the deletion with a success message. |
nothing calls this directly
no test coverage detected