/
api_op_create.go
65 lines (57 loc) · 2.52 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
62
63
64
65
// Package assistants contains auto-generated files. DO NOT MODIFY
package assistants
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
)
// CreateAssistantInput defines the input fields for creating a new assistant resource
type CreateAssistantInput struct {
CallbackEvents *string `form:"CallbackEvents,omitempty"`
CallbackURL *string `form:"CallbackUrl,omitempty"`
Defaults *string `form:"Defaults,omitempty"`
FriendlyName *string `form:"FriendlyName,omitempty"`
LogQueries *bool `form:"LogQueries,omitempty"`
StyleSheet *string `form:"StyleSheet,omitempty"`
UniqueName *string `form:"UniqueName,omitempty"`
}
// CreateAssistantResponse defines the response fields for the created assistant
type CreateAssistantResponse struct {
AccountSid string `json:"account_sid"`
CallbackEvents *string `json:"callback_events,omitempty"`
CallbackURL *string `json:"callback_url,omitempty"`
DateCreated time.Time `json:"date_created"`
DateUpdated *time.Time `json:"date_updated,omitempty"`
DevelopmentStage string `json:"development_stage"`
FriendlyName *string `json:"friendly_name,omitempty"`
LatestModelBuildSid *string `json:"latest_model_build_sid,omitempty"`
LogQueries bool `json:"log_queries"`
NeedsModelBuild *bool `json:"needs_model_build,omitempty"`
Sid string `json:"sid"`
URL string `json:"url"`
UniqueName string `json:"unique_name"`
}
// Create creates a new assistant
// See https://www.twilio.com/docs/autopilot/api/assistant#create-an-assistant-resource for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Create(input *CreateAssistantInput) (*CreateAssistantResponse, error) {
return c.CreateWithContext(context.Background(), input)
}
// CreateWithContext creates a new assistant
// See https://www.twilio.com/docs/autopilot/api/assistant#create-an-assistant-resource for more details
func (c Client) CreateWithContext(context context.Context, input *CreateAssistantInput) (*CreateAssistantResponse, error) {
op := client.Operation{
Method: http.MethodPost,
URI: "/Assistants",
ContentType: client.URLEncoded,
}
if input == nil {
input = &CreateAssistantInput{}
}
response := &CreateAssistantResponse{}
if err := c.client.Send(context, op, input, response); err != nil {
return nil, err
}
return response, nil
}