class Twilio::REST::Chat::V2::ServiceContext

Public Class Methods

new(version, sid) click to toggle source

Initialize the ServiceContext @param [Version] version Version that contains the resource @param [String] sid The SID of the Service resource to fetch. @return [ServiceContext] ServiceContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/chat/v2/service.rb
161 def initialize(version, sid)
162   super(version)
163 
164   # Path Solution
165   @solution = {sid: sid, }
166   @uri = "/Services/#{@solution[:sid]}"
167 
168   # Dependents
169   @channels = nil
170   @roles = nil
171   @users = nil
172   @bindings = nil
173 end

Public Instance Methods

bindings(sid=:unset) click to toggle source

Access the bindings @return [BindingList] @return [BindingContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v2/service.rb
381 def bindings(sid=:unset)
382   raise ArgumentError, 'sid cannot be nil' if sid.nil?
383 
384   if sid != :unset
385     return BindingContext.new(@version, @solution[:sid], sid, )
386   end
387 
388   unless @bindings
389     @bindings = BindingList.new(@version, service_sid: @solution[:sid], )
390   end
391 
392   @bindings
393 end
channels(sid=:unset) click to toggle source

Access the channels @return [ChannelList] @return [ChannelContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v2/service.rb
327 def channels(sid=:unset)
328   raise ArgumentError, 'sid cannot be nil' if sid.nil?
329 
330   if sid != :unset
331     return ChannelContext.new(@version, @solution[:sid], sid, )
332   end
333 
334   unless @channels
335     @channels = ChannelList.new(@version, service_sid: @solution[:sid], )
336   end
337 
338   @channels
339 end
delete() click to toggle source

Delete the ServiceInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/chat/v2/service.rb
187 def delete
188    @version.delete('DELETE', @uri)
189 end
fetch() click to toggle source

Fetch the ServiceInstance @return [ServiceInstance] Fetched ServiceInstance

    # File lib/twilio-ruby/rest/chat/v2/service.rb
178 def fetch
179   payload = @version.fetch('GET', @uri)
180 
181   ServiceInstance.new(@version, payload, sid: @solution[:sid], )
182 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service.rb
404 def inspect
405   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
406   "#<Twilio.Chat.V2.ServiceContext #{context}>"
407 end
roles(sid=:unset) click to toggle source

Access the roles @return [RoleList] @return [RoleContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v2/service.rb
345 def roles(sid=:unset)
346   raise ArgumentError, 'sid cannot be nil' if sid.nil?
347 
348   if sid != :unset
349     return RoleContext.new(@version, @solution[:sid], sid, )
350   end
351 
352   unless @roles
353     @roles = RoleList.new(@version, service_sid: @solution[:sid], )
354   end
355 
356   @roles
357 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service.rb
397 def to_s
398   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
399   "#<Twilio.Chat.V2.ServiceContext #{context}>"
400 end
update(friendly_name: :unset, default_service_role_sid: :unset, default_channel_role_sid: :unset, default_channel_creator_role_sid: :unset, read_status_enabled: :unset, reachability_enabled: :unset, typing_indicator_timeout: :unset, consumption_report_interval: :unset, notifications_new_message_enabled: :unset, notifications_new_message_template: :unset, notifications_new_message_sound: :unset, notifications_new_message_badge_count_enabled: :unset, notifications_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_added_to_channel_sound: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_removed_from_channel_sound: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, notifications_invited_to_channel_sound: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, limits_channel_members: :unset, limits_user_channels: :unset, media_compatibility_message: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, notifications_log_enabled: :unset) click to toggle source

Update the ServiceInstance @param [String] friendly_name A descriptive string that you create to describe

the resource.

@param [String] default_service_role_sid The service role assigned to users when

they are added to the service. See the {Role
resource}[https://www.twilio.com/docs/chat/rest/role-resource] for more info
about roles.

@param [String] default_channel_role_sid The channel role assigned to users when

they are added to a channel. See the {Role
resource}[https://www.twilio.com/docs/chat/rest/role-resource] for more info
about roles.

@param [String] default_channel_creator_role_sid The channel role assigned to a

channel creator when they join a new channel. See the {Role
resource}[https://www.twilio.com/docs/chat/rest/role-resource] for more info
about roles.

@param [Boolean] read_status_enabled Whether to enable the {Message Consumption

Horizon}[https://www.twilio.com/docs/chat/consumption-horizon] feature. The
default is `true`.

@param [Boolean] reachability_enabled Whether to enable the {Reachability

Indicator}[https://www.twilio.com/docs/chat/reachability-indicator] for this
Service instance. The default is `false`.

@param [String] typing_indicator_timeout How long in seconds after a `started

typing` event until clients should assume that user is no longer typing, even if
no `ended typing` message was received.  The default is 5 seconds.

@param [String] consumption_report_interval DEPRECATED. The interval in seconds

between consumption reports submission batches from client endpoints.

@param [Boolean] notifications_new_message_enabled Whether to send a

notification when a new message is added to a channel. The default is `false`.

@param [String] notifications_new_message_template The template to use to create

the notification text displayed when a new message is added to a channel and
`notifications.new_message.enabled` is `true`.

@param [String] notifications_new_message_sound The name of the sound to play

when a new message is added to a channel and `notifications.new_message.enabled`
is `true`.

@param [Boolean] notifications_new_message_badge_count_enabled Whether the new

message badge is enabled. The default is `false`.

@param [Boolean] notifications_added_to_channel_enabled Whether to send a

notification when a member is added to a channel. The default is `false`.

@param [String] notifications_added_to_channel_template The template to use to

create the notification text displayed when a member is added to a channel and
`notifications.added_to_channel.enabled` is `true`.

@param [String] notifications_added_to_channel_sound The name of the sound to

play when a member is added to a channel and
`notifications.added_to_channel.enabled` is `true`.

@param [Boolean] notifications_removed_from_channel_enabled Whether to send a

notification to a user when they are removed from a channel. The default is
`false`.

@param [String] notifications_removed_from_channel_template The template to use

to create the notification text displayed to a user when they are removed from a
channel and `notifications.removed_from_channel.enabled` is `true`.

@param [String] notifications_removed_from_channel_sound The name of the sound

to play to a user when they are removed from a channel and
`notifications.removed_from_channel.enabled` is `true`.

@param [Boolean] notifications_invited_to_channel_enabled Whether to send a

notification when a user is invited to a channel. The default is `false`.

@param [String] notifications_invited_to_channel_template The template to use to

create the notification text displayed when a user is invited to a channel and
`notifications.invited_to_channel.enabled` is `true`.

@param [String] notifications_invited_to_channel_sound The name of the sound to

play when a user is invited to a channel and
`notifications.invited_to_channel.enabled` is `true`.

@param [String] pre_webhook_url The URL for pre-event webhooks, which are called

by using the `webhook_method`. See {Webhook
Events}[https://www.twilio.com/docs/chat/webhook-events] for more details.

@param [String] post_webhook_url The URL for post-event webhooks, which are

called by using the `webhook_method`. See {Webhook
Events}[https://www.twilio.com/docs/chat/webhook-events] for more details.

@param [String] webhook_method The HTTP method to use for calls to the

`pre_webhook_url` and `post_webhook_url` webhooks.  Can be: `POST` or `GET` and
the default is `POST`. See {Webhook
Events}[https://www.twilio.com/docs/chat/webhook-events] for more details.

@param [Array] webhook_filters The list of webhook events that are

enabled for this Service instance. See {Webhook
Events}[https://www.twilio.com/docs/chat/webhook-events] for more details.

@param [String] limits_channel_members The maximum number of Members that can be

added to Channels within this Service. Can be up to 1,000.

@param [String] limits_user_channels The maximum number of Channels Users can be

a Member of within this Service. Can be up to 1,000.

@param [String] media_compatibility_message The message to send when a media

message has no text. Can be used as placeholder message.

@param [String] pre_webhook_retry_count The number of times to retry a call to

the `pre_webhook_url` if the request times out (after 5 seconds) or it receives
a 429, 503, or 504 HTTP response. Default retry count is 0 times, which means
the call won't be retried.

@param [String] post_webhook_retry_count The number of times to retry a call to

the `post_webhook_url` if the request times out (after 5 seconds) or it receives
a 429, 503, or 504 HTTP response. The default is 0, which means the call won't
be retried.

@param [Boolean] notifications_log_enabled Whether to log notifications. The

default is `false`.

@return [ServiceInstance] Updated ServiceInstance

    # File lib/twilio-ruby/rest/chat/v2/service.rb
283 def update(friendly_name: :unset, default_service_role_sid: :unset, default_channel_role_sid: :unset, default_channel_creator_role_sid: :unset, read_status_enabled: :unset, reachability_enabled: :unset, typing_indicator_timeout: :unset, consumption_report_interval: :unset, notifications_new_message_enabled: :unset, notifications_new_message_template: :unset, notifications_new_message_sound: :unset, notifications_new_message_badge_count_enabled: :unset, notifications_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_added_to_channel_sound: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_removed_from_channel_sound: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, notifications_invited_to_channel_sound: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, limits_channel_members: :unset, limits_user_channels: :unset, media_compatibility_message: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, notifications_log_enabled: :unset)
284   data = Twilio::Values.of({
285       'FriendlyName' => friendly_name,
286       'DefaultServiceRoleSid' => default_service_role_sid,
287       'DefaultChannelRoleSid' => default_channel_role_sid,
288       'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid,
289       'ReadStatusEnabled' => read_status_enabled,
290       'ReachabilityEnabled' => reachability_enabled,
291       'TypingIndicatorTimeout' => typing_indicator_timeout,
292       'ConsumptionReportInterval' => consumption_report_interval,
293       'Notifications.NewMessage.Enabled' => notifications_new_message_enabled,
294       'Notifications.NewMessage.Template' => notifications_new_message_template,
295       'Notifications.NewMessage.Sound' => notifications_new_message_sound,
296       'Notifications.NewMessage.BadgeCountEnabled' => notifications_new_message_badge_count_enabled,
297       'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled,
298       'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template,
299       'Notifications.AddedToChannel.Sound' => notifications_added_to_channel_sound,
300       'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled,
301       'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template,
302       'Notifications.RemovedFromChannel.Sound' => notifications_removed_from_channel_sound,
303       'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled,
304       'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template,
305       'Notifications.InvitedToChannel.Sound' => notifications_invited_to_channel_sound,
306       'PreWebhookUrl' => pre_webhook_url,
307       'PostWebhookUrl' => post_webhook_url,
308       'WebhookMethod' => webhook_method,
309       'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e },
310       'Limits.ChannelMembers' => limits_channel_members,
311       'Limits.UserChannels' => limits_user_channels,
312       'Media.CompatibilityMessage' => media_compatibility_message,
313       'PreWebhookRetryCount' => pre_webhook_retry_count,
314       'PostWebhookRetryCount' => post_webhook_retry_count,
315       'Notifications.LogEnabled' => notifications_log_enabled,
316   })
317 
318   payload = @version.update('POST', @uri, data: data)
319 
320   ServiceInstance.new(@version, payload, sid: @solution[:sid], )
321 end
users(sid=:unset) click to toggle source

Access the users @return [UserList] @return [UserContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v2/service.rb
363 def users(sid=:unset)
364   raise ArgumentError, 'sid cannot be nil' if sid.nil?
365 
366   if sid != :unset
367     return UserContext.new(@version, @solution[:sid], sid, )
368   end
369 
370   unless @users
371     @users = UserList.new(@version, service_sid: @solution[:sid], )
372   end
373 
374   @users
375 end