package healthimp

import (
	"net/http"

	"github.com/tech/sendico/pkg/api/http/response"
	"github.com/tech/sendico/pkg/api/routers/health"
	"github.com/tech/sendico/pkg/mlogger"
)

type Status struct {
	logger mlogger.Logger
	status health.ServiceStatus
}

func (hs *Status) healthHandler() http.HandlerFunc {
	return response.Ok(hs.logger, struct {
		Status health.ServiceStatus `json:"status"`
	}{
		hs.status,
	})
}

func (hr *Status) Finish() {
	hr.logger.Info("Finished")
}

func (hs *Status) setStatus(status health.ServiceStatus) {
	hs.status = status
}

func StatusHandler(logger mlogger.Logger) *Status {
	hs := Status{
		status: health.SSCreated,
		logger: logger.Named("status"),
	}
	return &hs
}
