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.



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 450

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'] == nil ? payload['validity_period'] : payload['validity_period'].to_i,
      'url' => payload['url'],
      'links' => payload['links'],
      'usecase' => payload['usecase'],
      'us_app_to_person_registered' => payload['us_app_to_person_registered'],
      'use_inbound_webhook_on_number' => payload['use_inbound_webhook_on_number'],
  }

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

Instance Method Details

#account_sid ⇒ String

Returns The SID of the Account that created the resource.

Returns:

  • (String) —

    The SID of the Account that created the resource



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

def 
  @properties['account_sid']
end

#alpha_senders ⇒ alpha_senders

Access the alpha_senders

Returns:



738
739
740
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 738

def alpha_senders
  context.alpha_senders
end

#area_code_geomatch ⇒ Boolean

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

Returns:

  • (Boolean) —

    Whether to enable Area Code Geomatch on the Service Instance



588
589
590
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 588

def area_code_geomatch
  @properties['area_code_geomatch']
end

#context ⇒ ServiceContext

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

Returns:



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

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

#date_created ⇒ Time

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



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

def date_created
  @properties['date_created']
end

#date_updated ⇒ Time

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



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

def date_updated
  @properties['date_updated']
end

#delete ⇒ Boolean

Delete the ServiceInstance

Returns:

  • (Boolean) —

    true if delete succeeds, false otherwise



717
718
719
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 717

def delete
  context.delete
end

#fallback_method ⇒ String

Returns The HTTP method we use to call fallback_url.

Returns:

  • (String) —

    The HTTP method we use to call fallback_url



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

def fallback_method
  @properties['fallback_method']
end

#fallback_to_long_code ⇒ Boolean

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



582
583
584
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 582

def fallback_to_long_code
  @properties['fallback_to_long_code']
end

#fallback_url ⇒ String

Returns The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. This field will be overridden if the use_inbound_webhook_on_number field is enabled.

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. This field will be overridden if the use_inbound_webhook_on_number field is enabled.



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

def fallback_url
  @properties['fallback_url']
end

#fetch ⇒ ServiceInstance

Fetch the ServiceInstance

Returns:



710
711
712
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 710

def fetch
  context.fetch
end

#friendly_name ⇒ String

Returns The string that you assigned to describe the resource.

Returns:

  • (String) —

    The string that you assigned to describe the resource



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

def friendly_name
  @properties['friendly_name']
end

#inbound_method ⇒ String

Returns The HTTP method we use to call inbound_request_url.

Returns:

  • (String) —

    The HTTP method we use to call inbound_request_url



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

def inbound_method
  @properties['inbound_method']
end

#inbound_request_url ⇒ String

Returns The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the use_inbound_webhook_on_number field is enabled.

Returns:

  • (String) —

    The URL we call using inbound_method when a message is received by any phone number or short code in the Service. This field will be overridden if the use_inbound_webhook_on_number field is enabled.



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

def inbound_request_url
  @properties['inbound_request_url']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



765
766
767
768
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 765

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



612
613
614
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 612

def links
  @properties['links']
end

#mms_converter ⇒ Boolean

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



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

def mms_converter
  @properties['mms_converter']
end

#phone_numbers ⇒ phone_numbers

Access the phone_numbers

Returns:



724
725
726
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 724

def phone_numbers
  context.phone_numbers
end

#scan_message_content ⇒ service.ScanMessageContent

Returns Reserved.

Returns:

  • (service.ScanMessageContent) —

    Reserved



576
577
578
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 576

def scan_message_content
  @properties['scan_message_content']
end

#short_codes ⇒ short_codes

Access the short_codes

Returns:



731
732
733
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 731

def short_codes
  context.short_codes
end

#sid ⇒ String

Returns The unique string that identifies the resource.

Returns:

  • (String) —

    The unique string that identifies the resource



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

def sid
  @properties['sid']
end

#smart_encoding ⇒ Boolean

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



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

def smart_encoding
  @properties['smart_encoding']
end

#status_callback ⇒ String

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



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

def status_callback
  @properties['status_callback']
end

#sticky_sender ⇒ Boolean

Returns Whether to enable Sticky Sender on the Service instance.

Returns:

  • (Boolean) —

    Whether to enable Sticky Sender on the Service instance



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

def sticky_sender
  @properties['sticky_sender']
end

#synchronous_validation ⇒ Boolean

Returns Reserved.

Returns:

  • (Boolean) —

    Reserved



594
595
596
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 594

def synchronous_validation
  @properties['synchronous_validation']
end

#to_s ⇒ Object

Provide a user friendly representation



758
759
760
761
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 758

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, usecase: :unset, use_inbound_webhook_on_number: :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 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. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the inbound_request_url defined for the Messaging Service.

  • 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 call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the fallback_url defined for the Messaging Service.

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

  • usecase (String) (defaults to: :unset) —

    A string that describes the scenario in which the Messaging Service will be used. Examples: [notification, marketing, verification, poll ..]

  • use_inbound_webhook_on_number (Boolean) (defaults to: :unset) —

    A boolean value that indicates either the webhook url configured on the phone number will be used or inbound_request_url/fallback_url url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the inbound_request_url/fallback_url defined for the Messaging Service.

Returns:



686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 686

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, usecase: :unset, use_inbound_webhook_on_number: :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,
      usecase: usecase,
      use_inbound_webhook_on_number: use_inbound_webhook_on_number,
  )
end

#url ⇒ String

Returns The absolute URL of the Service resource.

Returns:

  • (String) —

    The absolute URL of the Service resource



606
607
608
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 606

def url
  @properties['url']
end

#us_app_to_person ⇒ us_app_to_person

Access the us_app_to_person

Returns:



745
746
747
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 745

def us_app_to_person
  context.us_app_to_person
end

#us_app_to_person_registered ⇒ Boolean

Returns Whether US A2P campaign is registered for this Service.

Returns:

  • (Boolean) —

    Whether US A2P campaign is registered for this Service.



624
625
626
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 624

def us_app_to_person_registered
  @properties['us_app_to_person_registered']
end

#us_app_to_person_usecases ⇒ us_app_to_person_usecases

Access the us_app_to_person_usecases

Returns:



752
753
754
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 752

def us_app_to_person_usecases
  context.us_app_to_person_usecases
end

#use_inbound_webhook_on_number ⇒ Boolean

Returns If enabled, the webhook url configured on the phone number will be used and will override the inbound_request_url/fallback_url url called when an inbound message is received.

Returns:

  • (Boolean) —

    If enabled, the webhook url configured on the phone number will be used and will override the inbound_request_url/fallback_url url called when an inbound message is received.



630
631
632
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 630

def use_inbound_webhook_on_number
  @properties['use_inbound_webhook_on_number']
end

#usecase ⇒ String

Returns A string describing the scenario in which the Messaging Service will be used.

Returns:

  • (String) —

    A string describing the scenario in which the Messaging Service will be used



618
619
620
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 618

def usecase
  @properties['usecase']
end

#validity_period ⇒ String

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



600
601
602
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 600

def validity_period
  @properties['validity_period']
end