2024-07-27 14:58:37 +00:00
|
|
|
package kavenegarnotification
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/kavenegar/kavenegar-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (a *Adapter) Send(phoneNumber, message string) {
|
2024-07-30 14:20:49 +00:00
|
|
|
const op = "kavenegarnotification.Send"
|
|
|
|
|
2024-07-27 14:58:37 +00:00
|
|
|
var params *kavenegar.MessageSendParam
|
|
|
|
if _, err := a.adapter.Client().Message.Send(a.adapter.Config().Sender, []string{phoneNumber}, message, params); err != nil {
|
|
|
|
//nolint
|
|
|
|
switch err := err.(type) {
|
|
|
|
case *kavenegar.APIError:
|
|
|
|
// log error
|
|
|
|
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
|
|
|
case *kavenegar.HTTPError:
|
|
|
|
// log error
|
|
|
|
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
|
|
|
default:
|
|
|
|
// log error
|
|
|
|
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|