Class: Twilio::REST::Proxy::V1::ServiceInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/proxy/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 34 character string that uniquely identifies this Service.



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 339

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

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'unique_name' => payload['unique_name'],
      'account_sid' => payload['account_sid'],
      'callback_url' => payload['callback_url'],
      'default_ttl' => payload['default_ttl'].to_i,
      'number_selection_behavior' => payload['number_selection_behavior'],
      'geo_match_level' => payload['geo_match_level'],
      'intercept_callback_url' => payload['intercept_callback_url'],
      'out_of_session_callback_url' => payload['out_of_session_callback_url'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
      'links' => payload['links'],
  }

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

Instance Method Details

#account_sidString

Returns Account Sid.

Returns:

  • (String)

    Account Sid.



389
390
391
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 389

def 
  @properties['account_sid']
end

#callback_urlString

Returns URL Twilio will send callbacks to.

Returns:

  • (String)

    URL Twilio will send callbacks to



395
396
397
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 395

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



368
369
370
371
372
373
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 368

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

#date_createdTime

Returns The date this Service was created.

Returns:

  • (Time)

    The date this Service was created



431
432
433
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 431

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this Service was updated.

Returns:

  • (Time)

    The date this Service was updated



437
438
439
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 437

def date_updated
  @properties['date_updated']
end

#default_ttlString

Returns Default TTL for a Session, in seconds.

Returns:

  • (String)

    Default TTL for a Session, in seconds.



401
402
403
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 401

def default_ttl
  @properties['default_ttl']
end

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

def delete
  context.delete
end

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



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

def fetch
  context.fetch
end

#geo_match_levelservice.GeoMatchLevel

Returns Whether to limit proxy numbers in the same areacode.

Returns:

  • (service.GeoMatchLevel)

    Whether to limit proxy numbers in the same areacode.



413
414
415
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 413

def geo_match_level
  @properties['geo_match_level']
end

#inspectObject

Provide a detailed, user friendly representation



527
528
529
530
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 527

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

#intercept_callback_urlString

Returns A URL for Twilio call before each Interaction.

Returns:

  • (String)

    A URL for Twilio call before each Interaction.



419
420
421
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 419

def intercept_callback_url
  @properties['intercept_callback_url']
end

Returns Nested resource URLs.

Returns:

  • (String)

    Nested resource URLs.



449
450
451
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 449

def links
  @properties['links']
end

#number_selection_behaviorservice.NumberSelectionBehavior

Returns What behavior to use when choosing a proxy number.

Returns:

  • (service.NumberSelectionBehavior)

    What behavior to use when choosing a proxy number.



407
408
409
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 407

def number_selection_behavior
  @properties['number_selection_behavior']
end

#out_of_session_callback_urlString

Returns A URL for Twilio call when a new Interaction has no Session.

Returns:

  • (String)

    A URL for Twilio call when a new Interaction has no Session.



425
426
427
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 425

def out_of_session_callback_url
  @properties['out_of_session_callback_url']
end

#phone_numbersphone_numbers

Access the phone_numbers

Returns:



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

def phone_numbers
  context.phone_numbers
end

#sessionssessions

Access the sessions

Returns:



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

def sessions
  context.sessions
end

#short_codesshort_codes

Access the short_codes

Returns:



514
515
516
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 514

def short_codes
  context.short_codes
end

#sidString

Returns A string that uniquely identifies this Service.

Returns:

  • (String)

    A string that uniquely identifies this Service.



377
378
379
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 377

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



520
521
522
523
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 520

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

#unique_nameString

Returns A human readable description of this resource.

Returns:

  • (String)

    A human readable description of this resource.



383
384
385
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 383

def unique_name
  @properties['unique_name']
end

#update(unique_name: :unset, default_ttl: :unset, callback_url: :unset, geo_match_level: :unset, number_selection_behavior: :unset, intercept_callback_url: :unset, out_of_session_callback_url: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    A human readable description of this resource, up to 64 characters.

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

    The default time delay, in seconds, after which a session will be expired. Will be used for sessions where ttl is not specified.

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

    The URL to which Twilio will make callbacks on interaction status changes.

  • geo_match_level (service.GeoMatchLevel) (defaults to: :unset)

    Default: country Options: country, area-code, extended-area-code

  • number_selection_behavior (service.NumberSelectionBehavior) (defaults to: :unset)

    Default: prefer-sticky Options: prefer-sticky, avoid-sticky

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

    Fires on each interaction. If responded to with a 403 to this webhook, we will abort/block the interaction. For any other status or timeout, the interaction continues.

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

    A URL for Twilio call when a new Interaction has no Session.

Returns:



485
486
487
488
489
490
491
492
493
494
495
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 485

def update(unique_name: :unset, default_ttl: :unset, callback_url: :unset, geo_match_level: :unset, number_selection_behavior: :unset, intercept_callback_url: :unset, out_of_session_callback_url: :unset)
  context.update(
      unique_name: unique_name,
      default_ttl: default_ttl,
      callback_url: callback_url,
      geo_match_level: geo_match_level,
      number_selection_behavior: number_selection_behavior,
      intercept_callback_url: intercept_callback_url,
      out_of_session_callback_url: out_of_session_callback_url,
  )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



443
444
445
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 443

def url
  @properties['url']
end