/
client.go
57 lines (49 loc) · 1.69 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
52
53
54
55
56
57
// Package v2 contains auto-generated files. DO NOT MODIFY
package v2
import (
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/service/chat/v2/credential"
"github.com/RJPearson94/twilio-sdk-go/service/chat/v2/credentials"
"github.com/RJPearson94/twilio-sdk-go/service/chat/v2/service"
"github.com/RJPearson94/twilio-sdk-go/service/chat/v2/services"
"github.com/RJPearson94/twilio-sdk-go/session"
)
// Chat client is used to manage resources for Programmable Chat
// See https://www.twilio.com/docs/chat for more details
type Chat struct {
client *client.Client
Credential func(string) *credential.Client
Credentials *credentials.Client
Service func(string) *service.Client
Services *services.Client
}
// NewWithClient creates a new instance of the client with a HTTP client
func NewWithClient(client *client.Client) *Chat {
return &Chat{
client: client,
Credential: func(credentialSid string) *credential.Client {
return credential.New(client, credential.ClientProperties{
Sid: credentialSid,
})
},
Credentials: credentials.New(client),
Service: func(serviceSid string) *service.Client {
return service.New(client, service.ClientProperties{
Sid: serviceSid,
})
},
Services: services.New(client),
}
}
// GetClient is used for testing purposes only
func (s Chat) GetClient() *client.Client {
return s.client
}
// New creates a new instance of the client using session data and config
func New(sess *session.Session, clientConfig *client.Config) *Chat {
config := client.NewAPIClientConfig(clientConfig)
config.Beta = false
config.SubDomain = "chat"
config.APIVersion = "v2"
return NewWithClient(client.New(sess, config))
}