Class: Twilio::REST::Messaging::V1::ServiceInstance

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

    The SID of the Service resource to fetch.



412
413
414
415
416
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
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 412

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']),
      'inbound_request_url' => payload['inbound_request_url'],
      'inbound_method' => payload['inbound_method'],
      'fallback_url' => payload['fallback_url'],
      'fallback_method' => payload['fallback_method'],
      'status_callback' => payload['status_callback'],
      'sticky_sender' => payload['sticky_sender'],
      'mms_converter' => payload['mms_converter'],
      'smart_encoding' => payload['smart_encoding'],
      'scan_message_content' => payload['scan_message_content'],
      'fallback_to_long_code' => payload['fallback_to_long_code'],
      'area_code_geomatch' => payload['area_code_geomatch'],
      'synchronous_validation' => payload['synchronous_validation'],
      'validity_period' => payload['validity_period'].to_i,
      '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



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

def 
  @properties['account_sid']
end

#alpha_sendersalpha_senders

Access the alpha_senders

Returns:



663
664
665
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 663

def alpha_senders
  context.alpha_senders
end

#area_code_geomatchBoolean

Returns Whether to enable Area Code Geomatch on the Service Instance.

Returns:

  • (Boolean)

    Whether to enable Area Code Geomatch on the Service Instance



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

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



448
449
450
451
452
453
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 448

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

#date_createdTime

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was created



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was last updated



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



642
643
644
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 642

def delete
  context.delete
end

#fallback_methodString

Returns The HTTP method we use to call fallback_url.

Returns:

  • (String)

    The HTTP method we use to call fallback_url



505
506
507
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 505

def fallback_method
  @properties['fallback_method']
end

#fallback_to_long_codeBoolean

Returns Whether to enable Fallback to Long Code for messages sent through the Service instance.

Returns:

  • (Boolean)

    Whether to enable Fallback to Long Code for messages sent through the Service instance



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

def fallback_to_long_code
  @properties['fallback_to_long_code']
end

#fallback_urlString

Returns The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL.

Returns:

  • (String)

    The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL



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

def fallback_url
  @properties['fallback_url']
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



635
636
637
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 635

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



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

def friendly_name
  @properties['friendly_name']
end

#inbound_methodString

Returns The HTTP method we use to call inbound_request_url.

Returns:

  • (String)

    The HTTP method we use to call inbound_request_url



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

def inbound_method
  @properties['inbound_method']
end

#inbound_request_urlString

Returns The URL we call using inbound_method when a message is received by any phone number or short code in the Service.

Returns:

  • (String)

    The URL we call using inbound_method when a message is received by any phone number or short code in the Service



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

def inbound_request_url
  @properties['inbound_request_url']
end

#inspectObject

Provide a detailed, user friendly representation



690
691
692
693
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 690

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

Returns The absolute URLs of related resources.

Returns:

  • (String)

    The absolute URLs of related resources



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

def links
  @properties['links']
end

#mms_converterBoolean

Returns Whether to enable the MMS Converter for messages sent through the Service instance.

Returns:

  • (Boolean)

    Whether to enable the MMS Converter for messages sent through the Service instance



523
524
525
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 523

def mms_converter
  @properties['mms_converter']
end

#phone_numbersphone_numbers

Access the phone_numbers

Returns:



649
650
651
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 649

def phone_numbers
  context.phone_numbers
end

#scan_message_contentservice.ScanMessageContent

Returns Reserved.

Returns:

  • (service.ScanMessageContent)

    Reserved



535
536
537
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 535

def scan_message_content
  @properties['scan_message_content']
end

#short_codesshort_codes

Access the short_codes

Returns:



656
657
658
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 656

def short_codes
  context.short_codes
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



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

def sid
  @properties['sid']
end

#smart_encodingBoolean

Returns Whether to enable Encoding for messages sent through the Service instance.

Returns:

  • (Boolean)

    Whether to enable Encoding for messages sent through the Service instance



529
530
531
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 529

def smart_encoding
  @properties['smart_encoding']
end

#status_callbackString

Returns The URL we call to pass status updates about message delivery.

Returns:

  • (String)

    The URL we call to pass status updates about message delivery



511
512
513
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 511

def status_callback
  @properties['status_callback']
end

#sticky_senderBoolean

Returns Whether to enable Sticky Sender on the Service instance.

Returns:

  • (Boolean)

    Whether to enable Sticky Sender on the Service instance



517
518
519
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 517

def sticky_sender
  @properties['sticky_sender']
end

#synchronous_validationBoolean

Returns Reserved.

Returns:

  • (Boolean)

    Reserved



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

def synchronous_validation
  @properties['synchronous_validation']
end

#to_sObject

Provide a user friendly representation



683
684
685
686
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 683

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

#update(friendly_name: :unset, inbound_request_url: :unset, inbound_method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, sticky_sender: :unset, mms_converter: :unset, smart_encoding: :unset, scan_message_content: :unset, fallback_to_long_code: :unset, area_code_geomatch: :unset, validity_period: :unset, synchronous_validation: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

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

    The URL we should call using ‘inbound_method` when a message is received by any phone number or short code in the Service. When this property is `null`, receiving inbound messages is disabled.

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

    The HTTP method we should use to call ‘inbound_request_url`. Can be `GET` or `POST` and the default is `POST`.

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

    The URL that we should call using ‘fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL.

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

    The HTTP method we should use to call ‘fallback_url`. Can be: `GET` or `POST`.

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

    The URL we should call to pass status updates about message delivery.

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

    Whether to enable Sticky Sender on the Service instance.

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

    Whether to enable the MMS Converter for messages sent through the Service instance.

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

    Whether to enable Smart Encoding for messages sent through the Service instance.

  • scan_message_content (service.ScanMessageContent) (defaults to: :unset)

    Reserved.

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

    Whether to enable Fallback to Long Code for messages sent through the Service instance.

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

    Whether to enable Area Code Geomatch on the Service Instance.

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

    How long, in seconds, messages sent from the Service are valid. Can be an integer from ‘1` to `14,400`.

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

    Reserved.

Returns:



613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 613

def update(friendly_name: :unset, inbound_request_url: :unset, inbound_method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, sticky_sender: :unset, mms_converter: :unset, smart_encoding: :unset, scan_message_content: :unset, fallback_to_long_code: :unset, area_code_geomatch: :unset, validity_period: :unset, synchronous_validation: :unset)
  context.update(
      friendly_name: friendly_name,
      inbound_request_url: inbound_request_url,
      inbound_method: inbound_method,
      fallback_url: fallback_url,
      fallback_method: fallback_method,
      status_callback: status_callback,
      sticky_sender: sticky_sender,
      mms_converter: mms_converter,
      smart_encoding: smart_encoding,
      scan_message_content: scan_message_content,
      fallback_to_long_code: fallback_to_long_code,
      area_code_geomatch: area_code_geomatch,
      validity_period: validity_period,
      synchronous_validation: synchronous_validation,
  )
end

#urlString

Returns The absolute URL of the Service resource.

Returns:

  • (String)

    The absolute URL of the Service resource



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

def url
  @properties['url']
end

#us_app_to_personus_app_to_person

Access the us_app_to_person

Returns:



670
671
672
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 670

def us_app_to_person
  context.us_app_to_person
end

#us_app_to_person_usecasesus_app_to_person_usecases

Access the us_app_to_person_usecases

Returns:



677
678
679
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 677

def us_app_to_person_usecases
  context.us_app_to_person_usecases
end

#validity_periodString

Returns How long, in seconds, messages sent from the Service are valid.

Returns:

  • (String)

    How long, in seconds, messages sent from the Service are valid



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

def validity_period
  @properties['validity_period']
end