2024-08-16 17:37:37 +00:00
|
|
|
package notification
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
params "git.gocasts.ir/ebhomengo/niki/param"
|
|
|
|
bnfparam "git.gocasts.ir/ebhomengo/niki/param/admin/benefactor"
|
|
|
|
kbparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
|
|
smsmsg "git.gocasts.ir/ebhomengo/niki/pkg/sms_msg"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) KindBoxReqAdded(req params.NotificationKindBoxReqAdded) {
|
|
|
|
const op = "notification.KindBoxReqAdded"
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), s.cfg.Timeout)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
kb, err := s.KindBoxReqSvc.Get(ctx, kbparam.GetKindBoxReqRequest{
|
|
|
|
KindBoxID: req.KindBoxReqID,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
|
|
|
}
|
2024-09-10 20:55:19 +00:00
|
|
|
bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.Data.BenefactorID})
|
2024-08-16 17:37:37 +00:00
|
|
|
if gErr != nil {
|
|
|
|
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
|
|
|
}
|
|
|
|
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqAdded, bnf.FirstName))
|
|
|
|
}
|