package adminrefertimeservice

import (
	"context"

	param "git.gocasts.ir/ebhomengo/niki/param/admin/refer_time"
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)

func (s Service) GetReferTimeByID(ctx context.Context, req param.GetReferTimeRequest) (param.GetReferTimeResponse, error) {
	const op = "adminrefertimeservice.GetReferTimeByID"
	referTime, gErr := s.repo.Get(ctx, req.ReferTimeID)
	if gErr != nil {
		return param.GetReferTimeResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected)
	}

	return param.GetReferTimeResponse{
		Data: param.Data{
			ID:       referTime.ID,
			Status:   referTime.Status,
			Duration: referTime.Duration,
		},
	}, nil
}
