package benefactorkindboxservice

import (
	"context"

	"git.gocasts.ir/ebhomengo/niki/entity"
	param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box"
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)

func (s Service) RegisterEmptyingRequest(ctx context.Context, req param.KindBoxRegisterEmptyingRequest) error {
	const op = "benefactorKindBoxService.RegisterEmptyingRequest"

	err := s.repo.RegisterEmptyingRequestForKindBox(ctx, entity.KindBox{
		ID:                req.KindBoxID,
		ReturnAddressID:   req.ReturnAddressID,
		ReturnReferTimeID: req.ReturnReferTimeID,
		ReturnReferDate:   req.ReturnReferDate,
		Status:            entity.KindBoxReadyToReturnStatus,
		BenefactorID:      req.BenefactorID,
	})
	if err != nil {
		return richerror.New(op).WithErr(err)
	}

	return nil
}
