package sresponse

import (
	"net/http"

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

type resultAuth struct {
	authResponse    `json:",inline"`
	response.Result `json:",inline"`
}

func Success(logger mlogger.Logger, accessToken *TokenData) http.HandlerFunc {
	return response.Ok(logger, &resultAuth{
		Result:       response.Result{Result: true},
		authResponse: authResponse{AccessToken: *accessToken},
	})
}

func Failed(logger mlogger.Logger, accessToken *TokenData) http.HandlerFunc {
	return response.Accepted(logger, &resultAuth{
		Result:       response.Result{Result: false},
		authResponse: authResponse{AccessToken: *accessToken},
	})
}
