package agent

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/dig"

	"github.com/tidbcloud/aisupport/packages/sdk-go/infra/apiserver"
	"github.com/tidbcloud/aisupport/services/ticket-manager/internal/app"
	agentapi "github.com/tidbcloud/aisupport/services/ticket-manager/internal/services/agent/api"
)

type HandlerParam struct {
	dig.In

	Agent agentapi.Service
}

type Handler struct {
	agent agentapi.Service
}

func NewHandler(param HandlerParam) app.HandlerResult {
	return app.HandlerResult{
		Handler: &Handler{
			agent: param.Agent,
		},
	}
}

func (h *Handler) Name() string {
	return "AgentHandler"
}

func (h *Handler) Register(routers map[apiserver.RoutePath]gin.IRouter) error {
	router := routers[app.APIRoutePath]
	router.POST("/agent-gateway/events", h.HandleAgentGatewayEvent)
	return nil
}
