Class: Twilio::REST::Chat::V2::ServiceInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/chat/v2/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ ServiceInstance

Initialize the ServiceInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    The SID of the Service resource to fetch.


417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 417

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'friendly_name' => payload['friendly_name'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'default_service_role_sid' => payload['default_service_role_sid'],
      'default_channel_role_sid' => payload['default_channel_role_sid'],
      'default_channel_creator_role_sid' => payload['default_channel_creator_role_sid'],
      'read_status_enabled' => payload['read_status_enabled'],
      'reachability_enabled' => payload['reachability_enabled'],
      'typing_indicator_timeout' => payload['typing_indicator_timeout'].to_i,
      'consumption_report_interval' => payload['consumption_report_interval'].to_i,
      'limits' => payload['limits'],
      'pre_webhook_url' => payload['pre_webhook_url'],
      'post_webhook_url' => payload['post_webhook_url'],
      'webhook_method' => payload['webhook_method'],
      'webhook_filters' => payload['webhook_filters'],
      'pre_webhook_retry_count' => payload['pre_webhook_retry_count'].to_i,
      'post_webhook_retry_count' => payload['post_webhook_retry_count'].to_i,
      'notifications' => payload['notifications'],
      'media' => payload['media'],
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource


471
472
473
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 471

def 
  @properties['account_sid']
end

#bindingsbindings

Access the bindings

Returns:


767
768
769
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 767

def bindings
  context.bindings
end

#channelschannels

Access the channels

Returns:


746
747
748
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 746

def channels
  context.channels
end

#consumption_report_intervalString

Returns DEPRECATED.

Returns:

  • (String)

    DEPRECATED


531
532
533
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 531

def consumption_report_interval
  @properties['consumption_report_interval']
end

#contextServiceContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:


456
457
458
459
460
461
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 456

def context
  unless @instance_context
    @instance_context = ServiceContext.new(@version, @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was created


483
484
485
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 483

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was last updated


489
490
491
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 489

def date_updated
  @properties['date_updated']
end

#default_channel_creator_role_sidString

Returns The channel role assigned to a channel creator when they join a new channel.

Returns:

  • (String)

    The channel role assigned to a channel creator when they join a new channel


507
508
509
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 507

def default_channel_creator_role_sid
  @properties['default_channel_creator_role_sid']
end

#default_channel_role_sidString

Returns The channel role assigned to users when they are added to a channel.

Returns:

  • (String)

    The channel role assigned to users when they are added to a channel


501
502
503
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 501

def default_channel_role_sid
  @properties['default_channel_role_sid']
end

#default_service_role_sidString

Returns The service role assigned to users when they are added to the service.

Returns:

  • (String)

    The service role assigned to users when they are added to the service


495
496
497
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 495

def default_service_role_sid
  @properties['default_service_role_sid']
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


611
612
613
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 611

def delete
  context.delete
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:


604
605
606
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 604

def fetch
  context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource


477
478
479
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 477

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation


780
781
782
783
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 780

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Chat.V2.ServiceInstance #{values}>"
end

#limitsHash

Returns An object that describes the limits of the service instance.

Returns:

  • (Hash)

    An object that describes the limits of the service instance


537
538
539
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 537

def limits
  @properties['limits']
end

Returns The absolute URLs of the Service's Channels, Roles, and Users.

Returns:

  • (String)

    The absolute URLs of the Service's Channels, Roles, and Users


597
598
599
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 597

def links
  @properties['links']
end

#mediaHash

Returns The properties of the media that the service supports.

Returns:

  • (Hash)

    The properties of the media that the service supports


585
586
587
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 585

def media
  @properties['media']
end

#notificationsHash

Returns The notification configuration for the Service instance.

Returns:

  • (Hash)

    The notification configuration for the Service instance


579
580
581
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 579

def notifications
  @properties['notifications']
end

#post_webhook_retry_countString

Returns The number of times calls to the `post_webhook_url` will be retried.

Returns:

  • (String)

    The number of times calls to the `post_webhook_url` will be retried


573
574
575
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 573

def post_webhook_retry_count
  @properties['post_webhook_retry_count']
end

#post_webhook_urlString

Returns The URL for post-event webhooks.

Returns:

  • (String)

    The URL for post-event webhooks


549
550
551
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 549

def post_webhook_url
  @properties['post_webhook_url']
end

#pre_webhook_retry_countString

Returns Count of times webhook will be retried in case of timeout or 429/503/504 HTTP responses.

Returns:

  • (String)

    Count of times webhook will be retried in case of timeout or 429/503/504 HTTP responses


567
568
569
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 567

def pre_webhook_retry_count
  @properties['pre_webhook_retry_count']
end

#pre_webhook_urlString

Returns The webhook URL for pre-event webhooks.

Returns:

  • (String)

    The webhook URL for pre-event webhooks


543
544
545
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 543

def pre_webhook_url
  @properties['pre_webhook_url']
end

#reachability_enabledBoolean

Returns Whether the Reachability Indicator feature is enabled for this Service instance.

Returns:

  • (Boolean)

    Whether the Reachability Indicator feature is enabled for this Service instance


519
520
521
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 519

def reachability_enabled
  @properties['reachability_enabled']
end

#read_status_enabledBoolean

Returns Whether the Message Consumption Horizon feature is enabled.

Returns:

  • (Boolean)

    Whether the Message Consumption Horizon feature is enabled


513
514
515
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 513

def read_status_enabled
  @properties['read_status_enabled']
end

#rolesroles

Access the roles

Returns:


753
754
755
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 753

def roles
  context.roles
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource


465
466
467
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 465

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation


773
774
775
776
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 773

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Chat.V2.ServiceInstance #{values}>"
end

#typing_indicator_timeoutString

Returns How long in seconds to wait before assuming the user is no longer typing.

Returns:

  • (String)

    How long in seconds to wait before assuming the user is no longer typing


525
526
527
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 525

def typing_indicator_timeout
  @properties['typing_indicator_timeout']
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) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the resource.

  • default_service_role_sid (String) (defaults to: :unset)

    The service role assigned to users when they are added to the service. See the Role resource for more info about roles.

  • default_channel_role_sid (String) (defaults to: :unset)

    The channel role assigned to users when they are added to a channel. See the Role resource for more info about roles.

  • default_channel_creator_role_sid (String) (defaults to: :unset)

    The channel role assigned to a channel creator when they join a new channel. See the Role resource for more info about roles.

  • read_status_enabled (Boolean) (defaults to: :unset)

    Whether to enable the Message Consumption Horizon feature. The default is `true`.

  • reachability_enabled (Boolean) (defaults to: :unset)

    Whether to enable the Reachability Indicator for this Service instance. The default is `false`.

  • typing_indicator_timeout (String) (defaults to: :unset)

    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.

  • consumption_report_interval (String) (defaults to: :unset)

    DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints.

  • notifications_new_message_enabled (Boolean) (defaults to: :unset)

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

  • notifications_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 channel and `notifications.new_message.enabled` is `true`.

  • notifications_new_message_sound (String) (defaults to: :unset)

    The name of the sound to play when a new message is added to a channel and `notifications.new_message.enabled` is `true`.

  • notifications_new_message_badge_count_enabled (Boolean) (defaults to: :unset)

    Whether the new message badge is enabled. The default is `false`.

  • notifications_added_to_channel_enabled (Boolean) (defaults to: :unset)

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

  • notifications_added_to_channel_template (String) (defaults to: :unset)

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

  • notifications_added_to_channel_sound (String) (defaults to: :unset)

    The name of the sound to play when a member is added to a channel and `notifications.added_to_channel.enabled` is `true`.

  • notifications_removed_from_channel_enabled (Boolean) (defaults to: :unset)

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

  • notifications_removed_from_channel_template (String) (defaults to: :unset)

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

  • notifications_removed_from_channel_sound (String) (defaults to: :unset)

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

  • notifications_invited_to_channel_enabled (Boolean) (defaults to: :unset)

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

  • notifications_invited_to_channel_template (String) (defaults to: :unset)

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

  • notifications_invited_to_channel_sound (String) (defaults to: :unset)

    The name of the sound to play when a user is invited to a channel and `notifications.invited_to_channel.enabled` is `true`.

  • pre_webhook_url (String) (defaults to: :unset)

    The URL for pre-event webhooks, which are called by using the `webhook_method`. See Webhook Events for more details.

  • post_webhook_url (String) (defaults to: :unset)

    The URL for post-event webhooks, which are called by using the `webhook_method`. See Webhook Events for more details.

  • webhook_method (String) (defaults to: :unset)

    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 for more details.

  • webhook_filters (Array[String]) (defaults to: :unset)

    The list of webhook events that are enabled for this Service instance. See Webhook Events for more details.

  • limits_channel_members (String) (defaults to: :unset)

    The maximum number of Members that can be added to Channels within this Service. Can be up to 1,000.

  • limits_user_channels (String) (defaults to: :unset)

    The maximum number of Channels Users can be a Member of within this Service. Can be up to 1,000.

  • media_compatibility_message (String) (defaults to: :unset)

    The message to send when a media message has no text. Can be used as placeholder message.

  • pre_webhook_retry_count (String) (defaults to: :unset)

    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.

  • post_webhook_retry_count (String) (defaults to: :unset)

    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.

  • notifications_log_enabled (Boolean) (defaults to: :unset)

    Whether to log notifications. The default is `false`.

Returns:


707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 707

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)
  context.update(
      friendly_name: friendly_name,
      default_service_role_sid: default_service_role_sid,
      default_channel_role_sid: default_channel_role_sid,
      default_channel_creator_role_sid: default_channel_creator_role_sid,
      read_status_enabled: read_status_enabled,
      reachability_enabled: reachability_enabled,
      typing_indicator_timeout: typing_indicator_timeout,
      consumption_report_interval: consumption_report_interval,
      notifications_new_message_enabled: notifications_new_message_enabled,
      notifications_new_message_template: notifications_new_message_template,
      notifications_new_message_sound: notifications_new_message_sound,
      notifications_new_message_badge_count_enabled: notifications_new_message_badge_count_enabled,
      notifications_added_to_channel_enabled: notifications_added_to_channel_enabled,
      notifications_added_to_channel_template: notifications_added_to_channel_template,
      notifications_added_to_channel_sound: notifications_added_to_channel_sound,
      notifications_removed_from_channel_enabled: notifications_removed_from_channel_enabled,
      notifications_removed_from_channel_template: notifications_removed_from_channel_template,
      notifications_removed_from_channel_sound: notifications_removed_from_channel_sound,
      notifications_invited_to_channel_enabled: notifications_invited_to_channel_enabled,
      notifications_invited_to_channel_template: notifications_invited_to_channel_template,
      notifications_invited_to_channel_sound: notifications_invited_to_channel_sound,
      pre_webhook_url: pre_webhook_url,
      post_webhook_url: post_webhook_url,
      webhook_method: webhook_method,
      webhook_filters: webhook_filters,
      limits_channel_members: limits_channel_members,
      limits_user_channels: limits_user_channels,
      media_compatibility_message: media_compatibility_message,
      pre_webhook_retry_count: pre_webhook_retry_count,
      post_webhook_retry_count: post_webhook_retry_count,
      notifications_log_enabled: notifications_log_enabled,
  )
end

#urlString

Returns The absolute URL of the Service resource.

Returns:

  • (String)

    The absolute URL of the Service resource


591
592
593
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 591

def url
  @properties['url']
end

#usersusers

Access the users

Returns:


760
761
762
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 760

def users
  context.users
end

#webhook_filtersArray[String]

Returns The list of webhook events that are enabled for this Service instance.

Returns:

  • (Array[String])

    The list of webhook events that are enabled for this Service instance


561
562
563
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 561

def webhook_filters
  @properties['webhook_filters']
end

#webhook_methodString

Returns The HTTP method to use for both PRE and POST webhooks.

Returns:

  • (String)

    The HTTP method to use for both PRE and POST webhooks


555
556
557
# File 'lib/twilio-ruby/rest/chat/v2/service.rb', line 555

def webhook_method
  @properties['webhook_method']
end