2024-06-01 18:01:00 +00:00
|
|
|
package benefactoraddresshandler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
|
|
|
|
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
|
|
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetAddresses godoc
|
|
|
|
// @Summary Get all benefactor addresses
|
|
|
|
// @Tags Address
|
|
|
|
// @Accept json
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} param.GetAllAddressesResponse
|
|
|
|
// @Failure 400 {string} "Bad request"
|
|
|
|
// @Security AuthBearerBenefactor
|
2024-06-14 08:41:36 +00:00
|
|
|
// @Router /address/ [get].
|
2024-06-01 18:01:00 +00:00
|
|
|
func (h Handler) GetAddresses(c echo.Context) error {
|
|
|
|
var req param.GetAllAddressesRequest
|
|
|
|
|
|
|
|
claims := claim.GetClaimsFromEchoContext(c)
|
|
|
|
req.BenefactorID = claims.UserID
|
|
|
|
|
|
|
|
resp, sErr := h.addressSvc.GetAll(c.Request().Context(), req)
|
|
|
|
if sErr != nil {
|
|
|
|
msg, code := httpmsg.Error(sErr)
|
|
|
|
|
|
|
|
return echo.NewHTTPError(code, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(http.StatusOK, resp)
|
|
|
|
}
|