MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / delete

Method delete

api/pkg/handlers/phone_api_key_handler.go:164–187  ·  view source on GitHub ↗

@Summary Delete a phone API key from the database. @Description Delete a phone API Key from the database and cannot be used for authentication anymore. @Security ApiKeyAuth @Tags PhoneAPIKeys @Accept json @Produce json @Param phoneAPIKeyID path string true "ID o

(c fiber.Ctx)

Source from the content-addressed store, hash-verified

162// @Failure 500 {object} responses.InternalServerError
163// @Router /phone-api-keys/{phoneAPIKeyID} [delete]
164func (h *PhoneAPIKeyHandler) delete(c fiber.Ctx) error {
165 ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger)
166 defer span.End()
167
168 phoneAPIKeyID := c.Params("phoneAPIKeyID")
169 if errors := h.validator.ValidateUUID(phoneAPIKeyID, "phoneAPIKeyID"); len(errors) != 0 {
170 msg := fmt.Sprintf("validation errors [%s], while deleting a phone API key with ID [%s]", spew.Sdump(errors), phoneAPIKeyID)
171 ctxLogger.Warn(stacktrace.NewError(msg))
172 return h.responseUnprocessableEntity(c, errors, "validation errors while storing event")
173 }
174
175 err := h.service.Delete(ctx, h.userIDFomContext(c), uuid.MustParse(phoneAPIKeyID))
176 if stacktrace.GetCode(err) == repositories.ErrCodeNotFound {
177 return h.responseNotFound(c, fmt.Sprintf("cannot find phone API key with ID [%s]", phoneAPIKeyID))
178 }
179
180 if err != nil {
181 msg := fmt.Sprintf("cannot delete phone API key with ID [%s] for user with ID [%s]", phoneAPIKeyID, h.userIDFomContext(c))
182 ctxLogger.Error(h.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg)))
183 return h.responseInternalServerError(c)
184 }
185
186 return h.responseNoContent(c, "phone API key deleted successfully")
187}
188
189// @Summary Remove the association of a phone from the phone API key.
190// @Description You will need to login again to the httpSMS app on your Android phone with a new phone API key.

Callers

nothing calls this directly

Calls 11

ValidateUUIDMethod · 0.80
userIDFomContextMethod · 0.80
responseNotFoundMethod · 0.80
responseNoContentMethod · 0.80
WarnMethod · 0.65
DeleteMethod · 0.65
ErrorMethod · 0.65
WrapErrorSpanMethod · 0.65

Tested by

no test coverage detected