app-cloudep-notification-se.../internal/usecase/mitake.go

37 lines
755 B
Go

package usecase
import (
"app-cloudep-notification-service/internal/config"
"app-cloudep-notification-service/internal/domain/usecase"
"context"
"github.com/minchao/go-mitake"
)
type SMSUseCaseParam struct {
Conf config.Config
}
type SMSUseCase struct {
Client *mitake.Client
}
func (s *SMSUseCase) SendSMS(_ context.Context, req usecase.SMSReq) error {
message := mitake.Message{
Dstaddr: req.RecipientAddress,
Destname: req.RecipientName,
Smbody: req.Body,
}
_, err := s.Client.Send(message)
if err != nil {
return err
}
return nil
}
func MustMitakeUseCase(param SMSUseCaseParam) usecase.SMSClientUseCase {
return &SMSUseCase{
Client: mitake.NewClient(param.Conf.SMSSender.User, param.Conf.SMSSender.Password, nil),
}
}