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

Parameters:

  • version (Version) —

    Version that contains the resource

  • payload (Hash) —

    payload that contains response from Twilio

  • account_sid (String) —

    The SID of the Account that created this Notification resource.

  • sid (String) —

    The SID of the Call resource to fetch.



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 340

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_sid ⇒ String

Returns The unique ID of the Account responsible for this configuration.

Returns:

  • (String) —

    The unique ID of the Account responsible for this configuration.



373
374
375
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 373

def 
    @properties['account_sid']
end

#added_to_conversation ⇒ Hash

Returns The Push Notification configuration for being added to a Conversation.

Returns:

  • (Hash) —

    The Push Notification configuration for being added to a Conversation.



391
392
393
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 391

def added_to_conversation
    @properties['added_to_conversation']
end

#chat_service_sid ⇒ String

Returns The SID of the Conversation Service the Configuration applies to.

Returns:



379
380
381
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 379

def chat_service_sid
    @properties['chat_service_sid']
end

#context ⇒ NotificationContext

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

Returns:



364
365
366
367
368
369
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 364

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

#fetch ⇒ NotificationInstance

Fetch the NotificationInstance

Returns:



416
417
418
419
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 416

def fetch

    context.fetch
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



479
480
481
482
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 479

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

#log_enabled ⇒ Boolean

Returns Weather the notification logging is enabled.

Returns:

  • (Boolean) —

    Weather the notification logging is enabled.



403
404
405
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 403

def log_enabled
    @properties['log_enabled']
end

#new_message ⇒ Hash

Returns The Push Notification configuration for New Messages.

Returns:

  • (Hash) —

    The Push Notification configuration for New Messages.



385
386
387
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 385

def new_message
    @properties['new_message']
end

#removed_from_conversation ⇒ Hash

Returns The Push Notification configuration for being removed from a Conversation.

Returns:

  • (Hash) —

    The Push Notification configuration for being removed from a Conversation.



397
398
399
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 397

def removed_from_conversation
    @properties['removed_from_conversation']
end

#to_s ⇒ Object

Provide a user friendly representation



472
473
474
475
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 472

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

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:



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 437

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

#url ⇒ String

Returns An absolute API resource URL for this configuration.

Returns:

  • (String) —

    An absolute API resource URL for this configuration.



409
410
411
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 409

def url
    @properties['url']
end