/
api_op_update.go
78 lines (68 loc) · 3.32 KB
/
api_op_update.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
// Package conversation contains auto-generated files. DO NOT MODIFY
package conversation
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/utils"
)
type UpdateConversationTimersInput struct {
Closed *string `form:"Closed,omitempty"`
Inactive *string `form:"Inactive,omitempty"`
}
// UpdateConversationInput defines input fields for updating a conversation resource
type UpdateConversationInput 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 *UpdateConversationTimersInput `form:"Timers,omitempty"`
}
type UpdateConversationTimersResponse struct {
DateClosed *time.Time `json:"date_closed,omitempty"`
DateInactive *time.Time `json:"date_inactive,omitempty"`
}
// UpdateConversationResponse defines the response fields for the updated conversation
type UpdateConversationResponse 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 UpdateConversationTimersResponse `json:"timers"`
URL string `json:"url"`
}
// Update modifies a conversation resource
// See https://www.twilio.com/docs/conversations/api/conversation-resource#update-conversation for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Update(input *UpdateConversationInput) (*UpdateConversationResponse, error) {
return c.UpdateWithContext(context.Background(), input)
}
// UpdateWithContext modifies a conversation resource
// See https://www.twilio.com/docs/conversations/api/conversation-resource#update-conversation for more details
func (c Client) UpdateWithContext(context context.Context, input *UpdateConversationInput) (*UpdateConversationResponse, error) {
op := client.Operation{
Method: http.MethodPost,
URI: "/Services/{serviceSid}/Conversations/{sid}",
ContentType: client.URLEncoded,
PathParams: map[string]string{
"serviceSid": c.serviceSid,
"sid": c.sid,
},
}
if input == nil {
input = &UpdateConversationInput{}
}
response := &UpdateConversationResponse{}
if err := c.client.Send(context, op, input, response); err != nil {
return nil, err
}
return response, nil
}