class Twilio::REST::Chat::V1::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 Twilio-provided string that uniquely identifies the

Service resource to fetch.

@return [ServiceContext] ServiceContext

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

Public Instance Methods

channels(sid=:unset) click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v1/service.rb
404 def channels(sid=:unset)
405   raise ArgumentError, 'sid cannot be nil' if sid.nil?
406 
407   if sid != :unset
408     return ChannelContext.new(@version, @solution[:sid], sid, )
409   end
410 
411   unless @channels
412     @channels = ChannelList.new(@version, service_sid: @solution[:sid], )
413   end
414 
415   @channels
416 end
delete() click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v1/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/v1/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/v1/service.rb
463 def inspect
464   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
465   "#<Twilio.Chat.V1.ServiceContext #{context}>"
466 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/v1/service.rb
422 def roles(sid=:unset)
423   raise ArgumentError, 'sid cannot be nil' if sid.nil?
424 
425   if sid != :unset
426     return RoleContext.new(@version, @solution[:sid], sid, )
427   end
428 
429   unless @roles
430     @roles = RoleList.new(@version, service_sid: @solution[:sid], )
431   end
432 
433   @roles
434 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service.rb
456 def to_s
457   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
458   "#<Twilio.Chat.V1.ServiceContext #{context}>"
459 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_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, webhooks_on_message_send_url: :unset, webhooks_on_message_send_method: :unset, webhooks_on_message_update_url: :unset, webhooks_on_message_update_method: :unset, webhooks_on_message_remove_url: :unset, webhooks_on_message_remove_method: :unset, webhooks_on_channel_add_url: :unset, webhooks_on_channel_add_method: :unset, webhooks_on_channel_destroy_url: :unset, webhooks_on_channel_destroy_method: :unset, webhooks_on_channel_update_url: :unset, webhooks_on_channel_update_method: :unset, webhooks_on_member_add_url: :unset, webhooks_on_member_add_method: :unset, webhooks_on_member_remove_url: :unset, webhooks_on_member_remove_method: :unset, webhooks_on_message_sent_url: :unset, webhooks_on_message_sent_method: :unset, webhooks_on_message_updated_url: :unset, webhooks_on_message_updated_method: :unset, webhooks_on_message_removed_url: :unset, webhooks_on_message_removed_method: :unset, webhooks_on_channel_added_url: :unset, webhooks_on_channel_added_method: :unset, webhooks_on_channel_destroyed_url: :unset, webhooks_on_channel_destroyed_method: :unset, webhooks_on_channel_updated_url: :unset, webhooks_on_channel_updated_method: :unset, webhooks_on_member_added_url: :unset, webhooks_on_member_added_method: :unset, webhooks_on_member_removed_url: :unset, webhooks_on_member_removed_method: :unset, limits_channel_members: :unset, limits_user_channels: :unset) click to toggle source

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

the resource. It can be up to 64 characters long.

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

they are added to the service. See the {Roles
endpoint}[https://www.twilio.com/docs/chat/api/roles] for more details.

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

they are added to a channel. See the {Roles
endpoint}[https://www.twilio.com/docs/chat/api/roles] for more details.

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

channel creator when they join a new channel. See the {Roles
endpoint}[https://www.twilio.com/docs/chat/api/roles] for more details.

@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. Can be: `true` or `false`
and 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 [Boolean] notifications_added_to_channel_enabled Whether to send a

notification when a member is added to a channel. Can be: `true` or `false` and
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 [Boolean] notifications_removed_from_channel_enabled Whether to send a

notification to a user when they are removed from a channel. Can be: `true` or
`false` and 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 [Boolean] notifications_invited_to_channel_enabled Whether to send a

notification when a user is invited to a channel. Can be: `true` or `false` and
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] 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/api/chat/webhooks] 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/api/chat/webhooks] 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] webhooks_on_message_send_url The URL of the webhook to call in

response to the `on_message_send` event using the
`webhooks.on_message_send.method` HTTP method.

@param [String] webhooks_on_message_send_method The HTTP method to use when

calling the `webhooks.on_message_send.url`.

@param [String] webhooks_on_message_update_url The URL of the webhook to call in

response to the `on_message_update` event using the
`webhooks.on_message_update.method` HTTP method.

@param [String] webhooks_on_message_update_method The HTTP method to use when

calling the `webhooks.on_message_update.url`.

@param [String] webhooks_on_message_remove_url The URL of the webhook to call in

response to the `on_message_remove` event using the
`webhooks.on_message_remove.method` HTTP method.

@param [String] webhooks_on_message_remove_method The HTTP method to use when

calling the `webhooks.on_message_remove.url`.

@param [String] webhooks_on_channel_add_url The URL of the webhook to call in

response to the `on_channel_add` event using the
`webhooks.on_channel_add.method` HTTP method.

@param [String] webhooks_on_channel_add_method The HTTP method to use when

calling the `webhooks.on_channel_add.url`.

@param [String] webhooks_on_channel_destroy_url The URL of the webhook to call

in response to the `on_channel_destroy` event using the
`webhooks.on_channel_destroy.method` HTTP method.

@param [String] webhooks_on_channel_destroy_method The HTTP method to use when

calling the `webhooks.on_channel_destroy.url`.

@param [String] webhooks_on_channel_update_url The URL of the webhook to call in

response to the `on_channel_update` event using the
`webhooks.on_channel_update.method` HTTP method.

@param [String] webhooks_on_channel_update_method The HTTP method to use when

calling the `webhooks.on_channel_update.url`.

@param [String] webhooks_on_member_add_url The URL of the webhook to call in

response to the `on_member_add` event using the `webhooks.on_member_add.method`
HTTP method.

@param [String] webhooks_on_member_add_method The HTTP method to use when

calling the `webhooks.on_member_add.url`.

@param [String] webhooks_on_member_remove_url The URL of the webhook to call in

response to the `on_member_remove` event using the
`webhooks.on_member_remove.method` HTTP method.

@param [String] webhooks_on_member_remove_method The HTTP method to use when

calling the `webhooks.on_member_remove.url`.

@param [String] webhooks_on_message_sent_url The URL of the webhook to call in

response to the `on_message_sent` event using the
`webhooks.on_message_sent.method` HTTP method.

@param [String] webhooks_on_message_sent_method The URL of the webhook to call

in response to the `on_message_sent` event`.

@param [String] webhooks_on_message_updated_url The URL of the webhook to call

in response to the `on_message_updated` event using the
`webhooks.on_message_updated.method` HTTP method.

@param [String] webhooks_on_message_updated_method The HTTP method to use when

calling the `webhooks.on_message_updated.url`.

@param [String] webhooks_on_message_removed_url The URL of the webhook to call

in response to the `on_message_removed` event using the
`webhooks.on_message_removed.method` HTTP method.

@param [String] webhooks_on_message_removed_method The HTTP method to use when

calling the `webhooks.on_message_removed.url`.

@param [String] webhooks_on_channel_added_url The URL of the webhook to call in

response to the `on_channel_added` event using the
`webhooks.on_channel_added.method` HTTP method.

@param [String] webhooks_on_channel_added_method The URL of the webhook to call

in response to the `on_channel_added` event`.

@param [String] webhooks_on_channel_destroyed_url The URL of the webhook to call

in response to the `on_channel_added` event using the
`webhooks.on_channel_destroyed.method` HTTP method.

@param [String] webhooks_on_channel_destroyed_method The HTTP method to use when

calling the `webhooks.on_channel_destroyed.url`.

@param [String] webhooks_on_channel_updated_url The URL of the webhook to call

in response to the `on_channel_updated` event using the
`webhooks.on_channel_updated.method` HTTP method.

@param [String] webhooks_on_channel_updated_method The HTTP method to use when

calling the `webhooks.on_channel_updated.url`.

@param [String] webhooks_on_member_added_url The URL of the webhook to call in

response to the `on_channel_updated` event using the
`webhooks.on_channel_updated.method` HTTP method.

@param [String] webhooks_on_member_added_method The HTTP method to use when

calling the `webhooks.on_channel_updated.url`.

@param [String] webhooks_on_member_removed_url The URL of the webhook to call in

response to the `on_member_removed` event using the
`webhooks.on_member_removed.method` HTTP method.

@param [String] webhooks_on_member_removed_method The HTTP method to use when

calling the `webhooks.on_member_removed.url`.

@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.

@return [ServiceInstance] Updated ServiceInstance

    # File lib/twilio-ruby/rest/chat/v1/service.rb
337 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_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, webhooks_on_message_send_url: :unset, webhooks_on_message_send_method: :unset, webhooks_on_message_update_url: :unset, webhooks_on_message_update_method: :unset, webhooks_on_message_remove_url: :unset, webhooks_on_message_remove_method: :unset, webhooks_on_channel_add_url: :unset, webhooks_on_channel_add_method: :unset, webhooks_on_channel_destroy_url: :unset, webhooks_on_channel_destroy_method: :unset, webhooks_on_channel_update_url: :unset, webhooks_on_channel_update_method: :unset, webhooks_on_member_add_url: :unset, webhooks_on_member_add_method: :unset, webhooks_on_member_remove_url: :unset, webhooks_on_member_remove_method: :unset, webhooks_on_message_sent_url: :unset, webhooks_on_message_sent_method: :unset, webhooks_on_message_updated_url: :unset, webhooks_on_message_updated_method: :unset, webhooks_on_message_removed_url: :unset, webhooks_on_message_removed_method: :unset, webhooks_on_channel_added_url: :unset, webhooks_on_channel_added_method: :unset, webhooks_on_channel_destroyed_url: :unset, webhooks_on_channel_destroyed_method: :unset, webhooks_on_channel_updated_url: :unset, webhooks_on_channel_updated_method: :unset, webhooks_on_member_added_url: :unset, webhooks_on_member_added_method: :unset, webhooks_on_member_removed_url: :unset, webhooks_on_member_removed_method: :unset, limits_channel_members: :unset, limits_user_channels: :unset)
338   data = Twilio::Values.of({
339       'FriendlyName' => friendly_name,
340       'DefaultServiceRoleSid' => default_service_role_sid,
341       'DefaultChannelRoleSid' => default_channel_role_sid,
342       'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid,
343       'ReadStatusEnabled' => read_status_enabled,
344       'ReachabilityEnabled' => reachability_enabled,
345       'TypingIndicatorTimeout' => typing_indicator_timeout,
346       'ConsumptionReportInterval' => consumption_report_interval,
347       'Notifications.NewMessage.Enabled' => notifications_new_message_enabled,
348       'Notifications.NewMessage.Template' => notifications_new_message_template,
349       'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled,
350       'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template,
351       'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled,
352       'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template,
353       'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled,
354       'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template,
355       'PreWebhookUrl' => pre_webhook_url,
356       'PostWebhookUrl' => post_webhook_url,
357       'WebhookMethod' => webhook_method,
358       'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e },
359       'Webhooks.OnMessageSend.Url' => webhooks_on_message_send_url,
360       'Webhooks.OnMessageSend.Method' => webhooks_on_message_send_method,
361       'Webhooks.OnMessageUpdate.Url' => webhooks_on_message_update_url,
362       'Webhooks.OnMessageUpdate.Method' => webhooks_on_message_update_method,
363       'Webhooks.OnMessageRemove.Url' => webhooks_on_message_remove_url,
364       'Webhooks.OnMessageRemove.Method' => webhooks_on_message_remove_method,
365       'Webhooks.OnChannelAdd.Url' => webhooks_on_channel_add_url,
366       'Webhooks.OnChannelAdd.Method' => webhooks_on_channel_add_method,
367       'Webhooks.OnChannelDestroy.Url' => webhooks_on_channel_destroy_url,
368       'Webhooks.OnChannelDestroy.Method' => webhooks_on_channel_destroy_method,
369       'Webhooks.OnChannelUpdate.Url' => webhooks_on_channel_update_url,
370       'Webhooks.OnChannelUpdate.Method' => webhooks_on_channel_update_method,
371       'Webhooks.OnMemberAdd.Url' => webhooks_on_member_add_url,
372       'Webhooks.OnMemberAdd.Method' => webhooks_on_member_add_method,
373       'Webhooks.OnMemberRemove.Url' => webhooks_on_member_remove_url,
374       'Webhooks.OnMemberRemove.Method' => webhooks_on_member_remove_method,
375       'Webhooks.OnMessageSent.Url' => webhooks_on_message_sent_url,
376       'Webhooks.OnMessageSent.Method' => webhooks_on_message_sent_method,
377       'Webhooks.OnMessageUpdated.Url' => webhooks_on_message_updated_url,
378       'Webhooks.OnMessageUpdated.Method' => webhooks_on_message_updated_method,
379       'Webhooks.OnMessageRemoved.Url' => webhooks_on_message_removed_url,
380       'Webhooks.OnMessageRemoved.Method' => webhooks_on_message_removed_method,
381       'Webhooks.OnChannelAdded.Url' => webhooks_on_channel_added_url,
382       'Webhooks.OnChannelAdded.Method' => webhooks_on_channel_added_method,
383       'Webhooks.OnChannelDestroyed.Url' => webhooks_on_channel_destroyed_url,
384       'Webhooks.OnChannelDestroyed.Method' => webhooks_on_channel_destroyed_method,
385       'Webhooks.OnChannelUpdated.Url' => webhooks_on_channel_updated_url,
386       'Webhooks.OnChannelUpdated.Method' => webhooks_on_channel_updated_method,
387       'Webhooks.OnMemberAdded.Url' => webhooks_on_member_added_url,
388       'Webhooks.OnMemberAdded.Method' => webhooks_on_member_added_method,
389       'Webhooks.OnMemberRemoved.Url' => webhooks_on_member_removed_url,
390       'Webhooks.OnMemberRemoved.Method' => webhooks_on_member_removed_method,
391       'Limits.ChannelMembers' => limits_channel_members,
392       'Limits.UserChannels' => limits_user_channels,
393   })
394 
395   payload = @version.update('POST', @uri, data: data)
396 
397   ServiceInstance.new(@version, payload, sid: @solution[:sid], )
398 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/v1/service.rb
440 def users(sid=:unset)
441   raise ArgumentError, 'sid cannot be nil' if sid.nil?
442 
443   if sid != :unset
444     return UserContext.new(@version, @solution[:sid], sid, )
445   end
446 
447   unless @users
448     @users = UserList.new(@version, service_sid: @solution[:sid], )
449   end
450 
451   @users
452 end