Index returns the phones of a user @Summary Get phones of a user @Description Get list of phones which a user has registered on the http sms application @Security ApiKeyAuth @Tags Phones @Accept json @Produce json @Param skip query int false "number of heartbeats
(c fiber.Ctx)
| 67 | // @Failure 500 {object} responses.InternalServerError |
| 68 | // @Router /phones [get] |
| 69 | func (h *PhoneHandler) Index(c fiber.Ctx) error { |
| 70 | ctx, span := h.tracer.StartFromFiberCtx(c) |
| 71 | defer span.End() |
| 72 | |
| 73 | ctxLogger := h.tracer.CtxLogger(h.logger, span) |
| 74 | |
| 75 | var request requests.PhoneIndex |
| 76 | if err := c.Bind().Query(&request); err != nil { |
| 77 | msg := fmt.Sprintf("cannot marshall params [%s] into %T", c.OriginalURL(), request) |
| 78 | ctxLogger.Warn(stacktrace.Propagate(err, msg)) |
| 79 | return h.responseBadRequest(c, err) |
| 80 | } |
| 81 | |
| 82 | if errors := h.validator.ValidateIndex(ctx, request.Sanitize()); len(errors) != 0 { |
| 83 | msg := fmt.Sprintf("validation errors [%s], while fetching phones [%+#v]", spew.Sdump(errors), request) |
| 84 | ctxLogger.Warn(stacktrace.NewError(msg)) |
| 85 | return h.responseUnprocessableEntity(c, errors, "validation errors while fetching phones") |
| 86 | } |
| 87 | |
| 88 | phones, err := h.service.Index(ctx, h.userFromContext(c), request.ToIndexParams()) |
| 89 | if err != nil { |
| 90 | msg := fmt.Sprintf("cannot index phones with params [%+#v]", request) |
| 91 | ctxLogger.Error(stacktrace.Propagate(err, msg)) |
| 92 | return h.responseInternalServerError(c) |
| 93 | } |
| 94 | |
| 95 | return h.responseOK(c, fmt.Sprintf("fetched %d %s", len(*phones), h.pluralize("phone", len(*phones))), phones) |
| 96 | } |
| 97 | |
| 98 | // Upsert a phone |
| 99 | // @Summary Upsert Phone |
nothing calls this directly
no test coverage detected