Class: Twilio::REST::IpMessaging::V2::ServiceContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/binding.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb

Defined Under Namespace

Classes: BindingContext, BindingInstance, BindingInstanceMetadata, BindingList, BindingListResponse, BindingPage, BindingPageMetadata, ChannelContext, ChannelInstance, ChannelInstanceMetadata, ChannelList, ChannelListResponse, ChannelPage, ChannelPageMetadata, RoleContext, RoleInstance, RoleInstanceMetadata, RoleList, RoleListResponse, RolePage, RolePageMetadata, UserContext, UserInstance, UserInstanceMetadata, UserList, UserListResponse, UserPage, UserPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)


215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 215

def initialize(version, sid)
    super(version)
    

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

    # Dependents
    @bindings = nil
    @channels = nil
    @roles = nil
    @users = nil
end

Instance Method Details

#bindings(sid = :unset) ⇒ BindingList, BindingContext

Access the bindings

Returns:

Raises:

  • (ArgumentError)


547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 547

def bindings(sid=:unset)

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

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

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

 @bindings
end

#channels(sid = :unset) ⇒ ChannelList, ChannelContext

Access the channels

Returns:

Raises:

  • (ArgumentError)


566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 566

def channels(sid=:unset)

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

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

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

 @channels
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



232
233
234
235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 232

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

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 245

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

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 264

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

Returns:



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 283

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



629
630
631
632
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 629

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

#roles(sid = :unset) ⇒ RoleList, RoleContext

Access the roles

Returns:

Raises:

  • (ArgumentError)


585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 585

def roles(sid=:unset)

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

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

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

 @roles
end

#to_sObject

Provide a user friendly representation



622
623
624
625
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 622

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

#update(friendly_name: :unset, default_service_role_sid: :unset, default_channel_role_sid: :unset, default_channel_creator_role_sid: :unset, read_status_enabled: :unset, reachability_enabled: :unset, typing_indicator_timeout: :unset, consumption_report_interval: :unset, notifications_new_message_enabled: :unset, notifications_new_message_template: :unset, notifications_new_message_sound: :unset, notifications_new_message_badge_count_enabled: :unset, notifications_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_added_to_channel_sound: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_removed_from_channel_sound: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, notifications_invited_to_channel_sound: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, limits_channel_members: :unset, limits_user_channels: :unset, media_compatibility_message: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, notifications_log_enabled: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)
  • default_service_role_sid (String) (defaults to: :unset)
  • default_channel_role_sid (String) (defaults to: :unset)
  • default_channel_creator_role_sid (String) (defaults to: :unset)
  • read_status_enabled (Boolean) (defaults to: :unset)
  • reachability_enabled (Boolean) (defaults to: :unset)
  • typing_indicator_timeout (String) (defaults to: :unset)
  • consumption_report_interval (String) (defaults to: :unset)
  • notifications_new_message_enabled (Boolean) (defaults to: :unset)
  • notifications_new_message_template (String) (defaults to: :unset)
  • notifications_new_message_sound (String) (defaults to: :unset)
  • notifications_new_message_badge_count_enabled (Boolean) (defaults to: :unset)
  • notifications_added_to_channel_enabled (Boolean) (defaults to: :unset)
  • notifications_added_to_channel_template (String) (defaults to: :unset)
  • notifications_added_to_channel_sound (String) (defaults to: :unset)
  • notifications_removed_from_channel_enabled (Boolean) (defaults to: :unset)
  • notifications_removed_from_channel_template (String) (defaults to: :unset)
  • notifications_removed_from_channel_sound (String) (defaults to: :unset)
  • notifications_invited_to_channel_enabled (Boolean) (defaults to: :unset)
  • notifications_invited_to_channel_template (String) (defaults to: :unset)
  • notifications_invited_to_channel_sound (String) (defaults to: :unset)
  • pre_webhook_url (String) (defaults to: :unset)
  • post_webhook_url (String) (defaults to: :unset)
  • webhook_method (String) (defaults to: :unset)
  • webhook_filters (Array[String]) (defaults to: :unset)
  • limits_channel_members (String) (defaults to: :unset)
  • limits_user_channels (String) (defaults to: :unset)
  • media_compatibility_message (String) (defaults to: :unset)
  • pre_webhook_retry_count (String) (defaults to: :unset)
  • post_webhook_retry_count (String) (defaults to: :unset)
  • notifications_log_enabled (Boolean) (defaults to: :unset)

Returns:



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 339

def update(
    friendly_name: :unset, 
    default_service_role_sid: :unset, 
    default_channel_role_sid: :unset, 
    default_channel_creator_role_sid: :unset, 
    read_status_enabled: :unset, 
    reachability_enabled: :unset, 
    typing_indicator_timeout: :unset, 
    consumption_report_interval: :unset, 
    notifications_new_message_enabled: :unset, 
    notifications_new_message_template: :unset, 
    notifications_new_message_sound: :unset, 
    notifications_new_message_badge_count_enabled: :unset, 
    notifications_added_to_channel_enabled: :unset, 
    notifications_added_to_channel_template: :unset, 
    notifications_added_to_channel_sound: :unset, 
    notifications_removed_from_channel_enabled: :unset, 
    notifications_removed_from_channel_template: :unset, 
    notifications_removed_from_channel_sound: :unset, 
    notifications_invited_to_channel_enabled: :unset, 
    notifications_invited_to_channel_template: :unset, 
    notifications_invited_to_channel_sound: :unset, 
    pre_webhook_url: :unset, 
    post_webhook_url: :unset, 
    webhook_method: :unset, 
    webhook_filters: :unset, 
    limits_channel_members: :unset, 
    limits_user_channels: :unset, 
    media_compatibility_message: :unset, 
    pre_webhook_retry_count: :unset, 
    post_webhook_retry_count: :unset, 
    notifications_log_enabled: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'DefaultServiceRoleSid' => default_service_role_sid,
        'DefaultChannelRoleSid' => default_channel_role_sid,
        'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid,
        'ReadStatusEnabled' => read_status_enabled,
        'ReachabilityEnabled' => reachability_enabled,
        'TypingIndicatorTimeout' => typing_indicator_timeout,
        'ConsumptionReportInterval' => consumption_report_interval,
        'Notifications.NewMessage.Enabled' => notifications_new_message_enabled,
        'Notifications.NewMessage.Template' => notifications_new_message_template,
        'Notifications.NewMessage.Sound' => notifications_new_message_sound,
        'Notifications.NewMessage.BadgeCountEnabled' => notifications_new_message_badge_count_enabled,
        'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled,
        'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template,
        'Notifications.AddedToChannel.Sound' => notifications_added_to_channel_sound,
        'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled,
        'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template,
        'Notifications.RemovedFromChannel.Sound' => notifications_removed_from_channel_sound,
        'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled,
        'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template,
        'Notifications.InvitedToChannel.Sound' => notifications_invited_to_channel_sound,
        'PreWebhookUrl' => pre_webhook_url,
        'PostWebhookUrl' => post_webhook_url,
        'WebhookMethod' => webhook_method,
        'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e },
        'Limits.ChannelMembers' => limits_channel_members,
        'Limits.UserChannels' => limits_user_channels,
        'Media.CompatibilityMessage' => media_compatibility_message,
        'PreWebhookRetryCount' => pre_webhook_retry_count,
        'PostWebhookRetryCount' => post_webhook_retry_count,
        'Notifications.LogEnabled' => notifications_log_enabled,
    })

    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, default_service_role_sid: :unset, default_channel_role_sid: :unset, default_channel_creator_role_sid: :unset, read_status_enabled: :unset, reachability_enabled: :unset, typing_indicator_timeout: :unset, consumption_report_interval: :unset, notifications_new_message_enabled: :unset, notifications_new_message_template: :unset, notifications_new_message_sound: :unset, notifications_new_message_badge_count_enabled: :unset, notifications_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_added_to_channel_sound: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_removed_from_channel_sound: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, notifications_invited_to_channel_sound: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, limits_channel_members: :unset, limits_user_channels: :unset, media_compatibility_message: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, notifications_log_enabled: :unset) ⇒ ServiceInstance

Update the ServiceInstanceMetadata

Parameters:

  • friendly_name (String) (defaults to: :unset)
  • default_service_role_sid (String) (defaults to: :unset)
  • default_channel_role_sid (String) (defaults to: :unset)
  • default_channel_creator_role_sid (String) (defaults to: :unset)
  • read_status_enabled (Boolean) (defaults to: :unset)
  • reachability_enabled (Boolean) (defaults to: :unset)
  • typing_indicator_timeout (String) (defaults to: :unset)
  • consumption_report_interval (String) (defaults to: :unset)
  • notifications_new_message_enabled (Boolean) (defaults to: :unset)
  • notifications_new_message_template (String) (defaults to: :unset)
  • notifications_new_message_sound (String) (defaults to: :unset)
  • notifications_new_message_badge_count_enabled (Boolean) (defaults to: :unset)
  • notifications_added_to_channel_enabled (Boolean) (defaults to: :unset)
  • notifications_added_to_channel_template (String) (defaults to: :unset)
  • notifications_added_to_channel_sound (String) (defaults to: :unset)
  • notifications_removed_from_channel_enabled (Boolean) (defaults to: :unset)
  • notifications_removed_from_channel_template (String) (defaults to: :unset)
  • notifications_removed_from_channel_sound (String) (defaults to: :unset)
  • notifications_invited_to_channel_enabled (Boolean) (defaults to: :unset)
  • notifications_invited_to_channel_template (String) (defaults to: :unset)
  • notifications_invited_to_channel_sound (String) (defaults to: :unset)
  • pre_webhook_url (String) (defaults to: :unset)
  • post_webhook_url (String) (defaults to: :unset)
  • webhook_method (String) (defaults to: :unset)
  • webhook_filters (Array[String]) (defaults to: :unset)
  • limits_channel_members (String) (defaults to: :unset)
  • limits_user_channels (String) (defaults to: :unset)
  • media_compatibility_message (String) (defaults to: :unset)
  • pre_webhook_retry_count (String) (defaults to: :unset)
  • post_webhook_retry_count (String) (defaults to: :unset)
  • notifications_log_enabled (Boolean) (defaults to: :unset)

Returns:



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
484
485
486
487
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
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 455

def (
  friendly_name: :unset, 
  default_service_role_sid: :unset, 
  default_channel_role_sid: :unset, 
  default_channel_creator_role_sid: :unset, 
  read_status_enabled: :unset, 
  reachability_enabled: :unset, 
  typing_indicator_timeout: :unset, 
  consumption_report_interval: :unset, 
  notifications_new_message_enabled: :unset, 
  notifications_new_message_template: :unset, 
  notifications_new_message_sound: :unset, 
  notifications_new_message_badge_count_enabled: :unset, 
  notifications_added_to_channel_enabled: :unset, 
  notifications_added_to_channel_template: :unset, 
  notifications_added_to_channel_sound: :unset, 
  notifications_removed_from_channel_enabled: :unset, 
  notifications_removed_from_channel_template: :unset, 
  notifications_removed_from_channel_sound: :unset, 
  notifications_invited_to_channel_enabled: :unset, 
  notifications_invited_to_channel_template: :unset, 
  notifications_invited_to_channel_sound: :unset, 
  pre_webhook_url: :unset, 
  post_webhook_url: :unset, 
  webhook_method: :unset, 
  webhook_filters: :unset, 
  limits_channel_members: :unset, 
  limits_user_channels: :unset, 
  media_compatibility_message: :unset, 
  pre_webhook_retry_count: :unset, 
  post_webhook_retry_count: :unset, 
  notifications_log_enabled: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'DefaultServiceRoleSid' => default_service_role_sid,
        'DefaultChannelRoleSid' => default_channel_role_sid,
        'DefaultChannelCreatorRoleSid' => default_channel_creator_role_sid,
        'ReadStatusEnabled' => read_status_enabled,
        'ReachabilityEnabled' => reachability_enabled,
        'TypingIndicatorTimeout' => typing_indicator_timeout,
        'ConsumptionReportInterval' => consumption_report_interval,
        'Notifications.NewMessage.Enabled' => notifications_new_message_enabled,
        'Notifications.NewMessage.Template' => notifications_new_message_template,
        'Notifications.NewMessage.Sound' => notifications_new_message_sound,
        'Notifications.NewMessage.BadgeCountEnabled' => notifications_new_message_badge_count_enabled,
        'Notifications.AddedToChannel.Enabled' => notifications_added_to_channel_enabled,
        'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template,
        'Notifications.AddedToChannel.Sound' => notifications_added_to_channel_sound,
        'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled,
        'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template,
        'Notifications.RemovedFromChannel.Sound' => notifications_removed_from_channel_sound,
        'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled,
        'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template,
        'Notifications.InvitedToChannel.Sound' => notifications_invited_to_channel_sound,
        'PreWebhookUrl' => pre_webhook_url,
        'PostWebhookUrl' => post_webhook_url,
        'WebhookMethod' => webhook_method,
        'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e },
        'Limits.ChannelMembers' => limits_channel_members,
        'Limits.UserChannels' => limits_user_channels,
        'Media.CompatibilityMessage' => media_compatibility_message,
        'PreWebhookRetryCount' => pre_webhook_retry_count,
        'PostWebhookRetryCount' => post_webhook_retry_count,
        'Notifications.LogEnabled' => notifications_log_enabled,
    })

    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

#users(sid = :unset) ⇒ UserList, UserContext

Access the users

Returns:

Raises:

  • (ArgumentError)


604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service.rb', line 604

def users(sid=:unset)

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

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

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

 @users
end