Class: Twilio::REST::Sync::V1::ServiceInstance

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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

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)

    A unique identifier for this service instance.



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 377

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

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'unique_name' => payload['unique_name'],
      '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']),
      'url' => payload['url'],
      'webhook_url' => payload['webhook_url'],
      'reachability_webhooks_enabled' => payload['reachability_webhooks_enabled'],
      'acl_enabled' => payload['acl_enabled'],
      'reachability_debouncing_enabled' => payload['reachability_debouncing_enabled'],
      'reachability_debouncing_window' => payload['reachability_debouncing_window'].to_i,
      'links' => payload['links'],
  }

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

Instance Method Details

#account_sidString

Returns The account_sid.

Returns:

  • (String)

    The account_sid



427
428
429
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 427

def 
  @properties['account_sid']
end

#acl_enabledBoolean

Returns true or false - determines whether token identities must be granted access to Sync objects via the Permissions API in this Service.

Returns:

  • (Boolean)

    true or false - determines whether token identities must be granted access to Sync objects via the Permissions API in this Service.



469
470
471
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 469

def acl_enabled
  @properties['acl_enabled']
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:



406
407
408
409
410
411
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 406

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

#date_createdTime

Returns The date_created.

Returns:

  • (Time)

    The date_created



439
440
441
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 439

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date_updated.

Returns:

  • (Time)

    The date_updated



445
446
447
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 445

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

def delete
  context.delete
end

#documentsdocuments

Access the documents

Returns:



544
545
546
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 544

def documents
  context.documents
end

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



494
495
496
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 494

def fetch
  context.fetch
end

#friendly_nameString

Returns Human-readable name for this service instance.

Returns:

  • (String)

    Human-readable name for this service instance



433
434
435
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 433

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



578
579
580
581
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 578

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

Returns The links.

Returns:

  • (String)

    The links



487
488
489
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 487

def links
  @properties['links']
end

#reachability_debouncing_enabledBoolean

Returns true or false - Determines whether transient disconnections (i.e. an immediate reconnect succeeds) cause reachability webhooks.

Returns:

  • (Boolean)

    true or false - Determines whether transient disconnections (i.e. an immediate reconnect succeeds) cause reachability webhooks.



475
476
477
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 475

def reachability_debouncing_enabled
  @properties['reachability_debouncing_enabled']
end

#reachability_debouncing_windowString

Returns Determines how long an identity must be offline before reachability webhooks fire.

Returns:

  • (String)

    Determines how long an identity must be offline before reachability webhooks fire.



481
482
483
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 481

def reachability_debouncing_window
  @properties['reachability_debouncing_window']
end

#reachability_webhooks_enabledBoolean

Returns true or false - controls whether this instance fires webhooks when client endpoints connect to Sync.

Returns:

  • (Boolean)

    true or false - controls whether this instance fires webhooks when client endpoints connect to Sync



463
464
465
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 463

def reachability_webhooks_enabled
  @properties['reachability_webhooks_enabled']
end

#sidString

Returns A unique identifier for this service instance.

Returns:

  • (String)

    A unique identifier for this service instance.



415
416
417
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 415

def sid
  @properties['sid']
end

#sync_listssync_lists

Access the sync_lists

Returns:



551
552
553
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 551

def sync_lists
  context.sync_lists
end

#sync_mapssync_maps

Access the sync_maps

Returns:



558
559
560
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 558

def sync_maps
  context.sync_maps
end

#sync_streamssync_streams

Access the sync_streams

Returns:



565
566
567
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 565

def sync_streams
  context.sync_streams
end

#to_sObject

Provide a user friendly representation



571
572
573
574
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 571

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

#unique_nameString

Returns The unique_name.

Returns:

  • (String)

    The unique_name



421
422
423
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 421

def unique_name
  @properties['unique_name']
end

#update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset, reachability_debouncing_enabled: :unset, reachability_debouncing_window: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    A URL that will receive event updates when objects are manipulated.

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

    Human-readable name for this service instance

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

    True or false - controls whether this instance fires webhooks when client endpoints connect to Sync Defaults to false.

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

    ‘true` or `false` - determines whether token identities must be granted access to Sync objects via the [Permissions API](www.twilio.com/docs/api/sync/rest/sync-rest-api-permissions) in this Service.

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

    ‘true` or `false` - If false, every endpoint disconnection immediately yields a reachability webhook (if enabled). If true, then ’disconnection’ webhook events will only be fired after a configurable delay. Intervening reconnections would effectively cancel that webhook. Defaults to false.

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

    Reachability webhook delay period in milliseconds. Determines the delay after which a Sync identity is declared actually offline, measured from the moment the last running client disconnects. If all endpoints remain offline throughout this delay, then reachability webhooks will be fired (if enabled). A reconnection by any endpoint during this window — from the same identity — means no reachability webhook would be fired. Must be between 1000 and 30000. Defaults to 5000.

Returns:



530
531
532
533
534
535
536
537
538
539
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 530

def update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset, reachability_debouncing_enabled: :unset, reachability_debouncing_window: :unset)
  context.update(
      webhook_url: webhook_url,
      friendly_name: friendly_name,
      reachability_webhooks_enabled: reachability_webhooks_enabled,
      acl_enabled: acl_enabled,
      reachability_debouncing_enabled: reachability_debouncing_enabled,
      reachability_debouncing_window: reachability_debouncing_window,
  )
end

#urlString

Returns The url.

Returns:

  • (String)

    The url



451
452
453
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 451

def url
  @properties['url']
end

#webhook_urlString

Returns A URL that will receive event updates when objects are manipulated.

Returns:

  • (String)

    A URL that will receive event updates when objects are manipulated.



457
458
459
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 457

def webhook_url
  @properties['webhook_url']
end