Class: Twilio::REST::Conversations::V1::ServiceContext::ConfigurationContext::NotificationContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, chat_service_sid) ⇒ NotificationContext

Initialize the NotificationContext

Parameters:



53
54
55
56
57
58
59
60
61
62
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 53

def initialize(version, chat_service_sid)
    super(version)
    

    # Path Solution
    @solution = { chat_service_sid: chat_service_sid,  }
    @uri = "/Services/#{@solution[:chat_service_sid]}/Configuration/Notifications"

    
end

Instance Method Details

#fetchNotificationInstance

Fetch the NotificationInstance

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 66

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    NotificationInstance.new(
        @version,
        payload,
        chat_service_sid: @solution[:chat_service_sid],
    )
end

#fetch_with_metadataNotificationInstance

Fetch the NotificationInstanceMetadata

Returns:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 85

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    notification_instance = NotificationInstance.new(
        @version,
        response.body,
        chat_service_sid: @solution[:chat_service_sid],
    )
    .new(
        @version,
        notification_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



247
248
249
250
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 247

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Conversations.V1.NotificationContext #{context}>"
end

#to_sObject

Provide a user friendly representation



240
241
242
243
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 240

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Conversations.V1.NotificationContext #{context}>"
end

#update(log_enabled: :unset, new_message_enabled: :unset, new_message_template: :unset, new_message_sound: :unset, new_message_badge_count_enabled: :unset, added_to_conversation_enabled: :unset, added_to_conversation_template: :unset, added_to_conversation_sound: :unset, removed_from_conversation_enabled: :unset, removed_from_conversation_template: :unset, removed_from_conversation_sound: :unset, new_message_with_media_enabled: :unset, new_message_with_media_template: :unset) ⇒ NotificationInstance

Update the NotificationInstance

Parameters:

  • log_enabled (Boolean) (defaults to: :unset)

    Weather the notification logging is enabled.

  • new_message_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification when a new message is added to a conversation. The default is false.

  • new_message_template (String) (defaults to: :unset)

    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.

  • new_message_sound (String) (defaults to: :unset)

    The name of the sound to play when a new message is added to a conversation and new_message.enabled is true.

  • new_message_badge_count_enabled (Boolean) (defaults to: :unset)

    Whether the new message badge is enabled. The default is false.

  • added_to_conversation_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification when a participant is added to a conversation. The default is false.

  • added_to_conversation_template (String) (defaults to: :unset)

    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.

  • added_to_conversation_sound (String) (defaults to: :unset)

    The name of the sound to play when a participant is added to a conversation and added_to_conversation.enabled is true.

  • removed_from_conversation_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification to a user when they are removed from a conversation. The default is false.

  • removed_from_conversation_template (String) (defaults to: :unset)

    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.

  • removed_from_conversation_sound (String) (defaults to: :unset)

    The name of the sound to play to a user when they are removed from a conversation and removed_from_conversation.enabled is true.

  • new_message_with_media_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is false.

  • new_message_with_media_template (String) (defaults to: :unset)

    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.

Returns:



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
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 123

def update(
    log_enabled: :unset, 
    new_message_enabled: :unset, 
    new_message_template: :unset, 
    new_message_sound: :unset, 
    new_message_badge_count_enabled: :unset, 
    added_to_conversation_enabled: :unset, 
    added_to_conversation_template: :unset, 
    added_to_conversation_sound: :unset, 
    removed_from_conversation_enabled: :unset, 
    removed_from_conversation_template: :unset, 
    removed_from_conversation_sound: :unset, 
    new_message_with_media_enabled: :unset, 
    new_message_with_media_template: :unset
)

    data = Twilio::Values.of({
        'LogEnabled' => log_enabled,
        'NewMessage.Enabled' => new_message_enabled,
        'NewMessage.Template' => new_message_template,
        'NewMessage.Sound' => new_message_sound,
        'NewMessage.BadgeCountEnabled' => new_message_badge_count_enabled,
        'AddedToConversation.Enabled' => added_to_conversation_enabled,
        'AddedToConversation.Template' => added_to_conversation_template,
        'AddedToConversation.Sound' => added_to_conversation_sound,
        'RemovedFromConversation.Enabled' => removed_from_conversation_enabled,
        'RemovedFromConversation.Template' => removed_from_conversation_template,
        'RemovedFromConversation.Sound' => removed_from_conversation_sound,
        'NewMessage.WithMedia.Enabled' => new_message_with_media_enabled,
        'NewMessage.WithMedia.Template' => new_message_with_media_template,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    NotificationInstance.new(
        @version,
        payload,
        chat_service_sid: @solution[:chat_service_sid],
    )
end

#update_with_metadata(log_enabled: :unset, new_message_enabled: :unset, new_message_template: :unset, new_message_sound: :unset, new_message_badge_count_enabled: :unset, added_to_conversation_enabled: :unset, added_to_conversation_template: :unset, added_to_conversation_sound: :unset, removed_from_conversation_enabled: :unset, removed_from_conversation_template: :unset, removed_from_conversation_sound: :unset, new_message_with_media_enabled: :unset, new_message_with_media_template: :unset) ⇒ NotificationInstance

Update the NotificationInstanceMetadata

Parameters:

  • log_enabled (Boolean) (defaults to: :unset)

    Weather the notification logging is enabled.

  • new_message_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification when a new message is added to a conversation. The default is false.

  • new_message_template (String) (defaults to: :unset)

    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.

  • new_message_sound (String) (defaults to: :unset)

    The name of the sound to play when a new message is added to a conversation and new_message.enabled is true.

  • new_message_badge_count_enabled (Boolean) (defaults to: :unset)

    Whether the new message badge is enabled. The default is false.

  • added_to_conversation_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification when a participant is added to a conversation. The default is false.

  • added_to_conversation_template (String) (defaults to: :unset)

    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.

  • added_to_conversation_sound (String) (defaults to: :unset)

    The name of the sound to play when a participant is added to a conversation and added_to_conversation.enabled is true.

  • removed_from_conversation_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification to a user when they are removed from a conversation. The default is false.

  • removed_from_conversation_template (String) (defaults to: :unset)

    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.

  • removed_from_conversation_sound (String) (defaults to: :unset)

    The name of the sound to play to a user when they are removed from a conversation and removed_from_conversation.enabled is true.

  • new_message_with_media_enabled (Boolean) (defaults to: :unset)

    Whether to send a notification when a new message with media/file attachments is added to a conversation. The default is false.

  • new_message_with_media_template (String) (defaults to: :unset)

    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.

Returns:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 185

def (
  log_enabled: :unset, 
  new_message_enabled: :unset, 
  new_message_template: :unset, 
  new_message_sound: :unset, 
  new_message_badge_count_enabled: :unset, 
  added_to_conversation_enabled: :unset, 
  added_to_conversation_template: :unset, 
  added_to_conversation_sound: :unset, 
  removed_from_conversation_enabled: :unset, 
  removed_from_conversation_template: :unset, 
  removed_from_conversation_sound: :unset, 
  new_message_with_media_enabled: :unset, 
  new_message_with_media_template: :unset
)

    data = Twilio::Values.of({
        'LogEnabled' => log_enabled,
        'NewMessage.Enabled' => new_message_enabled,
        'NewMessage.Template' => new_message_template,
        'NewMessage.Sound' => new_message_sound,
        'NewMessage.BadgeCountEnabled' => new_message_badge_count_enabled,
        'AddedToConversation.Enabled' => added_to_conversation_enabled,
        'AddedToConversation.Template' => added_to_conversation_template,
        'AddedToConversation.Sound' => added_to_conversation_sound,
        'RemovedFromConversation.Enabled' => removed_from_conversation_enabled,
        'RemovedFromConversation.Template' => removed_from_conversation_template,
        'RemovedFromConversation.Sound' => removed_from_conversation_sound,
        'NewMessage.WithMedia.Enabled' => new_message_with_media_enabled,
        'NewMessage.WithMedia.Template' => new_message_with_media_template,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    notification_instance = NotificationInstance.new(
        @version,
        response.body,
        chat_service_sid: @solution[:chat_service_sid],
    )
    .new(
        @version,
        notification_instance,
        response.headers,
        response.status_code
    )
end