-
Notifications
You must be signed in to change notification settings - Fork 0
/
twilio_client.go
44 lines (38 loc) · 1.02 KB
/
twilio_client.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
package hsdp
import (
"github.com/cloudfoundry-community/gautocloud"
"github.com/cloudfoundry-community/gautocloud/connectors"
"github.com/kevinburke/twilio-go"
)
func init() {
gautocloud.RegisterConnector(NewTwilioClientConnector())
}
type TwilioClientConnector struct {
wrapRawConn connectors.Connector
}
func NewTwilioClientConnector() connectors.Connector {
return &TwilioClientConnector{
wrapRawConn: NewTwilioRawConnector(),
}
}
func (c TwilioClientConnector) Id() string {
return "hsdp:twilio-client"
}
func (c TwilioClientConnector) Name() string {
return ".*twilio.*"
}
func (c TwilioClientConnector) Tags() []string {
return []string{"twilio.*"}
}
func (c TwilioClientConnector) Load(schema interface{}) (interface{}, error) {
schema, err := c.wrapRawConn.Load(schema)
if err != nil {
return nil, err
}
fSchema := schema.(TwilioSubAccount)
client := twilio.NewClient(fSchema.SID, fSchema.AuthToken, nil)
return client, nil
}
func (c TwilioClientConnector) Schema() interface{} {
return c.wrapRawConn.Schema()
}