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:

  • version (Version)

    Version that contains the resource

  • chat_service_sid (String)

    The SID of the Conversation Service the Configuration applies to.


73
74
75
76
77
78
79
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 73

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:


134
135
136
137
138
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 134

def fetch
  payload = @version.fetch('GET', @uri)

  NotificationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
end

#inspectObject

Provide a detailed, user friendly representation


149
150
151
152
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 149

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

#to_sObject

Provide a user friendly representation


142
143
144
145
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 142

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) ⇒ 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`.

Returns:


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 111

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)
  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,
  })

  payload = @version.update('POST', @uri, data: data)

  NotificationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
end