/
role_update_example.go
53 lines (45 loc) · 1.21 KB
/
role_update_example.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 main
import (
"log"
"os"
"github.com/RJPearson94/twilio-sdk-go"
v1 "github.com/RJPearson94/twilio-sdk-go/service/conversations/v1"
"github.com/RJPearson94/twilio-sdk-go/service/conversations/v1/service/role"
"github.com/RJPearson94/twilio-sdk-go/session/credentials"
)
var conversationClient *v1.Conversations
func init() {
creds, err := credentials.New(credentials.Account{
Sid: os.Getenv("TWILIO_ACCOUNT_SID"),
AuthToken: os.Getenv("TWILIO_AUTH_TOKEN"),
})
if err != nil {
log.Panicf("%s", err.Error())
}
conversationClient = twilio.NewWithCredentials(creds).Conversations.V1
}
func main() {
resp, err := conversationClient.
Service("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").
Role("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").
Update(&role.UpdateRoleInput{
Permissions: []string{
"deleteConversation",
"removeParticipant",
"editConversationName",
"editConversationAttributes",
"addParticipant",
"sendMessage",
"sendMediaMessage",
"leaveConversation",
"editAnyMessage",
"editAnyMessageAttributes",
"editAnyParticipantAttributes",
"deleteAnyMessage",
},
})
if err != nil {
log.Panicf("%s", err.Error())
}
log.Printf("SID: %s", resp.Sid)
}