/
client.go
53 lines (46 loc) · 1.53 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
package v2
import (
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/service/studio/v2/flow"
"github.com/RJPearson94/twilio-sdk-go/service/studio/v2/flow_validation"
"github.com/RJPearson94/twilio-sdk-go/service/studio/v2/flows"
"github.com/RJPearson94/twilio-sdk-go/session"
"github.com/RJPearson94/twilio-sdk-go/session/credentials"
)
// Studio client is used to manage resources for Twilio Studio
// See https://www.twilio.com/docs/studio for more details
type Studio struct {
client *client.Client
Flow func(string) *flow.Client
Flows *flows.Client
FlowValidation *flow_validation.Client
}
// Used for testing purposes only
func (s Studio) GetClient() *client.Client {
return s.client
}
// New creates a new instance of the client using session data
func New(sess *session.Session) *Studio {
config := client.GetDefaultConfig()
config.Beta = true
config.SubDomain = "studio"
config.APIVersion = "v2"
return NewWithClient(client.New(sess, config))
}
// NewWithClient creates a new instance of the client with a HTTP client
func NewWithClient(client *client.Client) *Studio {
return &Studio{
client: client,
Flows: flows.New(client),
Flow: func(sid string) *flow.Client {
return flow.New(client, flow.ClientProperties{
Sid: sid,
})
},
FlowValidation: flow_validation.New(client),
}
}
// NewWithCredentials creates a new instance of the client with credentials
func NewWithCredentials(creds *credentials.Credentials) *Studio {
return New(session.New(creds))
}