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



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

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



63
64
65
66
67
68
69
70
71
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 63

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



139
140
141
142
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 139

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

#to_sObject

Provide a user friendly representation



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

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



89
90
91
92
93
94
95
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
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb', line 89

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

    payload = @version.update('POST', @uri, data: data)
    NotificationInstance.new(
        @version,
        payload,
        chat_service_sid: @solution[:chat_service_sid],
    )
end