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
|
2024-08-27 17:49:34 +00:00
|
|
|
// @Tags Benefactors Addresses
|
2024-06-01 18:01:00 +00:00
|
|
|
// @Accept json
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} param.GetAllAddressesResponse
|
|
|
|
// @Failure 400 {string} "Bad request"
|
|
|
|
// @Security AuthBearerBenefactor
|
2024-08-27 17:49:34 +00:00
|
|
|
// @Router /benefactors/addresses [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)
|
|
|
|
}
|