/
client.go
51 lines (43 loc) · 1.36 KB
/
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
45
46
47
48
49
50
51
package v1
import (
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/service/sync/v1/service"
"github.com/RJPearson94/twilio-sdk-go/service/sync/v1/services"
"github.com/RJPearson94/twilio-sdk-go/session"
"github.com/RJPearson94/twilio-sdk-go/session/credentials"
)
// Sync client is used to manage resources for Twilio Sync
// See https://www.twilio.com/docs/sync for more details
type Sync struct {
client *client.Client
Service func(string) *service.Client
Services *services.Client
}
// Used for testing purposes only
func (s Sync) GetClient() *client.Client {
return s.client
}
// New creates a new instance of the client using session data
func New(sess *session.Session) *Sync {
config := client.GetDefaultConfig()
config.Beta = false
config.SubDomain = "sync"
config.APIVersion = "v1"
return NewWithClient(client.New(sess, config))
}
// NewWithClient creates a new instance of the client with a HTTP client
func NewWithClient(client *client.Client) *Sync {
return &Sync{
client: client,
Service: func(sid string) *service.Client {
return service.New(client, service.ClientProperties{
Sid: sid,
})
},
Services: services.New(client),
}
}
// NewWithCredentials creates a new instance of the client with credentials
func NewWithCredentials(creds *credentials.Credentials) *Sync {
return New(session.New(creds))
}