class Twilio::REST::Messaging::V1::ServiceContext

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Public Class Methods

new(version, sid) click to toggle source

Initialize the ServiceContext @param [Version] version Version that contains the resource @param [String] sid The SID of the Service resource to fetch. @return [ServiceContext] ServiceContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/messaging/v1/service.rb
227 def initialize(version, sid)
228   super(version)
229 
230   # Path Solution
231   @solution = {sid: sid, }
232   @uri = "/Services/#{@solution[:sid]}"
233 
234   # Dependents
235   @phone_numbers = nil
236   @short_codes = nil
237   @alpha_senders = nil
238   @us_app_to_person = nil
239   @us_app_to_person_usecases = nil
240 end

Public Instance Methods

alpha_senders(sid=:unset) click to toggle source

Access the alpha_senders @return [AlphaSenderList] @return [AlphaSenderContext] if sid was passed.

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
371 def alpha_senders(sid=:unset)
372   raise ArgumentError, 'sid cannot be nil' if sid.nil?
373 
374   if sid != :unset
375     return AlphaSenderContext.new(@version, @solution[:sid], sid, )
376   end
377 
378   unless @alpha_senders
379     @alpha_senders = AlphaSenderList.new(@version, service_sid: @solution[:sid], )
380   end
381 
382   @alpha_senders
383 end
delete() click to toggle source

Delete the ServiceInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
327 def delete
328    @version.delete('DELETE', @uri)
329 end
fetch() click to toggle source

Fetch the ServiceInstance @return [ServiceInstance] Fetched ServiceInstance

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
318 def fetch
319   payload = @version.fetch('GET', @uri)
320 
321   ServiceInstance.new(@version, payload, sid: @solution[:sid], )
322 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
427 def inspect
428   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
429   "#<Twilio.Messaging.V1.ServiceContext #{context}>"
430 end
phone_numbers(sid=:unset) click to toggle source

Access the phone_numbers @return [PhoneNumberList] @return [PhoneNumberContext] if sid was passed.

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
335 def phone_numbers(sid=:unset)
336   raise ArgumentError, 'sid cannot be nil' if sid.nil?
337 
338   if sid != :unset
339     return PhoneNumberContext.new(@version, @solution[:sid], sid, )
340   end
341 
342   unless @phone_numbers
343     @phone_numbers = PhoneNumberList.new(@version, service_sid: @solution[:sid], )
344   end
345 
346   @phone_numbers
347 end
short_codes(sid=:unset) click to toggle source

Access the short_codes @return [ShortCodeList] @return [ShortCodeContext] if sid was passed.

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
353 def short_codes(sid=:unset)
354   raise ArgumentError, 'sid cannot be nil' if sid.nil?
355 
356   if sid != :unset
357     return ShortCodeContext.new(@version, @solution[:sid], sid, )
358   end
359 
360   unless @short_codes
361     @short_codes = ShortCodeList.new(@version, service_sid: @solution[:sid], )
362   end
363 
364   @short_codes
365 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
420 def to_s
421   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
422   "#<Twilio.Messaging.V1.ServiceContext #{context}>"
423 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, use_inbound_webhook_on_number: :unset) click to toggle source

Update the ServiceInstance @param [String] friendly_name A descriptive string that you create to describe

the resource. It can be up to 64 characters long.

@param [String] inbound_request_url 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.

@param [String] inbound_method The HTTP method we should use to call

`inbound_request_url`. Can be `GET` or `POST` and the default is `POST`.

@param [String] fallback_url 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.

@param [String] fallback_method The HTTP method we should use to call

`fallback_url`. Can be: `GET` or `POST`.

@param [String] status_callback The URL we should call to {pass status

updates}[https://www.twilio.com/docs/sms/api/message-resource#message-status-values]
about message delivery.

@param [Boolean] sticky_sender Whether to enable {Sticky

Sender}[https://www.twilio.com/docs/sms/services#sticky-sender] on the Service
instance.

@param [Boolean] mms_converter Whether to enable the {MMS

Converter}[https://www.twilio.com/docs/sms/services#mms-converter] for messages
sent through the Service instance.

@param [Boolean] smart_encoding Whether to enable {Smart

Encoding}[https://www.twilio.com/docs/sms/services#smart-encoding] for messages
sent through the Service instance.

@param [service.ScanMessageContent] scan_message_content Reserved. @param [Boolean] fallback_to_long_code Whether to enable {Fallback to Long

Code}[https://www.twilio.com/docs/sms/services#fallback-to-long-code] for
messages sent through the Service instance.

@param [Boolean] area_code_geomatch Whether to enable {Area Code

Geomatch}[https://www.twilio.com/docs/sms/services#area-code-geomatch] on the
Service Instance.

@param [String] validity_period How long, in seconds, messages sent from the

Service are valid. Can be an integer from `1` to `14,400`.

@param [Boolean] synchronous_validation Reserved. @param [Boolean] use_inbound_webhook_on_number 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.

@return [ServiceInstance] Updated ServiceInstance

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
291 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, use_inbound_webhook_on_number: :unset)
292   data = Twilio::Values.of({
293       'FriendlyName' => friendly_name,
294       'InboundRequestUrl' => inbound_request_url,
295       'InboundMethod' => inbound_method,
296       'FallbackUrl' => fallback_url,
297       'FallbackMethod' => fallback_method,
298       'StatusCallback' => status_callback,
299       'StickySender' => sticky_sender,
300       'MmsConverter' => mms_converter,
301       'SmartEncoding' => smart_encoding,
302       'ScanMessageContent' => scan_message_content,
303       'FallbackToLongCode' => fallback_to_long_code,
304       'AreaCodeGeomatch' => area_code_geomatch,
305       'ValidityPeriod' => validity_period,
306       'SynchronousValidation' => synchronous_validation,
307       'UseInboundWebhookOnNumber' => use_inbound_webhook_on_number,
308   })
309 
310   payload = @version.update('POST', @uri, data: data)
311 
312   ServiceInstance.new(@version, payload, sid: @solution[:sid], )
313 end
us_app_to_person(sid=:unset) click to toggle source

Access the us_app_to_person @return [UsAppToPersonList] @return [UsAppToPersonContext] if sid was passed.

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
389 def us_app_to_person(sid=:unset)
390   raise ArgumentError, 'sid cannot be nil' if sid.nil?
391 
392   if sid != :unset
393     return UsAppToPersonContext.new(@version, @solution[:sid], sid, )
394   end
395 
396   unless @us_app_to_person
397     @us_app_to_person = UsAppToPersonList.new(@version, messaging_service_sid: @solution[:sid], )
398   end
399 
400   @us_app_to_person
401 end
us_app_to_person_usecases() click to toggle source

Access the us_app_to_person_usecases @return [UsAppToPersonUsecaseList] @return [UsAppToPersonUsecaseContext]

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
407 def us_app_to_person_usecases
408   unless @us_app_to_person_usecases
409     @us_app_to_person_usecases = UsAppToPersonUsecaseList.new(
410         @version,
411         messaging_service_sid: @solution[:sid],
412     )
413   end
414 
415   @us_app_to_person_usecases
416 end