-
Notifications
You must be signed in to change notification settings - Fork 2
/
nexmo.go
45 lines (35 loc) · 909 Bytes
/
nexmo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package nexmo
import (
"errors"
"github.com/kadisoka/iam/pkg/iamserver/pnv10n"
)
const ServiceName = "nexmo"
func init() {
pnv10n.RegisterModule(
ServiceName,
pnv10n.Module{
ConfigSkeleton: func() interface{} { cfg := ConfigSkeleton(); return &cfg },
NewSMSDeliveryService: NewSMSDeliveryService,
})
}
type SMSDeliveryService struct {
config *Config
}
var _ pnv10n.SMSDeliveryService = &SMSDeliveryService{}
const apiBaseURL = "https://rest.nexmo.com/sms"
func NewSMSDeliveryService(config interface{}) pnv10n.SMSDeliveryService {
if config == nil {
panic(errors.New("configuration required"))
}
conf, ok := config.(*Config)
if !ok {
panic(errors.New("configuration of invalid type"))
}
if conf.APIKey == "" {
panic("NEXMO API Key not provided")
}
if conf.APISecret == "" {
panic("NEXMO API Secret not provided")
}
return &SMSDeliveryService{config: conf}
}