/
services_configuration_notifications.go
191 lines (174 loc) · 9.14 KB
/
services_configuration_notifications.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Conversations
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package openapi
import (
"encoding/json"
"fmt"
"net/url"
"strings"
)
// Fetch push notification service settings
func (c *ApiService) FetchServiceNotification(ChatServiceSid string) (*ConversationsV1ServiceNotification, error) {
path := "/v1/Services/{ChatServiceSid}/Configuration/Notifications"
path = strings.Replace(path, "{"+"ChatServiceSid"+"}", ChatServiceSid, -1)
data := url.Values{}
headers := make(map[string]interface{})
resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
defer resp.Body.Close()
ps := &ConversationsV1ServiceNotification{}
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
return nil, err
}
return ps, err
}
// Optional parameters for the method 'UpdateServiceNotification'
type UpdateServiceNotificationParams struct {
// Weather the notification logging is enabled.
LogEnabled *bool `json:"LogEnabled,omitempty"`
// Whether to send a notification when a new message is added to a conversation. The default is `false`.
NewMessageEnabled *bool `json:"NewMessage.Enabled,omitempty"`
// The template to use to create the notification text displayed when a new message is added to a conversation and `new_message.enabled` is `true`.
NewMessageTemplate *string `json:"NewMessage.Template,omitempty"`
// The name of the sound to play when a new message is added to a conversation and `new_message.enabled` is `true`.
NewMessageSound *string `json:"NewMessage.Sound,omitempty"`
// Whether the new message badge is enabled. The default is `false`.
NewMessageBadgeCountEnabled *bool `json:"NewMessage.BadgeCountEnabled,omitempty"`
// Whether to send a notification when a participant is added to a conversation. The default is `false`.
AddedToConversationEnabled *bool `json:"AddedToConversation.Enabled,omitempty"`
// The template to use to create the notification text displayed when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
AddedToConversationTemplate *string `json:"AddedToConversation.Template,omitempty"`
// The name of the sound to play when a participant is added to a conversation and `added_to_conversation.enabled` is `true`.
AddedToConversationSound *string `json:"AddedToConversation.Sound,omitempty"`
// Whether to send a notification to a user when they are removed from a conversation. The default is `false`.
RemovedFromConversationEnabled *bool `json:"RemovedFromConversation.Enabled,omitempty"`
// The template to use to create the notification text displayed to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
RemovedFromConversationTemplate *string `json:"RemovedFromConversation.Template,omitempty"`
// The name of the sound to play to a user when they are removed from a conversation and `removed_from_conversation.enabled` is `true`.
RemovedFromConversationSound *string `json:"RemovedFromConversation.Sound,omitempty"`
// Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is `false`.
NewMessageWithMediaEnabled *bool `json:"NewMessage.WithMedia.Enabled,omitempty"`
// The template to use to create the notification text displayed when a new message with media/file attachments is added to a conversation and `new_message.attachments.enabled` is `true`.
NewMessageWithMediaTemplate *string `json:"NewMessage.WithMedia.Template,omitempty"`
}
func (params *UpdateServiceNotificationParams) SetLogEnabled(LogEnabled bool) *UpdateServiceNotificationParams {
params.LogEnabled = &LogEnabled
return params
}
func (params *UpdateServiceNotificationParams) SetNewMessageEnabled(NewMessageEnabled bool) *UpdateServiceNotificationParams {
params.NewMessageEnabled = &NewMessageEnabled
return params
}
func (params *UpdateServiceNotificationParams) SetNewMessageTemplate(NewMessageTemplate string) *UpdateServiceNotificationParams {
params.NewMessageTemplate = &NewMessageTemplate
return params
}
func (params *UpdateServiceNotificationParams) SetNewMessageSound(NewMessageSound string) *UpdateServiceNotificationParams {
params.NewMessageSound = &NewMessageSound
return params
}
func (params *UpdateServiceNotificationParams) SetNewMessageBadgeCountEnabled(NewMessageBadgeCountEnabled bool) *UpdateServiceNotificationParams {
params.NewMessageBadgeCountEnabled = &NewMessageBadgeCountEnabled
return params
}
func (params *UpdateServiceNotificationParams) SetAddedToConversationEnabled(AddedToConversationEnabled bool) *UpdateServiceNotificationParams {
params.AddedToConversationEnabled = &AddedToConversationEnabled
return params
}
func (params *UpdateServiceNotificationParams) SetAddedToConversationTemplate(AddedToConversationTemplate string) *UpdateServiceNotificationParams {
params.AddedToConversationTemplate = &AddedToConversationTemplate
return params
}
func (params *UpdateServiceNotificationParams) SetAddedToConversationSound(AddedToConversationSound string) *UpdateServiceNotificationParams {
params.AddedToConversationSound = &AddedToConversationSound
return params
}
func (params *UpdateServiceNotificationParams) SetRemovedFromConversationEnabled(RemovedFromConversationEnabled bool) *UpdateServiceNotificationParams {
params.RemovedFromConversationEnabled = &RemovedFromConversationEnabled
return params
}
func (params *UpdateServiceNotificationParams) SetRemovedFromConversationTemplate(RemovedFromConversationTemplate string) *UpdateServiceNotificationParams {
params.RemovedFromConversationTemplate = &RemovedFromConversationTemplate
return params
}
func (params *UpdateServiceNotificationParams) SetRemovedFromConversationSound(RemovedFromConversationSound string) *UpdateServiceNotificationParams {
params.RemovedFromConversationSound = &RemovedFromConversationSound
return params
}
func (params *UpdateServiceNotificationParams) SetNewMessageWithMediaEnabled(NewMessageWithMediaEnabled bool) *UpdateServiceNotificationParams {
params.NewMessageWithMediaEnabled = &NewMessageWithMediaEnabled
return params
}
func (params *UpdateServiceNotificationParams) SetNewMessageWithMediaTemplate(NewMessageWithMediaTemplate string) *UpdateServiceNotificationParams {
params.NewMessageWithMediaTemplate = &NewMessageWithMediaTemplate
return params
}
// Update push notification service settings
func (c *ApiService) UpdateServiceNotification(ChatServiceSid string, params *UpdateServiceNotificationParams) (*ConversationsV1ServiceNotification, error) {
path := "/v1/Services/{ChatServiceSid}/Configuration/Notifications"
path = strings.Replace(path, "{"+"ChatServiceSid"+"}", ChatServiceSid, -1)
data := url.Values{}
headers := make(map[string]interface{})
if params != nil && params.LogEnabled != nil {
data.Set("LogEnabled", fmt.Sprint(*params.LogEnabled))
}
if params != nil && params.NewMessageEnabled != nil {
data.Set("NewMessage.Enabled", fmt.Sprint(*params.NewMessageEnabled))
}
if params != nil && params.NewMessageTemplate != nil {
data.Set("NewMessage.Template", *params.NewMessageTemplate)
}
if params != nil && params.NewMessageSound != nil {
data.Set("NewMessage.Sound", *params.NewMessageSound)
}
if params != nil && params.NewMessageBadgeCountEnabled != nil {
data.Set("NewMessage.BadgeCountEnabled", fmt.Sprint(*params.NewMessageBadgeCountEnabled))
}
if params != nil && params.AddedToConversationEnabled != nil {
data.Set("AddedToConversation.Enabled", fmt.Sprint(*params.AddedToConversationEnabled))
}
if params != nil && params.AddedToConversationTemplate != nil {
data.Set("AddedToConversation.Template", *params.AddedToConversationTemplate)
}
if params != nil && params.AddedToConversationSound != nil {
data.Set("AddedToConversation.Sound", *params.AddedToConversationSound)
}
if params != nil && params.RemovedFromConversationEnabled != nil {
data.Set("RemovedFromConversation.Enabled", fmt.Sprint(*params.RemovedFromConversationEnabled))
}
if params != nil && params.RemovedFromConversationTemplate != nil {
data.Set("RemovedFromConversation.Template", *params.RemovedFromConversationTemplate)
}
if params != nil && params.RemovedFromConversationSound != nil {
data.Set("RemovedFromConversation.Sound", *params.RemovedFromConversationSound)
}
if params != nil && params.NewMessageWithMediaEnabled != nil {
data.Set("NewMessage.WithMedia.Enabled", fmt.Sprint(*params.NewMessageWithMediaEnabled))
}
if params != nil && params.NewMessageWithMediaTemplate != nil {
data.Set("NewMessage.WithMedia.Template", *params.NewMessageWithMediaTemplate)
}
resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
defer resp.Body.Close()
ps := &ConversationsV1ServiceNotification{}
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
return nil, err
}
return ps, err
}