Update an entities.Webhook @Summary Update a webhook @Description Update a webhook for the currently authenticated user @Security ApiKeyAuth @Tags Webhooks @Accept json @Produce json @Param webhookID path string true "ID of the webhook" default(32343a19-da5
(c fiber.Ctx)
| 196 | // @Failure 500 {object} responses.InternalServerError |
| 197 | // @Router /webhooks/{webhookID} [put] |
| 198 | func (h *WebhookHandler) Update(c fiber.Ctx) error { |
| 199 | ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger) |
| 200 | defer span.End() |
| 201 | |
| 202 | var request requests.WebhookUpdate |
| 203 | if err := c.Bind().Body(&request); err != nil { |
| 204 | msg := fmt.Sprintf("cannot marshall params [%s] into [%T]", c.Body(), request) |
| 205 | ctxLogger.Warn(stacktrace.Propagate(err, msg)) |
| 206 | return h.responseBadRequest(c, err) |
| 207 | } |
| 208 | |
| 209 | request.WebhookID = c.Params("webhookID") |
| 210 | if errors := h.validator.ValidateUpdate(ctx, h.userIDFomContext(c), request.Sanitize()); len(errors) != 0 { |
| 211 | msg := fmt.Sprintf("validation errors [%s], while updating user [%+#v]", spew.Sdump(errors), request) |
| 212 | ctxLogger.Warn(stacktrace.NewError(msg)) |
| 213 | return h.responseUnprocessableEntity(c, errors, "validation errors while updating webhook") |
| 214 | } |
| 215 | |
| 216 | user, err := h.service.Update(ctx, request.ToUpdateParams(h.userFromContext(c))) |
| 217 | if err != nil { |
| 218 | msg := fmt.Sprintf("cannot update user with params [%+#v]", request) |
| 219 | ctxLogger.Error(stacktrace.Propagate(err, msg)) |
| 220 | return h.responseInternalServerError(c) |
| 221 | } |
| 222 | |
| 223 | return h.responseOK(c, "webhook updated successfully", user) |
| 224 | } |
nothing calls this directly
no test coverage detected