/
api_op_create.go
79 lines (69 loc) · 3.47 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Package conversations contains auto-generated files. DO NOT MODIFY
package conversations
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/utils"
)
type CreateConversationTimersInput struct {
Closed *string `form:"Closed,omitempty"`
Inactive *string `form:"Inactive,omitempty"`
}
// CreateConversationInput defines the input fields for creating a new conversation resource
type CreateConversationInput struct {
Attributes *string `form:"Attributes,omitempty"`
DateCreated *utils.RFC2822Time `form:"DateCreated,omitempty"`
DateUpdated *utils.RFC2822Time `form:"DateUpdated,omitempty"`
FriendlyName *string `form:"FriendlyName,omitempty"`
MessagingServiceSid *string `form:"MessagingServiceSid,omitempty"`
State *string `form:"State,omitempty"`
Timers *CreateConversationTimersInput `form:"Timers,omitempty"`
UniqueName *string `form:"UniqueName,omitempty"`
}
type CreateConversationTimersResponse struct {
DateClosed *time.Time `json:"date_closed,omitempty"`
DateInactive *time.Time `json:"date_inactive,omitempty"`
}
// CreateConversationResponse defines the response fields for the created conversation
type CreateConversationResponse struct {
AccountSid string `json:"account_sid"`
Attributes string `json:"attributes"`
ChatServiceSid *string `json:"chat_service_sid,omitempty"`
DateCreated time.Time `json:"date_created"`
DateUpdated *time.Time `json:"date_updated,omitempty"`
FriendlyName *string `json:"friendly_name,omitempty"`
MessagingServiceSid *string `json:"messaging_service_sid,omitempty"`
Sid string `json:"sid"`
State string `json:"state"`
Timers CreateConversationTimersResponse `json:"timers"`
URL string `json:"url"`
UniqueName *string `json:"unique_name,omitempty"`
}
// Create creates a new conversation
// See https://www.twilio.com/docs/conversations/api/conversation-resource#create-a-conversation-resource for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Create(input *CreateConversationInput) (*CreateConversationResponse, error) {
return c.CreateWithContext(context.Background(), input)
}
// CreateWithContext creates a new conversation
// See https://www.twilio.com/docs/conversations/api/conversation-resource#create-a-conversation-resource for more details
func (c Client) CreateWithContext(context context.Context, input *CreateConversationInput) (*CreateConversationResponse, error) {
op := client.Operation{
Method: http.MethodPost,
URI: "/Services/{serviceSid}/Conversations",
ContentType: client.URLEncoded,
PathParams: map[string]string{
"serviceSid": c.serviceSid,
},
}
if input == nil {
input = &CreateConversationInput{}
}
response := &CreateConversationResponse{}
if err := c.client.Send(context, op, input, response); err != nil {
return nil, err
}
return response, nil
}