package benefactorrefertimehandler

import (
	"net/http"

	refertimeparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/refer_time"
	httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
	"github.com/labstack/echo/v4"
)

// GetAll godoc
// @Summary      Get all refer times
// @Tags         Benefactors ReferTimes
// @Accept       json
// @Produce      json
// @Success      200  {object}  benefactorrefertimeparam.GetAllReferTimeResponse
// @Failure      400  {string}  "Bad request"
// @Security 	 AuthBearerBenefactor
// @Router       /benefactors/refer-times [get].
func (h Handler) GetAll(c echo.Context) error {
	var req refertimeparam.GetAllReferTimeRequest

	listReferTimes, err := h.benefactorReferTimeSvc.GetAll(c.Request().Context(), req)
	if err != nil {
		msg, code := httpmsg.Error(err)

		return echo.NewHTTPError(code, msg)
	}

	return c.JSON(http.StatusOK, listReferTimes)
}
