package notification

import (
	"context"
	"fmt"

	params "git.gocasts.ir/ebhomengo/niki/param"
	bnfparam "git.gocasts.ir/ebhomengo/niki/param/admin/benefactor"
	kbp "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
	smsmsg "git.gocasts.ir/ebhomengo/niki/pkg/sms_msg"
)

func (s Service) KindBoxEnumerated(req params.NotificationKindBoxEnumerated) {
	const op = "notification.KindBoxEnumerated"

	ctx := context.Background()
	kb, err := s.KindBoxSvc.Get(ctx, kbp.KindBoxGetRequest{
		KindBoxID: req.KindBoxID,
	})
	if err != nil {
		fmt.Println(fmt.Errorf("error(%s):%w", op, err))
	}
	bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.Data.BenefactorID})
	if gErr != nil {
		fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
	}
	s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxEnumerated, bnf.Data.FirstName, kb.Data.SerialNumber, kb.Data.Amount))
}
