package http

import (
	"fmt"

	"git.gocasts.ir/ebhomengo/niki/pkg/http_server"
)

type Server struct {
	HTTPServer http_server.Server
	Handler    Handler
}

func New(server http_server.Server, handler Handler) Server {
	return Server{
		HTTPServer: server,
		Handler:    handler,
	}
}

func (s Server) Serve() {
	s.RegisterRoutes()

	if err := s.HTTPServer.Start(); err != nil {
		fmt.Println("router start error", err)
	}
}

func (s Server) RegisterRoutes() {
	v1 := s.HTTPServer.Router.Group("/v1")

	v1.GET("/health_check", s.HealthCheck)
	v1.POST("/send_otp", s.Handler.SendOtp)
	v1.POST("/login_or_register", s.Handler.loginOrRegister)

}
