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:



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

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:



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

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

#inspectObject

Provide a detailed, user friendly representation



152
153
154
155
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 152

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

#to_sObject

Provide a user friendly representation



145
146
147
148
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 145

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:



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

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