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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, chat_service_sid: nil) ⇒ NotificationInstance

Initialize the NotificationInstance



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 196

def initialize(version, payload , chat_service_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'chat_service_sid' => payload['chat_service_sid'],
        'new_message' => payload['new_message'],
        'added_to_conversation' => payload['added_to_conversation'],
        'removed_from_conversation' => payload['removed_from_conversation'],
        'log_enabled' => payload['log_enabled'],
        'url' => payload['url'],
    }

    # Context
    @instance_context = nil
    @params = { 'chat_service_sid' => chat_service_sid  || @properties['chat_service_sid']  , }
end

Instance Method Details

#account_sidString



228
229
230
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 228

def 
    @properties['account_sid']
end

#added_to_conversationHash



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

def added_to_conversation
    @properties['added_to_conversation']
end

#chat_service_sidString



234
235
236
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 234

def chat_service_sid
    @properties['chat_service_sid']
end

#contextNotificationContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context



219
220
221
222
223
224
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 219

def context
    unless @instance_context
        @instance_context = NotificationContext.new(@version , @params['chat_service_sid'])
    end
    @instance_context
end

#fetchNotificationInstance

Fetch the NotificationInstance



271
272
273
274
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 271

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



334
335
336
337
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 334

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Conversations.V1.NotificationInstance #{values}>"
end

#log_enabledBoolean



258
259
260
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 258

def log_enabled
    @properties['log_enabled']
end

#new_messageHash



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

def new_message
    @properties['new_message']
end

#removed_from_conversationHash



252
253
254
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 252

def removed_from_conversation
    @properties['removed_from_conversation']
end

#to_sObject

Provide a user friendly representation



327
328
329
330
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 327

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Conversations.V1.NotificationInstance #{values}>"
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



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 292

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
)

    context.update(
        log_enabled: log_enabled, 
        new_message_enabled: new_message_enabled, 
        new_message_template: new_message_template, 
        new_message_sound: new_message_sound, 
        new_message_badge_count_enabled: new_message_badge_count_enabled, 
        added_to_conversation_enabled: added_to_conversation_enabled, 
        added_to_conversation_template: added_to_conversation_template, 
        added_to_conversation_sound: added_to_conversation_sound, 
        removed_from_conversation_enabled: removed_from_conversation_enabled, 
        removed_from_conversation_template: removed_from_conversation_template, 
        removed_from_conversation_sound: removed_from_conversation_sound, 
        new_message_with_media_enabled: new_message_with_media_enabled, 
        new_message_with_media_template: new_message_with_media_template, 
    )
end

#urlString



264
265
266
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 264

def url
    @properties['url']
end