-
Notifications
You must be signed in to change notification settings - Fork 5
/
api_op_create.go
61 lines (53 loc) · 2.12 KB
/
api_op_create.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
58
59
60
61
// Package users contains auto-generated files. DO NOT MODIFY
package users
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
)
// CreateUserInput defines the input fields for creating a new user resource
type CreateUserInput struct {
Attributes *string `form:"Attributes,omitempty"`
FriendlyName *string `form:"FriendlyName,omitempty"`
Identity string `validate:"required" form:"Identity"`
RoleSid *string `form:"RoleSid,omitempty"`
}
// CreateUserResponse defines the response fields for the created user
type CreateUserResponse struct {
AccountSid string `json:"account_sid"`
Attributes string `json:"attributes"`
ChatServiceSid string `json:"chat_service_sid"`
DateCreated time.Time `json:"date_created"`
DateUpdated *time.Time `json:"date_updated,omitempty"`
FriendlyName *string `json:"friendly_name,omitempty"`
Identity string `json:"identity"`
IsNotifiable *bool `json:"is_notifiable,omitempty"`
IsOnline *bool `json:"is_online,omitempty"`
RoleSid string `json:"role_sid"`
Sid string `json:"sid"`
URL string `json:"url"`
}
// Create creates a new user
// See https://www.twilio.com/docs/conversations/api/user-resource#create-a-conversations-user for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Create(input *CreateUserInput) (*CreateUserResponse, error) {
return c.CreateWithContext(context.Background(), input)
}
// CreateWithContext creates a new user
// See https://www.twilio.com/docs/conversations/api/user-resource#create-a-conversations-user for more details
func (c Client) CreateWithContext(context context.Context, input *CreateUserInput) (*CreateUserResponse, error) {
op := client.Operation{
Method: http.MethodPost,
URI: "/Users",
ContentType: client.URLEncoded,
}
if input == nil {
input = &CreateUserInput{}
}
response := &CreateUserResponse{}
if err := c.client.Send(context, op, input, response); err != nil {
return nil, err
}
return response, nil
}