@Summary Get the phone API keys of a user @Description Get list phone API keys which a user has registered on the httpSMS application @Security ApiKeyAuth @Tags PhoneAPIKeys @Accept json @Produce json @Param skip query int false "number of phone api keys to skip"
(c fiber.Ctx)
| 67 | // @Failure 500 {object} responses.InternalServerError |
| 68 | // @Router /phone-api-keys [get] |
| 69 | func (h *PhoneAPIKeyHandler) index(c fiber.Ctx) error { |
| 70 | ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger) |
| 71 | defer span.End() |
| 72 | |
| 73 | var request requests.PhoneAPIKeyIndex |
| 74 | if err := c.Bind().Query(&request); err != nil { |
| 75 | msg := fmt.Sprintf("cannot marshall params [%s] into %T", c.OriginalURL(), request) |
| 76 | ctxLogger.Warn(stacktrace.Propagate(err, msg)) |
| 77 | return h.responseBadRequest(c, err) |
| 78 | } |
| 79 | |
| 80 | if errors := h.validator.ValidateIndex(ctx, request.Sanitize()); len(errors) != 0 { |
| 81 | msg := fmt.Sprintf("validation errors [%s], while fetching phone API keys [%+#v]", spew.Sdump(errors), request) |
| 82 | ctxLogger.Warn(stacktrace.NewError(msg)) |
| 83 | return h.responseUnprocessableEntity(c, errors, "validation errors while fetching phone API keys") |
| 84 | } |
| 85 | |
| 86 | apiKeys, err := h.service.Index(ctx, h.userIDFomContext(c), request.ToIndexParams()) |
| 87 | if err != nil { |
| 88 | msg := fmt.Sprintf("cannot index phone API keys with params [%+#v]", request) |
| 89 | ctxLogger.Error(stacktrace.Propagate(err, msg)) |
| 90 | return h.responseInternalServerError(c) |
| 91 | } |
| 92 | |
| 93 | return h.responseOK(c, fmt.Sprintf("fetched %d phone API %s", len(apiKeys), h.pluralize("key", len(apiKeys))), apiKeys) |
| 94 | } |
| 95 | |
| 96 | // @Summary Store phone API key |
| 97 | // @Description Creates a new phone API key which can be used to log in to the httpSMS app on your Android phone |
nothing calls this directly
no test coverage detected