package handler import ( "fmt" "gitea.urkob.com/urko/ess-etl-go/internal/request" "gitea.urkob.com/urko/ess-etl-go/internal/xml_loader" "github.com/gofiber/fiber/v2" ) type AMSEmployeeWIHandler struct { ewiLoader xml_loader.EmployeeWILoader } func NewAMSEmployeeWIHandler(AmsApi, AmsApiKey string) *AMSEmployeeWIHandler { return &AMSEmployeeWIHandler{ ewiLoader: xml_loader.NewEmployeeWILoader(request.NewRequestService(AmsApi, AmsApiKey)), } } func (hdl *AMSEmployeeWIHandler) Get(c *fiber.Ctx) error { id := c.Params("id", "") if id == "" { return JSONError(c, fiber.StatusBadRequest, fmt.Errorf("id is empty"), defaultErrMessage) } from, to := "2023-01-16", "2023-01-16" employeeWI, err := hdl.ewiLoader.LoadEmployee(id, from, to) if err != nil { return JSONError(c, fiber.StatusBadRequest, fmt.Errorf("ewiLoader.LoadEmployee: %s", err), defaultErrMessage) } return c.Status(fiber.StatusOK).JSON(employeeWI) }