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/destination_alpha_sender.rb,
lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.rb

Defined Under Namespace

Classes: AlphaSenderContext, AlphaSenderInstance, AlphaSenderInstanceMetadata, AlphaSenderList, AlphaSenderListResponse, AlphaSenderPage, AlphaSenderPageMetadata, ChannelSenderContext, ChannelSenderInstance, ChannelSenderInstanceMetadata, ChannelSenderList, ChannelSenderListResponse, ChannelSenderPage, ChannelSenderPageMetadata, DestinationAlphaSenderContext, DestinationAlphaSenderInstance, DestinationAlphaSenderInstanceMetadata, DestinationAlphaSenderList, DestinationAlphaSenderListResponse, DestinationAlphaSenderPage, DestinationAlphaSenderPageMetadata, PhoneNumberContext, PhoneNumberInstance, PhoneNumberInstanceMetadata, PhoneNumberList, PhoneNumberListResponse, PhoneNumberPage, PhoneNumberPageMetadata, ShortCodeContext, ShortCodeInstance, ShortCodeInstanceMetadata, ShortCodeList, ShortCodeListResponse, ShortCodePage, ShortCodePageMetadata, UsAppToPersonContext, UsAppToPersonInstance, UsAppToPersonInstanceMetadata, UsAppToPersonList, UsAppToPersonListResponse, UsAppToPersonPage, UsAppToPersonPageMetadata, UsAppToPersonUsecaseInstance, UsAppToPersonUsecaseList, UsAppToPersonUsecaseListResponse, UsAppToPersonUsecasePage, UsAppToPersonUsecasePageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext



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 305

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
    @destination_alpha_senders = nil
    @channel_senders = nil
end

Instance Method Details

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

Access the alpha_senders

Raises:

  • (ArgumentError)


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

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

Raises:

  • (ArgumentError)


656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 656

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



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

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the ServiceInstanceMetadata



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 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      service_instance = ServiceInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      .new(@version, service_instance, response.headers, response.status_code)
end

#destination_alpha_senders(sid = :unset) ⇒ DestinationAlphaSenderList, DestinationAlphaSenderContext

Access the destination_alpha_senders

Raises:

  • (ArgumentError)


637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 637

def destination_alpha_senders(sid=:unset)

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

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

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

 @destination_alpha_senders
end

#fetchServiceInstance

Fetch the ServiceInstance



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

#fetch_with_metadataServiceInstance

Fetch the ServiceInstanceMetadata



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

def 

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

#inspectObject

Provide a detailed, user friendly representation



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

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

Raises:

  • (ArgumentError)


599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 599

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

Raises:

  • (ArgumentError)


561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 561

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



674
675
676
677
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 674

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



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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 417

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

#update_with_metadata(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 ServiceInstanceMetadata



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 488

def (
  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', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    service_instance = ServiceInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    .new(
        @version,
        service_instance,
        response.headers,
        response.status_code
    )
end

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

Access the us_app_to_person

Raises:

  • (ArgumentError)


580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/twilio-ruby/rest/messaging/v1/service.rb', line 580

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



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

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