package benefactoraddresshandler

import (
	"net/http"

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

// GetAllCities godoc
// @Summary      Get all cities
// @Tags         Benefactors Addresses
// @Accept       json
// @Produce      json
// @Success      200  {object}  addressparam.GetAllCitiesResponse
// @Failure      400  {string}  "Bad request"
// @Router       /benefactors/addresses/cities [get].
func (h Handler) GetAllCities(c echo.Context) error {
	var req addressparam.GetAllCitiesRequest

	listCities, err := h.addressSvc.GetAllCities(c.Request().Context(), req)
	if err != nil {
		msg, code := httpmsg.Error(err)

		return echo.NewHTTPError(code, msg)
	}

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