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

Method UpdateMatchingRule

api/reconciliation_api.go:218–240  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

216// - 500 Internal Server Error: If there is an error updating the matching rule.
217// - 200 OK: If the matching rule is successfully updated.
218func (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.

Callers

nothing calls this directly

Calls 2

UpdateMatchingRuleMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected