package service

import (
	"github.com/UpmeshLTD/urus-aio/infrastructure/db/entities"
	gin2 "github.com/UpmeshLTD/urus-aio/infrastructure/server/transport/http/gin"
	"github.com/UpmeshLTD/urus-aio/infrastructure/server/transport/http/gin/middleware"
	"github.com/UpmeshLTD/urus-aio/shipment/server/http/dto"
	"github.com/UpmeshLTD/urus-aio/shipment/service/transform"
	"github.com/gin-gonic/gin"
)

type iBusinessProfile interface {
	GetBusinessProfile(ctx *gin.Context)
}

// GetBusinessProfile godoc
// @Summary Get business profile by ID
// @Description Get business profile by ID
// @Tags BusinessProfile
// @Accept json
// @Produce json
// @Param userworkspace header string true "User workspace")
// @Param id path string true "Business Profile ID"
// @Success 200 {object} dto.BusinessProfile
// @Security BearerToken
// @Router /business-profiles/{id} [GET]
func (s *serviceImpl) GetBusinessProfile(c *gin.Context) {
	req := dto.GetBusinessProfileRequest{}
	if err := c.BindUri(&req); err != nil {
		gin2.ResponseBadRequest(c, err)
		return
	}
	profile, err := s.businessProfileDomain.GetBusinessProfile(c.Request.Context(), &entities.BusinessProfile{
		ID:          req.ID,
		WorkspaceID: middleware.GetWorkspaceId(c),
	})
	if err != nil {
		gin2.ResponseInternalServerError(c, err)
		return
	}

	gin2.ResponseSuccess(c, transform.BusinessProfileEntityToDTO(profile))
}
