Class: Twilio::REST::Chat::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/chat/v1/service.rb,
lib/twilio-ruby/rest/chat/v1/service/role.rb,
lib/twilio-ruby/rest/chat/v1/service/user.rb,
lib/twilio-ruby/rest/chat/v1/service/channel.rb,
lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb,
lib/twilio-ruby/rest/chat/v1/service/channel/member.rb,
lib/twilio-ruby/rest/chat/v1/service/channel/message.rb,
lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb

Defined Under Namespace

Classes: ChannelContext, ChannelInstance, ChannelList, ChannelPage, RoleContext, RoleInstance, RoleList, RolePage, UserContext, UserInstance, UserList, UserPage

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



180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 180

def initialize(version, sid)
  super(version)

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

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

Instance Method Details

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

Access the channels

Returns:

Raises:

  • (ArgumentError)


433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 433

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

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



217
218
219
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 217

def delete
  @version.delete('delete', @uri)
end

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 198

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  ServiceInstance.new(
      @version,
      payload,
      sid: @solution[:sid],
  )
end

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

Access the roles

Returns:

Raises:

  • (ArgumentError)


458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 458

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



506
507
508
509
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 506

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Chat.V1.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_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, webhooks_on_message_send_url: :unset, webhooks_on_message_send_method: :unset, webhooks_on_message_send_format: :unset, webhooks_on_message_update_url: :unset, webhooks_on_message_update_method: :unset, webhooks_on_message_update_format: :unset, webhooks_on_message_remove_url: :unset, webhooks_on_message_remove_method: :unset, webhooks_on_message_remove_format: :unset, webhooks_on_channel_add_url: :unset, webhooks_on_channel_add_method: :unset, webhooks_on_channel_add_format: :unset, webhooks_on_channel_destroy_url: :unset, webhooks_on_channel_destroy_method: :unset, webhooks_on_channel_destroy_format: :unset, webhooks_on_channel_update_url: :unset, webhooks_on_channel_update_method: :unset, webhooks_on_channel_update_format: :unset, webhooks_on_member_add_url: :unset, webhooks_on_member_add_method: :unset, webhooks_on_member_add_format: :unset, webhooks_on_member_remove_url: :unset, webhooks_on_member_remove_method: :unset, webhooks_on_member_remove_format: :unset, webhooks_on_message_sent_url: :unset, webhooks_on_message_sent_method: :unset, webhooks_on_message_sent_format: :unset, webhooks_on_message_updated_url: :unset, webhooks_on_message_updated_method: :unset, webhooks_on_message_updated_format: :unset, webhooks_on_message_removed_url: :unset, webhooks_on_message_removed_method: :unset, webhooks_on_message_removed_format: :unset, webhooks_on_channel_added_url: :unset, webhooks_on_channel_added_method: :unset, webhooks_on_channel_added_format: :unset, webhooks_on_channel_destroyed_url: :unset, webhooks_on_channel_destroyed_method: :unset, webhooks_on_channel_destroyed_format: :unset, webhooks_on_channel_updated_url: :unset, webhooks_on_channel_updated_method: :unset, webhooks_on_channel_updated_format: :unset, webhooks_on_member_added_url: :unset, webhooks_on_member_added_method: :unset, webhooks_on_member_added_format: :unset, webhooks_on_member_removed_url: :unset, webhooks_on_member_removed_method: :unset, webhooks_on_member_removed_format: :unset, limits_channel_members: :unset, limits_user_channels: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    The friendly_name

  • default_service_role_sid (String) (defaults to: :unset)

    The default_service_role_sid

  • default_channel_role_sid (String) (defaults to: :unset)

    The default_channel_role_sid

  • default_channel_creator_role_sid (String) (defaults to: :unset)

    The default_channel_creator_role_sid

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

    The read_status_enabled

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

    The reachability_enabled

  • typing_indicator_timeout (String) (defaults to: :unset)

    The typing_indicator_timeout

  • consumption_report_interval (String) (defaults to: :unset)

    The consumption_report_interval

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

    The notifications.new_message.enabled

  • notifications_new_message_template (String) (defaults to: :unset)

    The notifications.new_message.template

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

    The notifications.added_to_channel.enabled

  • notifications_added_to_channel_template (String) (defaults to: :unset)

    The notifications.added_to_channel.template

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

    The notifications.removed_from_channel.enabled

  • notifications_removed_from_channel_template (String) (defaults to: :unset)

    The notifications.removed_from_channel.template

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

    The notifications.invited_to_channel.enabled

  • notifications_invited_to_channel_template (String) (defaults to: :unset)

    The notifications.invited_to_channel.template

  • pre_webhook_url (String) (defaults to: :unset)

    The pre_webhook_url

  • post_webhook_url (String) (defaults to: :unset)

    The post_webhook_url

  • webhook_method (String) (defaults to: :unset)

    The webhook_method

  • webhook_filters (String) (defaults to: :unset)

    The webhook_filters

  • webhooks_on_message_send_url (String) (defaults to: :unset)

    The webhooks.on_message_send.url

  • webhooks_on_message_send_method (String) (defaults to: :unset)

    The webhooks.on_message_send.method

  • webhooks_on_message_send_format (String) (defaults to: :unset)

    The webhooks.on_message_send.format

  • webhooks_on_message_update_url (String) (defaults to: :unset)

    The webhooks.on_message_update.url

  • webhooks_on_message_update_method (String) (defaults to: :unset)

    The webhooks.on_message_update.method

  • webhooks_on_message_update_format (String) (defaults to: :unset)

    The webhooks.on_message_update.format

  • webhooks_on_message_remove_url (String) (defaults to: :unset)

    The webhooks.on_message_remove.url

  • webhooks_on_message_remove_method (String) (defaults to: :unset)

    The webhooks.on_message_remove.method

  • webhooks_on_message_remove_format (String) (defaults to: :unset)

    The webhooks.on_message_remove.format

  • webhooks_on_channel_add_url (String) (defaults to: :unset)

    The webhooks.on_channel_add.url

  • webhooks_on_channel_add_method (String) (defaults to: :unset)

    The webhooks.on_channel_add.method

  • webhooks_on_channel_add_format (String) (defaults to: :unset)

    The webhooks.on_channel_add.format

  • webhooks_on_channel_destroy_url (String) (defaults to: :unset)

    The webhooks.on_channel_destroy.url

  • webhooks_on_channel_destroy_method (String) (defaults to: :unset)

    The webhooks.on_channel_destroy.method

  • webhooks_on_channel_destroy_format (String) (defaults to: :unset)

    The webhooks.on_channel_destroy.format

  • webhooks_on_channel_update_url (String) (defaults to: :unset)

    The webhooks.on_channel_update.url

  • webhooks_on_channel_update_method (String) (defaults to: :unset)

    The webhooks.on_channel_update.method

  • webhooks_on_channel_update_format (String) (defaults to: :unset)

    The webhooks.on_channel_update.format

  • webhooks_on_member_add_url (String) (defaults to: :unset)

    The webhooks.on_member_add.url

  • webhooks_on_member_add_method (String) (defaults to: :unset)

    The webhooks.on_member_add.method

  • webhooks_on_member_add_format (String) (defaults to: :unset)

    The webhooks.on_member_add.format

  • webhooks_on_member_remove_url (String) (defaults to: :unset)

    The webhooks.on_member_remove.url

  • webhooks_on_member_remove_method (String) (defaults to: :unset)

    The webhooks.on_member_remove.method

  • webhooks_on_member_remove_format (String) (defaults to: :unset)

    The webhooks.on_member_remove.format

  • webhooks_on_message_sent_url (String) (defaults to: :unset)

    The webhooks.on_message_sent.url

  • webhooks_on_message_sent_method (String) (defaults to: :unset)

    The webhooks.on_message_sent.method

  • webhooks_on_message_sent_format (String) (defaults to: :unset)

    The webhooks.on_message_sent.format

  • webhooks_on_message_updated_url (String) (defaults to: :unset)

    The webhooks.on_message_updated.url

  • webhooks_on_message_updated_method (String) (defaults to: :unset)

    The webhooks.on_message_updated.method

  • webhooks_on_message_updated_format (String) (defaults to: :unset)

    The webhooks.on_message_updated.format

  • webhooks_on_message_removed_url (String) (defaults to: :unset)

    The webhooks.on_message_removed.url

  • webhooks_on_message_removed_method (String) (defaults to: :unset)

    The webhooks.on_message_removed.method

  • webhooks_on_message_removed_format (String) (defaults to: :unset)

    The webhooks.on_message_removed.format

  • webhooks_on_channel_added_url (String) (defaults to: :unset)

    The webhooks.on_channel_added.url

  • webhooks_on_channel_added_method (String) (defaults to: :unset)

    The webhooks.on_channel_added.method

  • webhooks_on_channel_added_format (String) (defaults to: :unset)

    The webhooks.on_channel_added.format

  • webhooks_on_channel_destroyed_url (String) (defaults to: :unset)

    The webhooks.on_channel_destroyed.url

  • webhooks_on_channel_destroyed_method (String) (defaults to: :unset)

    The webhooks.on_channel_destroyed.method

  • webhooks_on_channel_destroyed_format (String) (defaults to: :unset)

    The webhooks.on_channel_destroyed.format

  • webhooks_on_channel_updated_url (String) (defaults to: :unset)

    The webhooks.on_channel_updated.url

  • webhooks_on_channel_updated_method (String) (defaults to: :unset)

    The webhooks.on_channel_updated.method

  • webhooks_on_channel_updated_format (String) (defaults to: :unset)

    The webhooks.on_channel_updated.format

  • webhooks_on_member_added_url (String) (defaults to: :unset)

    The webhooks.on_member_added.url

  • webhooks_on_member_added_method (String) (defaults to: :unset)

    The webhooks.on_member_added.method

  • webhooks_on_member_added_format (String) (defaults to: :unset)

    The webhooks.on_member_added.format

  • webhooks_on_member_removed_url (String) (defaults to: :unset)

    The webhooks.on_member_removed.url

  • webhooks_on_member_removed_method (String) (defaults to: :unset)

    The webhooks.on_member_removed.method

  • webhooks_on_member_removed_format (String) (defaults to: :unset)

    The webhooks.on_member_removed.format

  • limits_channel_members (String) (defaults to: :unset)

    The limits.channel_members

  • limits_user_channels (String) (defaults to: :unset)

    The limits.user_channels

Returns:



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
420
421
422
423
424
425
426
427
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 342

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_added_to_channel_enabled: :unset, notifications_added_to_channel_template: :unset, notifications_removed_from_channel_enabled: :unset, notifications_removed_from_channel_template: :unset, notifications_invited_to_channel_enabled: :unset, notifications_invited_to_channel_template: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, webhook_method: :unset, webhook_filters: :unset, webhooks_on_message_send_url: :unset, webhooks_on_message_send_method: :unset, webhooks_on_message_send_format: :unset, webhooks_on_message_update_url: :unset, webhooks_on_message_update_method: :unset, webhooks_on_message_update_format: :unset, webhooks_on_message_remove_url: :unset, webhooks_on_message_remove_method: :unset, webhooks_on_message_remove_format: :unset, webhooks_on_channel_add_url: :unset, webhooks_on_channel_add_method: :unset, webhooks_on_channel_add_format: :unset, webhooks_on_channel_destroy_url: :unset, webhooks_on_channel_destroy_method: :unset, webhooks_on_channel_destroy_format: :unset, webhooks_on_channel_update_url: :unset, webhooks_on_channel_update_method: :unset, webhooks_on_channel_update_format: :unset, webhooks_on_member_add_url: :unset, webhooks_on_member_add_method: :unset, webhooks_on_member_add_format: :unset, webhooks_on_member_remove_url: :unset, webhooks_on_member_remove_method: :unset, webhooks_on_member_remove_format: :unset, webhooks_on_message_sent_url: :unset, webhooks_on_message_sent_method: :unset, webhooks_on_message_sent_format: :unset, webhooks_on_message_updated_url: :unset, webhooks_on_message_updated_method: :unset, webhooks_on_message_updated_format: :unset, webhooks_on_message_removed_url: :unset, webhooks_on_message_removed_method: :unset, webhooks_on_message_removed_format: :unset, webhooks_on_channel_added_url: :unset, webhooks_on_channel_added_method: :unset, webhooks_on_channel_added_format: :unset, webhooks_on_channel_destroyed_url: :unset, webhooks_on_channel_destroyed_method: :unset, webhooks_on_channel_destroyed_format: :unset, webhooks_on_channel_updated_url: :unset, webhooks_on_channel_updated_method: :unset, webhooks_on_channel_updated_format: :unset, webhooks_on_member_added_url: :unset, webhooks_on_member_added_method: :unset, webhooks_on_member_added_format: :unset, webhooks_on_member_removed_url: :unset, webhooks_on_member_removed_method: :unset, webhooks_on_member_removed_format: :unset, limits_channel_members: :unset, limits_user_channels: :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.AddedToChannel.Enabled' => notifications_added_to_channel_enabled,
      'Notifications.AddedToChannel.Template' => notifications_added_to_channel_template,
      'Notifications.RemovedFromChannel.Enabled' => notifications_removed_from_channel_enabled,
      'Notifications.RemovedFromChannel.Template' => notifications_removed_from_channel_template,
      'Notifications.InvitedToChannel.Enabled' => notifications_invited_to_channel_enabled,
      'Notifications.InvitedToChannel.Template' => notifications_invited_to_channel_template,
      'PreWebhookUrl' => pre_webhook_url,
      'PostWebhookUrl' => post_webhook_url,
      'WebhookMethod' => webhook_method,
      'WebhookFilters' => webhook_filters,
      'Webhooks.OnMessageSend.Url' => webhooks_on_message_send_url,
      'Webhooks.OnMessageSend.Method' => webhooks_on_message_send_method,
      'Webhooks.OnMessageSend.Format' => webhooks_on_message_send_format,
      'Webhooks.OnMessageUpdate.Url' => webhooks_on_message_update_url,
      'Webhooks.OnMessageUpdate.Method' => webhooks_on_message_update_method,
      'Webhooks.OnMessageUpdate.Format' => webhooks_on_message_update_format,
      'Webhooks.OnMessageRemove.Url' => webhooks_on_message_remove_url,
      'Webhooks.OnMessageRemove.Method' => webhooks_on_message_remove_method,
      'Webhooks.OnMessageRemove.Format' => webhooks_on_message_remove_format,
      'Webhooks.OnChannelAdd.Url' => webhooks_on_channel_add_url,
      'Webhooks.OnChannelAdd.Method' => webhooks_on_channel_add_method,
      'Webhooks.OnChannelAdd.Format' => webhooks_on_channel_add_format,
      'Webhooks.OnChannelDestroy.Url' => webhooks_on_channel_destroy_url,
      'Webhooks.OnChannelDestroy.Method' => webhooks_on_channel_destroy_method,
      'Webhooks.OnChannelDestroy.Format' => webhooks_on_channel_destroy_format,
      'Webhooks.OnChannelUpdate.Url' => webhooks_on_channel_update_url,
      'Webhooks.OnChannelUpdate.Method' => webhooks_on_channel_update_method,
      'Webhooks.OnChannelUpdate.Format' => webhooks_on_channel_update_format,
      'Webhooks.OnMemberAdd.Url' => webhooks_on_member_add_url,
      'Webhooks.OnMemberAdd.Method' => webhooks_on_member_add_method,
      'Webhooks.OnMemberAdd.Format' => webhooks_on_member_add_format,
      'Webhooks.OnMemberRemove.Url' => webhooks_on_member_remove_url,
      'Webhooks.OnMemberRemove.Method' => webhooks_on_member_remove_method,
      'Webhooks.OnMemberRemove.Format' => webhooks_on_member_remove_format,
      'Webhooks.OnMessageSent.Url' => webhooks_on_message_sent_url,
      'Webhooks.OnMessageSent.Method' => webhooks_on_message_sent_method,
      'Webhooks.OnMessageSent.Format' => webhooks_on_message_sent_format,
      'Webhooks.OnMessageUpdated.Url' => webhooks_on_message_updated_url,
      'Webhooks.OnMessageUpdated.Method' => webhooks_on_message_updated_method,
      'Webhooks.OnMessageUpdated.Format' => webhooks_on_message_updated_format,
      'Webhooks.OnMessageRemoved.Url' => webhooks_on_message_removed_url,
      'Webhooks.OnMessageRemoved.Method' => webhooks_on_message_removed_method,
      'Webhooks.OnMessageRemoved.Format' => webhooks_on_message_removed_format,
      'Webhooks.OnChannelAdded.Url' => webhooks_on_channel_added_url,
      'Webhooks.OnChannelAdded.Method' => webhooks_on_channel_added_method,
      'Webhooks.OnChannelAdded.Format' => webhooks_on_channel_added_format,
      'Webhooks.OnChannelDestroyed.Url' => webhooks_on_channel_destroyed_url,
      'Webhooks.OnChannelDestroyed.Method' => webhooks_on_channel_destroyed_method,
      'Webhooks.OnChannelDestroyed.Format' => webhooks_on_channel_destroyed_format,
      'Webhooks.OnChannelUpdated.Url' => webhooks_on_channel_updated_url,
      'Webhooks.OnChannelUpdated.Method' => webhooks_on_channel_updated_method,
      'Webhooks.OnChannelUpdated.Format' => webhooks_on_channel_updated_format,
      'Webhooks.OnMemberAdded.Url' => webhooks_on_member_added_url,
      'Webhooks.OnMemberAdded.Method' => webhooks_on_member_added_method,
      'Webhooks.OnMemberAdded.Format' => webhooks_on_member_added_format,
      'Webhooks.OnMemberRemoved.Url' => webhooks_on_member_removed_url,
      'Webhooks.OnMemberRemoved.Method' => webhooks_on_member_removed_method,
      'Webhooks.OnMemberRemoved.Format' => webhooks_on_member_removed_format,
      'Limits.ChannelMembers' => limits_channel_members,
      'Limits.UserChannels' => limits_user_channels,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  ServiceInstance.new(
      @version,
      payload,
      sid: @solution[:sid],
  )
end

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

Access the users

Returns:

Raises:

  • (ArgumentError)


483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/twilio-ruby/rest/chat/v1/service.rb', line 483

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