UpdateHook handles updating an existing webhook.
(c *gin.Context)
| 26 | |
| 27 | // UpdateHook handles updating an existing webhook. |
| 28 | func (a *Api) UpdateHook(c *gin.Context) { |
| 29 | hookID := c.Param("id") |
| 30 | var hook hooks.Hook |
| 31 | if err := c.ShouldBindJSON(&hook); err != nil { |
| 32 | c.JSON(http.StatusBadRequest, apierror.NewAPIError(apierror.ErrInvalidInput, "invalid hook data", err)) |
| 33 | return |
| 34 | } |
| 35 | |
| 36 | if err := a.ledgerforge.Hooks.UpdateHook(c.Request.Context(), hookID, &hook); err != nil { |
| 37 | c.JSON(http.StatusBadRequest, apierror.NewAPIError(apierror.ErrInvalidInput, "failed to update hook", err)) |
| 38 | return |
| 39 | } |
| 40 | |
| 41 | c.JSON(http.StatusOK, hook) |
| 42 | } |
| 43 | |
| 44 | // GetHook retrieves a specific webhook by ID. |
| 45 | func (a *Api) GetHook(c *gin.Context) { |
nothing calls this directly
no test coverage detected