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

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



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 462

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'],
        'sending_windows' => payload['sending_windows'],
    }

    # 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:



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

def 
    @properties['account_sid']
end

#alpha_sendersalpha_senders

Access the alpha_senders

Returns:



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

def alpha_senders
    context.alpha_senders
end

#area_code_geomatchBoolean

Returns Whether to enable [Area Code Geomatch](www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance.

Returns:



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

def area_code_geomatch
    @properties['area_code_geomatch']
end

#channel_senderschannel_senders

Access the channel_senders

Returns:



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

def channel_senders
    context.channel_senders
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:



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

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

#date_createdTime

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

Returns:



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

def date_created
    @properties['date_created']
end

#date_updatedTime

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

Returns:



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

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    context.delete
end

#fallback_methodString

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

Returns:

  • (String)

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



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

def fallback_method
    @properties['fallback_method']
end

#fallback_to_long_codeBoolean

Returns [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.

Returns:

  • (Boolean)
    OBSOLETE

    Former feature used to fallback to long code sender after certain short code message failures.



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

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

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



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

def fallback_url
    @properties['fallback_url']
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



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

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.



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

def friendly_name
    @properties['friendly_name']
end

#inbound_methodString

Returns The HTTP method we use to call ‘inbound_request_url`. Can be `GET` or `POST`.

Returns:

  • (String)

    The HTTP method we use to call ‘inbound_request_url`. Can be `GET` or `POST`.



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

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

Returns:

  • (String)

    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.



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

def inbound_request_url
    @properties['inbound_request_url']
end

#inspectObject

Provide a detailed, user friendly representation



778
779
780
781
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 778

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

Returns The absolute URLs of related resources.

Returns:

  • (Hash)

    The absolute URLs of related resources.



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

def links
    @properties['links']
end

#mms_converterBoolean

Returns Whether to enable the [MMS Converter](www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance.

Returns:



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

def mms_converter
    @properties['mms_converter']
end

#phone_numbersphone_numbers

Access the phone_numbers

Returns:



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

def phone_numbers
    context.phone_numbers
end

#scan_message_contentScanMessageContent

Returns:

  • (ScanMessageContent)


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

def scan_message_content
    @properties['scan_message_content']
end

#sending_windowsHash

Returns A list of Sending Windows, which indicate defined time ranges in which a message can be sent, in the UTC time zone. Each window is defined by two strings, labeled "start_time" and "end_time".

Returns:

  • (Hash)

    A list of Sending Windows, which indicate defined time ranges in which a message can be sent, in the UTC time zone. Each window is defined by two strings, labeled "start_time" and "end_time".



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

def sending_windows
    @properties['sending_windows']
end

#short_codesshort_codes

Access the short_codes

Returns:



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

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.



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

def sid
    @properties['sid']
end

#smart_encodingBoolean

Returns Whether to enable [Smart Encoding](www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance.

Returns:



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

def smart_encoding
    @properties['smart_encoding']
end

#status_callbackString

Returns The URL we call to [pass status updates](www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery.

Returns:



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

def status_callback
    @properties['status_callback']
end

#sticky_senderBoolean

Returns Whether to enable [Sticky Sender](www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance.

Returns:



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

def sticky_sender
    @properties['sticky_sender']
end

#synchronous_validationBoolean

Returns Reserved.

Returns:

  • (Boolean)

    Reserved.



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

def synchronous_validation
    @properties['synchronous_validation']
end

#to_sObject

Provide a user friendly representation



771
772
773
774
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 771

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](www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery.

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

    Whether to enable [Sticky Sender](www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance.

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

    Whether to enable the [MMS Converter](www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance.

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

    Whether to enable [Smart Encoding](www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance.

  • scan_message_content (ScanMessageContent) (defaults to: :unset)
  • fallback_to_long_code (Boolean) (defaults to: :unset)
    OBSOLETE

    Former feature used to fallback to long code sender after certain short code message failures.

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

    Whether to enable [Area Code Geomatch](www.twilio.com/docs/messaging/services#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. Possible values are ‘notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`.

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



688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 688

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

#urlString

Returns The absolute URL of the Service resource.

Returns:

  • (String)

    The absolute URL of the Service resource.



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

def url
    @properties['url']
end

#us_app_to_personus_app_to_person

Access the us_app_to_person

Returns:



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

def us_app_to_person
    context.us_app_to_person
end

#us_app_to_person_registeredBoolean

Returns Whether US A2P campaign is registered for this Service.

Returns:

  • (Boolean)

    Whether US A2P campaign is registered for this Service.



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

def us_app_to_person_registered
    @properties['us_app_to_person_registered']
end

#us_app_to_person_usecasesus_app_to_person_usecases

Access the us_app_to_person_usecases

Returns:



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

def us_app_to_person_usecases
    context.us_app_to_person_usecases
end

#use_inbound_webhook_on_numberBoolean

Returns 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:

  • (Boolean)

    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.



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

def use_inbound_webhook_on_number
    @properties['use_inbound_webhook_on_number']
end

#usecaseString

Returns A string that describes the scenario in which the Messaging Service will be used. Possible values are ‘notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`.

Returns:

  • (String)

    A string that describes the scenario in which the Messaging Service will be used. Possible values are ‘notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`.



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

def usecase
    @properties['usecase']
end

#validity_periodString

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

Returns:

  • (String)

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



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

def validity_period
    @properties['validity_period']
end