Class: Twilio::REST::Messaging::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/service.rb,
lib/twilio-ruby/rest/messaging/v1/service/short_code.rb,
lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb,
lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb,
lib/twilio-ruby/rest/messaging/v1/service/channel_sender.rb,
lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb,
lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.rb

Defined Under Namespace

Classes: AlphaSenderContext, AlphaSenderInstance, AlphaSenderList, AlphaSenderPage, ChannelSenderContext, ChannelSenderInstance, ChannelSenderList, ChannelSenderPage, PhoneNumberContext, PhoneNumberInstance, PhoneNumberList, PhoneNumberPage, ShortCodeContext, ShortCodeInstance, ShortCodeList, ShortCodePage, UsAppToPersonContext, UsAppToPersonInstance, UsAppToPersonList, UsAppToPersonPage, UsAppToPersonUsecaseInstance, UsAppToPersonUsecaseList, UsAppToPersonUsecasePage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the Service resource to update.



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 206

def initialize(version, sid)
    super(version)

    # Path Solution
    @solution = { sid: sid,  }
    @uri = "/Services/#{@solution[:sid]}"

    # Dependents
    @us_app_to_person_usecases = nil
    @short_codes = nil
    @us_app_to_person = nil
    @phone_numbers = nil
    @alpha_senders = nil
    @channel_senders = nil
end

Instance Method Details

#alpha_senders(sid = :unset) ⇒ AlphaSenderList, AlphaSenderContext

Access the alpha_senders

Returns:

Raises:

  • (ArgumentError)


395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 395

def alpha_senders(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return AlphaSenderContext.new(@version, @solution[:sid],sid )
    end

    unless @alpha_senders
        @alpha_senders = AlphaSenderList.new(
            @version, service_sid: @solution[:sid], )
    end

 @alpha_senders
end

#channel_senders(sid = :unset) ⇒ ChannelSenderList, ChannelSenderContext

Access the channel_senders

Returns:

Raises:

  • (ArgumentError)


414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 414

def channel_senders(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return ChannelSenderContext.new(@version, @solution[:sid],sid )
    end

    unless @channel_senders
        @channel_senders = ChannelSenderList.new(
            @version, messaging_service_sid: @solution[:sid], )
    end

 @channel_senders
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



224
225
226
227
228
229
230
231
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 224

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 236

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    ServiceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Messaging.V1.ServiceContext #{context}>"
end

#phone_numbers(sid = :unset) ⇒ PhoneNumberList, PhoneNumberContext

Access the phone_numbers

Returns:

Raises:

  • (ArgumentError)


376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 376

def phone_numbers(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return PhoneNumberContext.new(@version, @solution[:sid],sid )
    end

    unless @phone_numbers
        @phone_numbers = PhoneNumberList.new(
            @version, service_sid: @solution[:sid], )
    end

 @phone_numbers
end

#short_codes(sid = :unset) ⇒ ShortCodeList, ShortCodeContext

Access the short_codes

Returns:

Raises:

  • (ArgumentError)


338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 338

def short_codes(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return ShortCodeContext.new(@version, @solution[:sid],sid )
    end

    unless @short_codes
        @short_codes = ShortCodeList.new(
            @version, service_sid: @solution[:sid], )
    end

 @short_codes
end

#to_sObject

Provide a user friendly representation



432
433
434
435
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 432

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Messaging.V1.ServiceContext #{context}>"
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:



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 271

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
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'InboundRequestUrl' => inbound_request_url,
        'InboundMethod' => inbound_method,
        'FallbackUrl' => fallback_url,
        'FallbackMethod' => fallback_method,
        'StatusCallback' => status_callback,
        'StickySender' => sticky_sender,
        'MmsConverter' => mms_converter,
        'SmartEncoding' => smart_encoding,
        'ScanMessageContent' => scan_message_content,
        'FallbackToLongCode' => fallback_to_long_code,
        'AreaCodeGeomatch' => area_code_geomatch,
        'ValidityPeriod' => validity_period,
        'SynchronousValidation' => synchronous_validation,
        'Usecase' => usecase,
        'UseInboundWebhookOnNumber' => use_inbound_webhook_on_number,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    ServiceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#us_app_to_person(sid = :unset) ⇒ UsAppToPersonList, UsAppToPersonContext

Access the us_app_to_person

Returns:

Raises:

  • (ArgumentError)


357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 357

def us_app_to_person(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return UsAppToPersonContext.new(@version, @solution[:sid],sid )
    end

    unless @us_app_to_person
        @us_app_to_person = UsAppToPersonList.new(
            @version, messaging_service_sid: @solution[:sid], )
    end

 @us_app_to_person
end

#us_app_to_person_usecasesUsAppToPersonUsecaseList, UsAppToPersonUsecaseContext

Access the us_app_to_person_usecases

Returns:



327
328
329
330
331
332
333
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 327

def us_app_to_person_usecases
  unless @us_app_to_person_usecases
    @us_app_to_person_usecases = UsAppToPersonUsecaseList.new(
            @version, messaging_service_sid: @solution[:sid], )
  end
  @us_app_to_person_usecases
end