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

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/proxy/v1/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

  • account_sid (String)

    The SID of the Account that created this Service resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 359

def initialize(version, payload , sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'unique_name' => payload['unique_name'],
        'account_sid' => payload['account_sid'],
        'chat_instance_sid' => payload['chat_instance_sid'],
        'callback_url' => payload['callback_url'],
        'default_ttl' => payload['default_ttl'] == nil ? payload['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 The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Service resource.

Returns:



410
411
412
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 410

def 
    @properties['account_sid']
end

#callback_urlString

Returns The URL we call when the interaction status changes.

Returns:

  • (String)

    The URL we call when the interaction status changes.



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

def callback_url
    @properties['callback_url']
end

#chat_instance_sidString

Returns The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship.

Returns:

  • (String)

    The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship.



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

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



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

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

#date_createdTime

Returns The [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created.

Returns:



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

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.

Returns:



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

def date_updated
    @properties['date_updated']
end

#default_ttlString

Returns The default ‘ttl` value for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session’s last create or last Interaction. The default value of ‘0` indicates an unlimited Session length. You can override a Session’s default TTL value by setting its ‘ttl` value.

Returns:

  • (String)

    The default ‘ttl` value for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session’s last create or last Interaction. The default value of ‘0` indicates an unlimited Session length. You can override a Session’s default TTL value by setting its ‘ttl` value.



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

def default_ttl
    @properties['default_ttl']
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



483
484
485
486
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 483

def delete

    context.delete
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



491
492
493
494
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 491

def fetch

    context.fetch
end

#geo_match_levelGeoMatchLevel

Returns:

  • (GeoMatchLevel)


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

def geo_match_level
    @properties['geo_match_level']
end

#inspectObject

Provide a detailed, user friendly representation



560
561
562
563
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 560

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

#intercept_callback_urlString

Returns The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues.

Returns:

  • (String)

    The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues.



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

def intercept_callback_url
    @properties['intercept_callback_url']
end

Returns The URLs of resources related to the Service.

Returns:

  • (Hash)

    The URLs of resources related to the Service.



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

def links
    @properties['links']
end

#number_selection_behaviorNumberSelectionBehavior

Returns:

  • (NumberSelectionBehavior)


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

def number_selection_behavior
    @properties['number_selection_behavior']
end

#out_of_session_callback_urlString

Returns The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information.

Returns:



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

def out_of_session_callback_url
    @properties['out_of_session_callback_url']
end

#phone_numbersphone_numbers

Access the phone_numbers

Returns:



547
548
549
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 547

def phone_numbers
    context.phone_numbers
end

#sessionssessions

Access the sessions

Returns:



533
534
535
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 533

def sessions
    context.sessions
end

#short_codesshort_codes

Access the short_codes

Returns:



540
541
542
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 540

def short_codes
    context.short_codes
end

#sidString

Returns The unique string that we created to identify the Service resource.

Returns:

  • (String)

    The unique string that we created to identify the Service resource.



398
399
400
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 398

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



553
554
555
556
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 553

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

#unique_nameString

Returns An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. Supports UTF-8 characters. **This value should not have PII.**.

Returns:

  • (String)

    An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. Supports UTF-8 characters. **This value should not have PII.**



404
405
406
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 404

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, chat_instance_sid: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.**

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

    The default ‘ttl` value to set for Sessions created in the Service. The TTL (time to live) is measured in seconds after the Session’s last create or last Interaction. The default value of ‘0` indicates an unlimited Session length. You can override a Session’s default TTL value by setting its ‘ttl` value.

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

    The URL we should call when the interaction status changes.

  • geo_match_level (GeoMatchLevel) (defaults to: :unset)
  • number_selection_behavior (NumberSelectionBehavior) (defaults to: :unset)
  • intercept_callback_url (String) (defaults to: :unset)

    The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues.

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

    The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information.

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

    The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship.

Returns:



507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
# File 'lib/twilio-ruby/rest/proxy/v1/service.rb', line 507

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, 
    chat_instance_sid: :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, 
        chat_instance_sid: chat_instance_sid, 
    )
end

#urlString

Returns The absolute URL of the Service resource.

Returns:

  • (String)

    The absolute URL of the Service resource.



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

def url
    @properties['url']
end