/
api_op_update.go
72 lines (64 loc) · 2.91 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
// Package message contains auto-generated files. DO NOT MODIFY
package message
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
)
// UpdateChannelMessageInput defines input fields for updating a message resource
type UpdateChannelMessageInput struct {
Attributes *string `form:"Attributes,omitempty"`
Body *string `form:"Body,omitempty"`
DateCreated *time.Time `form:"DateCreated,omitempty"`
DateUpdated *time.Time `form:"DateUpdated,omitempty"`
From *string `form:"From,omitempty"`
LastUpdatedBy *string `form:"LastUpdatedBy,omitempty"`
}
// UpdateChannelMessageResponse defines the response fields for the updated message
type UpdateChannelMessageResponse struct {
AccountSid string `json:"account_sid"`
Attributes *string `json:"attributes,omitempty"`
Body *string `json:"body,omitempty"`
ChannelSid string `json:"channel_sid"`
DateCreated time.Time `json:"date_created"`
DateUpdated *time.Time `json:"date_updated,omitempty"`
From *string `json:"from,omitempty"`
Index *int `json:"index,omitempty"`
LastUpdatedBy *string `json:"last_updated_by,omitempty"`
Media *map[string]interface{} `json:"media,omitempty"`
ServiceSid string `json:"service_sid"`
Sid string `json:"sid"`
To *string `json:"to,omitempty"`
Type *string `json:"type,omitempty"`
URL string `json:"url"`
WasEdited *bool `json:"was_edited,omitempty"`
}
// Update modifies a message resource
// See https://www.twilio.com/docs/chat/rest/message-resource#update-a-message-resource for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Update(input *UpdateChannelMessageInput) (*UpdateChannelMessageResponse, error) {
return c.UpdateWithContext(context.Background(), input)
}
// UpdateWithContext modifies a message resource
// See https://www.twilio.com/docs/chat/rest/message-resource#update-a-message-resource for more details
func (c Client) UpdateWithContext(context context.Context, input *UpdateChannelMessageInput) (*UpdateChannelMessageResponse, error) {
op := client.Operation{
Method: http.MethodPost,
URI: "/Services/{serviceSid}/Channels/{channelSid}/Messages/{sid}",
ContentType: client.URLEncoded,
PathParams: map[string]string{
"serviceSid": c.serviceSid,
"channelSid": c.channelSid,
"sid": c.sid,
},
}
if input == nil {
input = &UpdateChannelMessageInput{}
}
response := &UpdateChannelMessageResponse{}
if err := c.client.Send(context, op, input, response); err != nil {
return nil, err
}
return response, nil
}