package adminkindboxservice

import (
	"context"

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

func (s Service) AssignReceiverAgent(ctx context.Context, req param.AssignReceiverRequest) error {
	const op = "AdminKindBoxService.AssignReceiverAgent"

	err := s.repo.AssignReceiverAgent(ctx, entity.KindBox{
		ID:              req.KindBoxID,
		ReceiverAgentID: req.ReceiverAgentID,
	})
	if err != nil {
		return richerror.New(op).WithErr(err)
	}

	return nil
}
